Time Series Analysis Henrik Madsen hm@imm.dtu.dk Informatics and - - PowerPoint PPT Presentation

time series analysis
SMART_READER_LITE
LIVE PREVIEW

Time Series Analysis Henrik Madsen hm@imm.dtu.dk Informatics and - - PowerPoint PPT Presentation

H. Madsen, Time Series Analysis, Chapmann Hall Time Series Analysis Henrik Madsen hm@imm.dtu.dk Informatics and Mathematical Modelling Technical University of Denmark DK-2800 Kgs. Lyngby Henrik Madsen 1 H. Madsen, Time Series Analysis,


slide-1
SLIDE 1

1 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Time Series Analysis

Henrik Madsen

hm@imm.dtu.dk

Informatics and Mathematical Modelling Technical University of Denmark DK-2800 Kgs. Lyngby

slide-2
SLIDE 2

2 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Outline of the lecture

Regression based methods, 2nd part: Regression and exponential smoothing (Sec. 3.4) Time series with seasonal variations (Sec. 3.5)

slide-3
SLIDE 3

3 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Regression without explanatory variables

During Lecture 2 we saw that assuming known independent variables x we can forecast the dependent variable Y To be able to do so we estimated θ in Yt = f(xt, t; θ) + εt If we do not have access to x we may use: Yt = f(t; θ) + εt During this lecture we shall consider models of this (last) form and we shall consider how θ can be updated as more information becomes available Only models linear in θ will be considered

slide-4
SLIDE 4

4 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Model: Constant mean

Yt = µ + εt, εt i.i.d. with mean zero and constant variance σ2 (white noise). In vector form (t = 1, . . . , N): Y = 1µ + ε Estimate: ˆ µ = (1T 1)−11T Y = N−1

N

  • t=1

Yt = ¯ y· Prediction (the conditional mean): YN+ℓ|N = µ = 1

N N

  • t=1

Yt Variance of the prediction error: V

  • YN+ℓ −

YN+ℓ|N

  • = σ2(1 + 1

N )

slide-5
SLIDE 5

5 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Updating the estimate

Based on Y1, Y2, . . . , YN we have ˆ µN = 1

N N

  • t=1

Yt When we get one more observation YN+1 the best estimate is ˆ µN+1 =

1 N+1 N+1

  • t=1

Yt Recursive update: ˆ µN+1 = 1 N + 1

N+1

  • t=1

Yt = 1 N + 1YN+1 + N N + 1 ˆ µN

slide-6
SLIDE 6

6 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Model: Local constant mean

In the constant mean model the variance of the forecast error decrease towards σ2 as 1/N Therefore, if N is sufficiently high (say 100) there is not much gained by increasing the number of observations If there is indications that the true (underlying) mean is actually changing slowly it can even be advantageous to “forget” old

  • bservations.

One way of doing this is to base the estimate on a rolling window containing e.g. the 100 most recent observations An alternative is exponential smoothening

slide-7
SLIDE 7

7 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Exponential smoothening

ˆ µN = c

N−1

  • j=0

λjYN−j = c[YN + λYN−1 + · · · + λN−1Y1]

Observation number Weight 5 10 15 20 25 30 c

The constant c is chosen so that the weights sum to one, which implies that c = (1 − λ)/(1 − λN). For large N: ˆ µN+1 = (1−λ)YN+1 +λˆ µN or YN+ℓ+1|N+1 = (1−λ)YN+1 +λ YN+ℓ|N

slide-8
SLIDE 8

8 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Choice of smoothing constant α = 1 − λ

The smoothing constant α = 1 − λ determines how much the latest observation influence the prediction Given a data set t = 1, . . . , N we can try different values before implementing the method on-line S(α) =

N

  • t=1

(Yt − Yt|t−1(α))2 If the data set is large we eliminate the influence of the initial estimate by dropping the first part of the errors when evaluating S(α)

slide-9
SLIDE 9

9 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Example – wind speed 76 m a.g.l. at Risø

Measurements of wind speed every 10th minute Task: Forecast up to approximately 3 hours ahead using exponential smoothing

  • 10min. avg. of wind speed (m/s)

Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep

2002 2003 5 10 15 20 25

slide-10
SLIDE 10

10 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

S(α) for horizons 10 and 70 minutes

20000 30000 40000 50000 0.2 0.4 0.6 0.8 10 minutes Weight on most recent observation SSE 80000 85000 90000 95000 100000 0.2 0.4 0.6 0.8 70 minutes Weight on most recent observation SSE

10 minutes (1-step): Use α = 0.95 or higher 70 minutes (7-step): Use α ≈ 0.7

slide-11
SLIDE 11

11 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

S(α) for horizons 130 and 190 minutes

130000 135000 140000 145000 0.2 0.4 0.6 0.8 130 minutes Weight on most recent observation SSE 174000 176000 178000 180000 182000 184000 186000 0.2 0.4 0.6 0.8 190 minutes Weight on most recent observation SSE

130 minutes (13-step): Use α ≈ 0.6 190 minutes (19-step): Use α ≈ 0.5

slide-12
SLIDE 12

12 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Example of forecasts with optimal α

m/s

12:00 14:00 16:00 18:00 20:00 22:00 0:00 2:00 4:00 6:00 8:00 10:00 12:00 Jan 11 2003 Jan 12 2003 4 6 8 10 12 14

Measurements 10 minute forecast 190 minute forecast

slide-13
SLIDE 13

13 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Trend models

Linear regression model Functions of time are taken as the independent variables

slide-14
SLIDE 14

14 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Linear trend

Observations for t = 1, . . . , N Naive formulation of the model: Yt = φ0 + φ1 t + εt If we want to forecast YN+j given information up to N we use

  • YN+j|N = ˆ

φ0 + ˆ φ1 (N + j) However, for on-line applications N + j can be arbitrary large The problem arise because φ0 and φ1 is defined w.r.t. the

  • rigin 0

Defining the parameters w.r.t. the origin n we obtain the model: Yt = θ0 + θ1 (t − N) + εt Using this formulation we get: YN+j|N = ˆ θ0 + ˆ θ1 j

slide-15
SLIDE 15

15 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Linear trend in a general setting

The general trend model: YN+j = f T (j)θ + εN+j The linear trend model is obtained when: f(j) = 1 j

  • It follows that for N + 1 + j:

YN+1+j =

  • 1

j + 1 T θ+εN+1+j = 1 1 1 1 j T θ+εN+1+j The 2 × 2 matrix L defines the transition from f(j) to f(j + 1)

slide-16
SLIDE 16

16 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Trend models in general

Model: YN+j = f T (j)θ + εN+j Requirement: f(j + 1) = Lf(j) Initial value: f(0) In Section 3.4 some trend models which fulfill the requirement above are listed. Constant mean: YN+j = θ0 + εN+j Linear trend: YN+j = θ0 + θ1j + εN+j Quadratic trend: YN+j = θ0 + θ1j + θ2

j2 2 + εn+j

k’th order polynomial trend: Yn+j = θ0 + θ1j + θ2

j2 2 + · · · + θk jk k! + εN+j

Harmonic model with the period p: YN+j = θ0 + θ1 sin 2π

p j + θ2 cos 2π p j + εN+j

slide-17
SLIDE 17

17 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Estimation

Model equations written for all observations Y1, . . . , YN Y = xNθ+ ε      Y1 Y2 . . . YN      =      f T (−N + 1) f T (−N + 2) . . . f T (0)      θ+      ε1 ε2 . . . εN      OLS-estimates: θN = (xT

NxN)−1xT NY or

  • θN = F −1

N hN

F N =

N−1

  • j=0

f(−j)f T (−j) hN =

N−1

  • j=0

f(−j)YN−j

slide-18
SLIDE 18

18 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

ℓ-step prediction

Prediction:

  • YN+ℓ|N = f T (ℓ)

θN Variance of the prediction error: V [YN+ℓ − YN+ℓ|N] = σ2 1 + f T (ℓ)F −1

N f(ℓ)

  • 100(1 − α)% prediction interval:
  • YN+ℓ|N ± tα/2(N − p)
  • V [eN(ℓ)] =
  • YN+ℓ|N ± tα/2(N − p)

σ

  • 1 + f T (ℓ)F −1

N f(ℓ)

where ˆ σ2 = εT ε/(N − p) (p is the number of estimated parameters)

slide-19
SLIDE 19

19 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Updating the estimates when YN+1 is available

Task: Going from estimates based on t = 1, . . . , N, i.e. θN to estimates based on t = 1, . . . , N, N + 1, i.e. θN+1 without redoing everything. . . Solution:

  • θN+1

= F −1

N+1hN+1

F N+1 = F N + f(−N)f T (−N) hN+1 = L−1hN + f(0)YN+1

slide-20
SLIDE 20

20 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Local trend models

We forget old observations in an exponential manner:

  • θN = arg min

θ S(θ; N)

where for 0 < λ < 1 S(θ; N) =

N−1

  • j=0

λj[YN−j − f T (−j)θ]2

j (age of observation) Weight 5 10 15 20 25 30 0.0 0.4 0.8

slide-21
SLIDE 21

21 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

WLS formulation

The criterion: S(θ; N) =

N−1

  • j=0

λj[YN−j − f T (−j)θ]2 can be written as:      Y1 − f T (N − 1)θ Y2 − f T (N − 2)θ . . . YN − fT (0)θ     

T 

    λN−1 · · · λN−2 · · · . . . . . . ... . . . 1           Y1 − f T (N − 1)θ Y2 − f T (N − 2)θ . . . YN − f T (0)θ      which is a WLS criterion with Σ = diag[1/λN−1, . . . , 1/λ, 1]

slide-22
SLIDE 22

22 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

WLS solution

  • θN = (xT

NΣ−1xN)−1xT NΣ−1Y

  • r
  • θN

= F −1

N hN

F N =

N−1

  • j=0

λjf(−j)f T (−j) hN =

N−1

  • j=0

λjf(−j)YN−j

slide-23
SLIDE 23

23 Henrik Madsen

  • H. Madsen, Time Series Analysis, Chapmann Hall

Updating the estimates when YN+1 is available

  • θN+1

= F −1

N+1hN+1

F N+1 = F N + λNf(−N)f T (−N) hN+1 = λL−1hN + f(0)YN+1 When no data is available we can use h0 = 0 and F 0 = 0 For many functions λNf(−N)f T (−N) → 0 for N → ∞ and we get the stationary result F N+1 = F N = F . Hence:

  • θN+1 = LT

θN + F −1f(0)[YN+1 − YN+1|N]