lecture_22_periodicity
lecture_22_periodicity
Forecasting
Lecture 22
Periodicity in Time Series
• Assignments
• Assignment 5 due on Thursd y
• Quick review
• SARIMA models:
Multiplic tive ARIMA models for se son l d t
• Combining regression with SARIMA
C lend r ex mples
2
a
a
a
a
a
a
a
a
a
Today’s Topics
Text, §6.1-6.2
• Periodogr m
• E icient comput tion of regression with n predictors
• Fourier frequencies: Uncorrel ted expl n tory v ri bles
• F st Fourier tr nsform
3
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Differencing and
Deterministic Trends
Differencing a Linear Trend
• Model
• Suppose process is line r trend plus white noise
Xt = α + β t + wt
• You di erence it, s if r ndom w lk
(1 − B) Xt = β + (1 − B) wt
5
a
ff
a
a
a
ff
a
a
a
a
a
ff
a
a
ff
a
Differencing a Linear Trend
• Model
• Line r trend plus white noise
Xt = α + β t + wt
• Di erencing yields
(1 − B) Xt = β + (1 − B) wt
6
ff
a
a
a
a
a
a
a
Differencing a Seasonal Trend
• Model
• Process is se son l trend plus AR(1) noise
Xt = α + St + Zt, (1 − ϕB)Zt = wt
where St is deterministic se son l p ttern
St − St−12 = 0
• You se son lly di erence it, s if stoch stic trend
(1 − B 12) (1 − ϕB) Xt = (1 − B 12) wt
7
f
a
a
a
a
a
a
a
ff
a
a
ff
a
a
a
ff
a
a
a
ff
a
a
a
a
a
Differencing a Seasonal Trend
• Model
• Se son l trend plus AR(1) noise
Xt = α + St + zt, (1 − ϕB)zt = wt
with St − St−12 = 0
• Se son lly di erenced
(1 − B 12) (1 − ϕB) Xt = (1 − B 12) wt
8
a
a
a
a
a
a
a
a
ff
a
Back to the Housing Example
• Monthly housing st rts
• 10 ye rs, 2010-2019
• log sc le
• Trend ppe rs stoch stic, so di erence
• Stoch stic se son lity too?
9
a
a
a
a
a
a
f
a
a
a
a
ff
a
a
a
a
a
ff
a
a
a
ff
a
Back to the Housing Example
• Estim tion results
• Consistent with deterministic se son l trend
• Residu l di gnostics look ok y
• Wh t to do?
• Softw re is ine with the itted model
(though model is not invertible)
-> Le ve it lone (forec sts work ine)
• Revise model to h ve deterministic se son l
trend (periodic) it with regression.
10
a
a
a
a
a
f
a
f
a
a
a
f
a
a
a
a
a
f
a
Deterministic Seasonal Trend
• Regression fe tures
12
• Use monthly dummy v ri bles to cre te se son l trend for which (1 − B ) St =0
• Ret in di erencing for over ll trend.
• Over ll it nd forec sts comp r ble to SARIMA model
Close to MA1
estim te in
SARIMA model
11
a
a
a
f
ff
a
a
a
a
a
a
a
a
a
a
a
Deterministic Seasonal Trend
• Di erent ppro ch to regression fe tures
12
• Cre te fe tures from sines nd cosines, so th t (1 − B ) St = 0
Cosine/Sine with period 12, period 6, period 4, period 3, period 2.4, nd period 2
• Use di erencing for over ll trend. Fit nd forec sts m tch the prior regression
period 12
period 6
period 4
period 3
period 2.4
period 2
12
ff
a
ff
a
a
a
a
a
a
a
a
a
Periodic Predictors
using
Sines and Cosines
Periodic Behavior
• Widespre d phenomen re periodic
• Astronomic l d t
v ri ble st r m gnitude, qu s rs
• Clim te
nnu l temper ture, ozone levels
• Medic l d t
pulse, EKG
• Business cycles re somewh t periodic
• Questions
• Does time series show periodic v ri tion?
• At wh t frequencies?
• Should white noise h ve periodic fe tures?
14
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Sinusoidal Functions
• Sinusoid model
• De ine
Text writes ω r ther th n
Xt = R cos(2π ν t + φ) + wt ν for the frequency. I just
c nnot do th t!
• ν is the frequency (reciproc l of the period)
• R is the mplitude of the cosine w ve.
• φ is the ph se of the cosine
(does not lw ys st rt t 1 when t = 0)
• V ri ble st r ex mple
• D t isn’t single sinusoid
• Residu ls from regression of st r m gnitudes on
cos/sine with frequency 21/600 is nother sine w ve.
• Counting pe ks suggests second frequency 25/600
18
a
a
a
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Estimating a Periodic Function
• Le st squ res estim tes
• Sum of sinusoids
∑
Xt = Aj cos(2π νj t) + Bj sin(2π νj t)
j
• M gnitude of e ch given by Rj2 = Aj2 + Bj2.
• V ri ble st r ex mple
• Try with frequencies set to ν1=21/600, ν2=25/600
• Still not quite right: sinusoid rem ins
• Integer periods?
• Periods of these re 600/21≈28.6 nd 600/25=24.
• Round these to integer periods
See Bloom ield, Ch pter 3 for further discussion of inding these frequencies 19
a
a
a
a
f
a
a
a
a
a
a
a
a
a
f
Estimating a Periodic Function
• Le st squ res estim tes
• Sum of sinusoids
∑
Xt = Aj cos(2πνj t) + Bj sin(2πνj t)
j <latexit sha1_base64="3PoouSwEOXbl2t/f9uEuUeTu4KY=">AAACk3icdZHdatswFMdldx9d9pV17Go3YmFlUFBkL3VixqDLdrGbQTeatlAnQZbVVMSWhKRsDcZvtYfYK+xtpsQecws7IDj//znnh46Uqpwbi/Fvz9+5c/fe/d0HnYePHj952n22d2rkSlM2oTKX+jwlhuVcsInlNmfnSjNSpDk7S5cfN/Wz70wbLsWJXSs2LchC8EtOiXXWvPsrSdmCi5JoTdZVqWledSBMrogtv1XzYBbC/ff7tf5Q64NajWuVEKW0vIYRwsNZeDBEcdxyA4xR5HBUt6DhLWh4Axq2x9HorYNGaDRoufAQo7CGJkxkzdXn3R5GMQ7iwyGsk9GgSaLYkfA2eqCJ43n3Z5JJuiqYsDQnxlwEWNmpo1lOc1Z1kpVhitAlWbALlwpSMDMtty9ewdfOyeCl1O4IC7due6IkhTHrInWdBbFX5nZtY/6rcaFWtuxPjPuofirT/g+pl31F1EYbS0RGdIYsu646bs2/u8D/J6chCiIUfR30jsbNwrvgJXgF3oAADMER+AyOwQRQD3kn3tSb+S/8d/7Y/1S3+l4z8xzcCP/LH9c3vks=</latexit>
20
a
a
a
a
a
a
a
a
a
a
Finding Periodic Components
The periodogr m
a
Hidden Periodicity
• Does time series cont in periodic components?
• E sy to identify periodic functions in c ses like the v ri ble st r
• n tur l in context
• obvious in d t
• Wh t bout periodicities in other time series?
• st tion ry process
• se son l d t
• residu ls from models th t supposedly c pture se son lity
• Di gnostic
• L st pplic tion is n import nt di gnostic
• Do “dese son lized” d t h ve periodic components?
• Do residu ls from n SARIMA model h ve periodic components?
• Bro d ppro ch
• Compute the mount of energy ( mplitude) of ll the possible sinusoids … the periodogr m
22
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Periodogram
• Why estim te just couple of frequencies
• If n is n even number, we c n write with no error
n/2
∑
ak = (2/n) xt cos(2πtk/n)
∑
Xt = aj cos(2π t j/n) + bj sin(2π t j/n) Equ tion 6.8
∑
bk = (2/n) xt sin(2πtk/n)
j=0
• End c ses re speci l since sin(0) = sin(k π) = 0 so b0 = bn/2 = 0 (cos(0) = 1, cos(k π)=±1)
• Sc led periodogr m
P(k/n) = ak2 + bk2 = Rk2 De inition 6.3
• Fourier frequencies
• Sine/cosines with frequencies νj = j/n, for j = 0, 1, …, n/2
Supplement l
• Highest frequency is νn/2 = 1/2, .k. . the folding frequency or Nyquist frequency slides discuss
li sing
• Asides
• Line r tr nsform tion ( rot tion) of time series (X1, …, Xn) into coe icients ( 0, 1,b1, …, n/2)
• If n is highly composite (e.g. n = 2m), then c n compute in O(n log n) using FFT
23
a
a
f
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Properties of Periodogram
• Suppose time series is white noise
• Coe icients
∑ ∑
ak = (2/n) wt cos(2πtk/n) nd bk = (2/n) wt sin(2πtk/n)
• Expected v lues re e sy
E ak = E bk = 0
Appendix
• V ri nces nd cov ri nces re lso e sy – if you remember b sic trigonometry Property C.3
4 σw2 n 2
2 σw2 p ge 234
n2 ∑
Var(ak) = Var(bk) = sin (2πkt/n) = k = 1, 2, …, n/2-1
t=1
n
n/2
Cov(ak, aj) = 0 ( j ≠ k) and Cov(ak, bj) =0
• Periodogr m
2 2 2
n 2 N(0,1) + N(0,1) χ
I(k/n) = (ak + bk2) ≈ σw2 2 Proportion l to n
• De ine s = σw2 exponenti l r ndom
4 2 2 v ri ble
24
a
a
a
a
f
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Properties of Periodogram
• Periodogr m of white noise
• Proportion l to exponenti l r.v.
n 2 χ2
I(k/n) = (ak + bk ) ∼ σw
2 2 2
4 2
• Approxim tely independent v lues s mpled from skewed distribution: Very noisy ppe r nce
Exponenti l
• Ex mple
Distribution
• n = 256
2
• White noise, σw =5
25
a
a
a
a
a
a
a
a
Examples of Periodogram
White Noise (n=128) V ri ble St r (n=600)
26
a
a
a
a
What’s next?
• S mpling properties of the periodogr m
• Are pe ks in white noise import nt or just s mpling v ri tion?
• Key di gnostic:
- For residu ls from model, wh t should the periodogr m show?
- For dese son lized d t from FRED, wh t should the periodogr m show?
27
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Supplements
f
Not covered: More Examples
• fMRI
• Sign l indic ted by squ re w ves (Ex mple 1.6) with period 64 seconds
• C ution: D t s mpled 1 point every two seconds. M x observ ble frequency is 1/2δ = 1/4 seconds
• Expect sign l response t period 32 me surements
• Sign l is evident in 4 output series, but re these signi ic nt?
29
BOLD = blood oxygen level dependent Periodogr ms shown on zoomed sc le
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Aliasing and Nyquist Frequency
• Beh vior under s mpling
• We observe discrete time series, equ lly sp ced observ tions of continuous process
• Highest frequency we c n estim te is 1/2 since we need t le st 2 observ tions within cycle
≈ Figure 6.1
• 1/2 is known s the Nyquist or folding frequency
• Sinusoids with frequencies higher th n 1/2 ppe r
t lower frequency
• Ex mple
• Continuous process h s period 4 hours, or frequency 1/4
• Process is s mpled every 2.5 hours
• Discrete time series h s cycle t lower frequency 1/20
• M th
• S mple continuous process t times t = 0, δ, 2δ, 3δ… f 0 ))
<latexit sha1_base64="evOMpHJlmreKf4waojxhjUT0uco=">AAADIXicpVJPb9MwFHfCvxH+dXDk8kTFlogtTarR0QPSBBeOQ6LbpLmqHMfprDpOZLtAFeXT8BU48gW4IW6IG1f4EDhtJgoa4sCTorz3+yc/J0kpuDZR9MVxL12+cvXaxnXvxs1bt+90Nu8e6WKuKBvRQhTqJCGaCS7ZyHAj2EmpGMkTwY6T2fOGP37NlOaFfGUWJRvnZCp5xikxFppsOiOcsCmXFVGKLOpKUVGDB4Bpof0+4JID3jF4B7IAtp5uLXHAgmXG7zeksTT4cQ+nTBgCu5BtB4AVn54Z+6aqybJ1kdWfwcoV/FeG1S8P8Q/TSj8L1qfG19geAdZcQrtvo1kbzXk2VRdGttezHXiYybS9x0mnG4XDKB4+3odV82SvbQZDiMNoWV3U1uGk8x6nBZ3nTBoqiNancVSasU0znApWe3iuWUnojEzZqW0lyZkeV8vvX8NDi6SQFco+0sASXXdUJNd6kSdWmRNzpv/kGvAXx2U5N1VvpO1v00uKpPemULNeScpm1obIlKg0NOxt7dk1z3eBvzdH/TAehIOXe92DZ+3CG+g+eoB8FKN9dIBeoEM0QtT54Hxzvjs/3HfuR/eT+3kldZ3Wcw/9Vu7XnyI15Nw=</latexit>
• Ali s
• Ali sing will h ppen since 1/2 < f
• Resulting discrete time series h s sinusoid t frequency 0.25
<latexit sha1_base64="HCG2/S1c4g5IeZmBO2k4kv2O63A=">AAACmXicdVFbb9MwFHYyLiNcVsbjXo6omFoxcqm6jj4gDXiZeBqCbhNzVTmO21lNbMt2gSrKv+J38M6/wckyoAiOZOWc813kz0lVzo2N4x+ev3Xr9p272/eC+w8ePtrpPN49M3KlKZtQmUt9kRLDci7YxHKbswulGSnSnJ2ny7c1fv6ZacOl+GjXik0LshB8zimxbjXrfMcpW3BREq3Juio1zSsIADCVpjcArDjgA4sPIAkHh33Yf7XfQIBzNrctwUIvgeeQRMM+YM0XV9Z9qa5tXP2S9AYNub8x1ZoXgA0XcOPW3xwbV6r/aeau5uAAM5G1AWadbhyO42R8eATXzcth24zGLkTcVBe1dTrrfMOZpKuCCUtzYsxlEis7dW6W05xVAV4ZpghdkgW7dK0gBTPTsnn3Cp65TQZzqd0RFprtn4qSFMasi9QxC2KvzN9YvfyNcaFWtowmxv2uKJVp9EXqZaSIqmdjiciIzkLLvlaBi3mTBf7fnA3CZBSO3g+7x2/awNtoDz1FPZSgI3SMTtApmiDqDb1PHvUyf89/7Z/4766pvtdqnqCN8j/8BL7sukg=</latexit>