Trend spotting ! TIME SE R IE S AN ALYSIS IN R Da v id S . Ma - - PowerPoint PPT Presentation

trend spotting
SMART_READER_LITE
LIVE PREVIEW

Trend spotting ! TIME SE R IE S AN ALYSIS IN R Da v id S . Ma - - PowerPoint PPT Presentation

Trend spotting ! TIME SE R IE S AN ALYSIS IN R Da v id S . Ma eson Associate Professor at Cornell Uni v ersit y Trends Some time series do not e x hibit an y clear trends o v er time : TIME SERIES ANALYSIS IN R Trends : linear E x amples of


slide-1
SLIDE 1

Trend spotting!

TIME SE R IE S AN ALYSIS IN R

David S. Maeson

Associate Professor at Cornell University

slide-2
SLIDE 2

TIME SERIES ANALYSIS IN R

Trends

Some time series do not exhibit any clear trends over time:

slide-3
SLIDE 3

TIME SERIES ANALYSIS IN R

Trends: linear

Examples of linear trends over time:

slide-4
SLIDE 4

TIME SERIES ANALYSIS IN R

Trends: rapid growth

Examples of rapid growth trends over time:

slide-5
SLIDE 5

TIME SERIES ANALYSIS IN R

Trends: periodic

Examples of periodic or sinusoidal trends over time:

slide-6
SLIDE 6

TIME SERIES ANALYSIS IN R

Trends: variance

Examples of increasing variance trends over time:

slide-7
SLIDE 7

TIME SERIES ANALYSIS IN R

Sample transformations: log()

The log() function can linearize a rapid growth trend:

slide-8
SLIDE 8

TIME SERIES ANALYSIS IN R

Sample transformations: diff()

The diff() function can remove a linear trend:

slide-9
SLIDE 9

TIME SERIES ANALYSIS IN R

Sample transformations: diff(…, s)

The diff(…, s) function, or seasonal dierence transformation, can remove periodic trends.

diff(x, s = 4)

slide-10
SLIDE 10

Let's practice!

TIME SE R IE S AN ALYSIS IN R

slide-11
SLIDE 11

The white noise (WN) model

TIME SE R IE S AN ALYSIS IN R

David S. Maeson

Associate Professor at Cornell University

slide-12
SLIDE 12

TIME SERIES ANALYSIS IN R

White noise

White Noise (WN) is the simplest example of a stationary process. A weak white noise process has: A xed, constant mean. A xed, constant variance. No correlation over time.

slide-13
SLIDE 13

TIME SERIES ANALYSIS IN R

White noise

Time series plots of White Noise:

slide-14
SLIDE 14

TIME SERIES ANALYSIS IN R

White noise

Time series plots of White Noise?

slide-15
SLIDE 15

TIME SERIES ANALYSIS IN R

# Simulate n = 50 observations from the WN model WN_1 <- arima.sim(model = list(order = c(0, 0, 0)), n = 50) head(WN_1)

  • 0.005052984 0.042669765 3.261154066

2.486431235 0.283119322 1.543525773 ts.plot(WN_1)

slide-16
SLIDE 16

TIME SERIES ANALYSIS IN R # Simulate from the WN model with mean = 4, sd = 2 WN_2 <- arima.sim(model = list(order = c(0, 0, 0)), n = 50, mean = 4, sd = 2) ts.plot(WN_2)

slide-17
SLIDE 17

TIME SERIES ANALYSIS IN R

Estimating white noise

# Fit the WN model with # arima()arima(WN_2,

  • rder =

c(0, 0, 0)) Coefficients: intercept 4.0739 s.e. 0.2698 sigma^2 estimated as 3.639 # Calculate the sample # mean and sample variance # of WN mean(WN_2) 4.0739 var(WN_2) 3.713

slide-18
SLIDE 18

Let's practice!

TIME SE R IE S AN ALYSIS IN R

slide-19
SLIDE 19

The random walk (RW) model

TIME SE R IE S AN ALYSIS IN R

David S. Maeson

Associate Professor at Cornell University

slide-20
SLIDE 20

TIME SERIES ANALYSIS IN R

Random walk

Random Walk (RW) is a simple example of a non-stationary process. A random walk has: No specied mean or variance. Strong dependence over time. Its changes or increments are white noise (WN).

slide-21
SLIDE 21

TIME SERIES ANALYSIS IN R

Random walk

Time series plots of Random Walk:

slide-22
SLIDE 22

TIME SERIES ANALYSIS IN R

Random walk

The random walk recursion:

Today = Y esterday + Noise

More formally:

Y = Y + ϵ

where ϵ is mean zero white noise (WN). Simulation requires an initial point Y . Only one parameter, the WN variance σ .

t t−1 t t ϵ 2

slide-23
SLIDE 23

TIME SERIES ANALYSIS IN R

Random walk - I

The random walk process:

Y = Y + ϵ

where ϵ is mean zero WN As Y − Y

= ϵ → diff(Y) is WN

t t−1 t t t t−1 t

slide-24
SLIDE 24

TIME SERIES ANALYSIS IN R

Random walk - II

slide-25
SLIDE 25

TIME SERIES ANALYSIS IN R

Random walk with drift - I

The random walk with a dri:

Today = Constant + Y esterday + Noise

More formally:

Y = c + Y + ϵ

where ϵ is mean zero white noise (WN). Two parameters, the constant c , and the WN variance σ .

Y − Y = ? → WN with mean c!

t t−1 t t ϵ 2 t t−1

slide-26
SLIDE 26

TIME SERIES ANALYSIS IN R

Random walk with drift - II

Time series plots of Random Walk with dri:

slide-27
SLIDE 27

Let's practice!

TIME SE R IE S AN ALYSIS IN R

slide-28
SLIDE 28

Stationary processes

TIME SE R IE S AN ALYSIS IN R

David S. Maeson

Associate Professor at Cornell University

slide-29
SLIDE 29

TIME SERIES ANALYSIS IN R

Stationarity

Stationary models are parsimonious. Stationary processes have distributional stability over time. Observed time series: Fluctuate randomly. But behave similarly from one time period to the next.

slide-30
SLIDE 30

TIME SERIES ANALYSIS IN R

Weak stationarity - I

Weak stationary: mean, variance, covariance constant over time.

Y ,Y , ...is a weakly stationary process if:

Mean μ of Y is same (constant) for all t. Variance σ of Y is same (constant) for all t. And….

1 2 t 2 t

slide-31
SLIDE 31

TIME SERIES ANALYSIS IN R

Weak stationarity - II

Covariance of Y and Y is same (constant) for all ∣t − s∣ = h, for allh.

Cov(Y ,Y ) = Cov(Y ,Y )

since each pair is separated by three units of time.

t s 2 5 7 10

slide-32
SLIDE 32

TIME SERIES ANALYSIS IN R

Stationarity: why?

A stationary process can be modeled with fewer parameters. For example, we do not need a dierent expectation for each Y ; rather they all have a common expectation, μ. Estimate μ accurately by .

t

y ¯

slide-33
SLIDE 33

TIME SERIES ANALYSIS IN R

Stationarity: when?

Many nancial time series do not exhibit stationarity, however: The changes in the series are oen approximately stationary. A stationary series should show random oscillation around some xed level; a phenomenon called mean-reversion.

slide-34
SLIDE 34

TIME SERIES ANALYSIS IN R

Stationarity example

Ination rates and changes in ination rates:

slide-35
SLIDE 35

Let's practice!

TIME SE R IE S AN ALYSIS IN R