You are on page 1of 20

INTRODUCTION TO TIME SERIES ANALYSIS

Welcome to
the Course!
Introduction to Time Series Analysis

Introduction
● Time Series: A sequence of data in chronological order
● Data is commonly recorded sequentially, over time
● Time series data is everywhere
BMW Daily log stock returns
0.10
0.05
0.00
−0.05
−0.10
−0.15

Sep 01 Jan 02 Jan 01 Jan 01 Jan 01 Jan 01 Jan 03 Jan 01


1980 1983 1985 1987 1989 1991 1993 1995
Introduction to Time Series Analysis

Time Series Example


Monthly values ofConsumer
the Consumer Price
Price Index
Index (CPI):
20
15
Inflation Rate (%)

10
5
0
−5

1960 1965 1970 1975 1980 1985 1990

Year
Introduction to Time Series Analysis

Time Series Data


● Time series data is dated or time stamped in R

> print(BMW_data)
...
1996-07-08 0.002
1996-07-09 -0.006
1996-07-10 -0.016
1996-07-11 -0.020
1996-07-14 -0.006
1996-07-15 -0.014
1996-07-16 0.002
1996-07-17 -0.001
...
Introduction to Time Series Analysis

Time Series Plots


> plot(Time_Series)
Example Time Series Plot
3


2

● ●
● ●


Time_Series




0

● ●


−1


−2

5 10 15 20

Time
Introduction to Time Series Analysis

Basic Time Series Models


● White Noise (WN)
● Random Walk (RW)
● Autoregression (AR)
● Simple Moving Average (MA)
INTRODUCTION TO TIME SERIES ANALYSIS

Let’s practice!
INTRODUCTION TO TIME SERIES ANALYSIS

Sampling Frequency
Introduction to Time Series Analysis

Sampling Frequency: Exact


● Some time series data is exactly evenly spaced
74

● ●

● ●

● ●
72



Hourly Temp.

70




68

● ●


66

● ●

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time
Introduction to Time Series Analysis

Sampling Frequency: Approximate


● Some time series data is only approximately evenly spaced

74



● ●

● ● ●
● ●
72

●●


Hourly Temp.


70



68



66

● ●

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time
Introduction to Time Series Analysis

Sampling Frequency: Missing Values


● Some time series data is evenly spaced, but with missing values
74

● ●


72


Hourly Temp.



70


68


66

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time
Introduction to Time Series Analysis

Basic Assumptions
Simplifying assumptions for time series:
● Consecutive observations are equally spaced
● Apply a discrete-time observation index
● This may only hold approximately
Ex. Daily log returns on stock may only be available

for weekdays.
Ex. Monthly CPI values are equally spaced by month, 

not by day.
Introduction to Time Series Analysis

Sampling Frequency: R Functions


● R functions: start(), end(), frequency(), deltat()

> start(Hourly_series)
[1] 1 1

> end(Hourly_series)
[1] 1 24

> frequency(Hourly_series)
[1] 24

> deltat(Hourly_series)
[1] 0.0417
INTRODUCTION TO TIME SERIES ANALYSIS

Let’s practice!
INTRODUCTION TO TIME SERIES ANALYSIS

Basic Time
Series Objects
Introduction to Time Series Analysis

Building ts() Objects - I


● Start with a vector of data
● Apply the ts() function
> data_vector
[1] 10 6 11 8 10 3 6 9

> time_series <- ts(data_vector)


> plot(time_series)
8 10
time_series

6
4

1 2 3 4 5 6 7 8

Time
Introduction to Time Series Analysis

Building ts() Objects - II


● Specify the start date and observation frequency:
> time_series <- ts(data_vector, start = 2001, frequency = 1)
> plot(time_series)
10
time_series

8
6
4

2001 2002 2003 2004 2005 2006 2007 2008

Time
Introduction to Time Series Analysis

Using is.ts()
● The is.ts() function checks whether an object is of the ts() class:
> is.ts(data_vector)
[1] FALSE

> is.ts(time_series)
[1] TRUE
Introduction to Time Series Analysis

Why ts() Objects?


Why create and use time series objects of the ts() class?
● Improved plo!ing
● Access to time index information
● Model estimation and forecasting (later chapters)
INTRODUCTION TO TIME SERIES ANALYSIS

Let’s practice!

You might also like