Forecasting using 4. White noise and time series decomposition OTexts.com/fpp/2/6 OTexts.com/fpp/6/ Forecasting using R 1 Rob J Hyndman
Forecasting using
4. White noise and time series decomposition
OTexts.com/fpp/2/6OTexts.com/fpp/6/
Forecasting using R 1
Rob J Hyndman
Student award
To students who make the most contribution tothe class, as voted by their peers.
Contributions can be on Piazza or during thewebex online sessions.
Contribute questions, answers, comments,code suggestions, etc.
Looking for engaged learners, not experts.
At end of course, all students to vote for bestcontributor.
$100 to the top voted student and $50 tothe second student (plus t-shirts).
Forecasting using R 2
Time zones
All sessions are at UTC 22:00for the entire course.Be aware when your time zone changes.
Most of Europe changed last Sunday. So classesare now one hour earlier for most Europeanresidents.
Most of USA and Canada change next Sunday.So classes will be one hour earlier for mostNorth American residents from next week.
Forecasting using R 3
Outline
1 White noise
2 Time series decomposition
3 Seasonal adjustment
4 Forecasting and decomposition
Forecasting using R White noise 4
Example: White noise
Forecasting using R White noise 5
White noise
Time
x
0 10 20 30 40 50
−3
−2
−1
01
2
Example: White noise
Forecasting using R White noise 5
White noise
Time
x
0 10 20 30 40 50
−3
−2
−1
01
2
White noise data is uncorrelated acrosstime with zero mean and constant variance.(Technically, we require independence aswell.)
Example: White noise
Forecasting using R White noise 5
White noise
Time
x
0 10 20 30 40 50
−3
−2
−1
01
2
White noise data is uncorrelated acrosstime with zero mean and constant variance.(Technically, we require independence aswell.)
Think of white noise as completelyuninteresting with no predictable patterns.
Example: White noise
r1 = 0.013r2 = −0.163r3 = 0.163r4 = −0.259r5 = −0.198r6 = 0.064r7 = −0.139r8 = −0.032r9 = 0.199r10 = −0.240
Sample autocorrelations for white noise series.For uncorrelated data, we would expect eachautocorrelation to be close to zero.
Forecasting using R White noise 6
−0.
4−
0.2
0.0
0.2
0.4
Lag
AC
F
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1511 13
Sampling distribution of autocorrelations
Sampling distribution of rk for white noise data isasymptotically N(0,1/T).
95% of all rk for white noise must lie within±1.96/
√T.
If this is not the case, the series is probably notWN.
Common to plot lines at ±1.96/√T when
plotting ACF. These are the critical values.
Forecasting using R White noise 7
Sampling distribution of autocorrelations
Sampling distribution of rk for white noise data isasymptotically N(0,1/T).
95% of all rk for white noise must lie within±1.96/
√T.
If this is not the case, the series is probably notWN.
Common to plot lines at ±1.96/√T when
plotting ACF. These are the critical values.
Forecasting using R White noise 7
Sampling distribution of autocorrelations
Sampling distribution of rk for white noise data isasymptotically N(0,1/T).
95% of all rk for white noise must lie within±1.96/
√T.
If this is not the case, the series is probably notWN.
Common to plot lines at ±1.96/√T when
plotting ACF. These are the critical values.
Forecasting using R White noise 7
Sampling distribution of autocorrelations
Sampling distribution of rk for white noise data isasymptotically N(0,1/T).
95% of all rk for white noise must lie within±1.96/
√T.
If this is not the case, the series is probably notWN.
Common to plot lines at ±1.96/√T when
plotting ACF. These are the critical values.
Forecasting using R White noise 7
Autocorrelation
Forecasting using R White noise 8
−0.
4−
0.2
0.0
0.2
0.4
Lag
AC
F
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1511 13
Example:T = 50 and socritical values at±1.96/
√50 =
±0.28.All autocorrelationcoefficients lie withinthese limits,confirming that thedata are white noise.(More precisely, the data cannot bedistinguished from white noise.)
Example: Pigs slaughtered
Forecasting using R White noise 9
Number of pigs slaughtered in Victoria
thou
sand
s
1990 1991 1992 1993 1994 1995
8090
100
110
Example: Pigs slaughtered
Forecasting using R White noise 10
−0.
20.
00.
2
Lag
AC
F
0 10 20 30 40
Example: Pigs slaughtered
Monthly total number of pigs slaughtered in thestate of Victoria, Australia, from January 1990through August 1995. (Source: Australian Bureau ofStatistics.)
Difficult to detect pattern in time plot.
ACF shows some significant autocorrelation atlags 1, 2, and 3.
r12 relatively large although not significant.This may indicate some slight seasonality.
These show the series is not a white noise series.
Forecasting using R White noise 11
Example: Pigs slaughtered
Monthly total number of pigs slaughtered in thestate of Victoria, Australia, from January 1990through August 1995. (Source: Australian Bureau ofStatistics.)
Difficult to detect pattern in time plot.
ACF shows some significant autocorrelation atlags 1, 2, and 3.
r12 relatively large although not significant.This may indicate some slight seasonality.
These show the series is not a white noise series.
Forecasting using R White noise 11
Example: Pigs slaughtered
Monthly total number of pigs slaughtered in thestate of Victoria, Australia, from January 1990through August 1995. (Source: Australian Bureau ofStatistics.)
Difficult to detect pattern in time plot.
ACF shows some significant autocorrelation atlags 1, 2, and 3.
r12 relatively large although not significant.This may indicate some slight seasonality.
These show the series is not a white noise series.
Forecasting using R White noise 11
Example: Pigs slaughtered
Monthly total number of pigs slaughtered in thestate of Victoria, Australia, from January 1990through August 1995. (Source: Australian Bureau ofStatistics.)
Difficult to detect pattern in time plot.
ACF shows some significant autocorrelation atlags 1, 2, and 3.
r12 relatively large although not significant.This may indicate some slight seasonality.
These show the series is not a white noise series.
Forecasting using R White noise 11
Example: Pigs slaughtered
Monthly total number of pigs slaughtered in thestate of Victoria, Australia, from January 1990through August 1995. (Source: Australian Bureau ofStatistics.)
Difficult to detect pattern in time plot.
ACF shows some significant autocorrelation atlags 1, 2, and 3.
r12 relatively large although not significant.This may indicate some slight seasonality.
These show the series is not a white noise series.
Forecasting using R White noise 11
Example: Pigs slaughtered
Monthly total number of pigs slaughtered in thestate of Victoria, Australia, from January 1990through August 1995. (Source: Australian Bureau ofStatistics.)
Difficult to detect pattern in time plot.
ACF shows some significant autocorrelation atlags 1, 2, and 3.
r12 relatively large although not significant.This may indicate some slight seasonality.
These show the series is not a white noise series.
Forecasting using R White noise 11
ACF of residuals
We assume that the residuals are white noise(uncorrelated, mean zero, constant variance). Ifthey aren’t, then there is information left in theresiduals that should be used in computingforecasts.So a standard residual diagnostic is to checkthe ACF of the residuals of a forecastingmethod.We expect these to look like white noise.
Dow-Jones naive forecasts revisited
yt|t−1 = yt−1
et = yt − yt−1
Forecasting using R White noise 12
ACF of residuals
We assume that the residuals are white noise(uncorrelated, mean zero, constant variance). Ifthey aren’t, then there is information left in theresiduals that should be used in computingforecasts.So a standard residual diagnostic is to checkthe ACF of the residuals of a forecastingmethod.We expect these to look like white noise.
Dow-Jones naive forecasts revisited
yt|t−1 = yt−1
et = yt − yt−1
Forecasting using R White noise 12
ACF of residuals
We assume that the residuals are white noise(uncorrelated, mean zero, constant variance). Ifthey aren’t, then there is information left in theresiduals that should be used in computingforecasts.So a standard residual diagnostic is to checkthe ACF of the residuals of a forecastingmethod.We expect these to look like white noise.
Dow-Jones naive forecasts revisited
yt|t−1 = yt−1
et = yt − yt−1
Forecasting using R White noise 12
ACF of residuals
We assume that the residuals are white noise(uncorrelated, mean zero, constant variance). Ifthey aren’t, then there is information left in theresiduals that should be used in computingforecasts.So a standard residual diagnostic is to checkthe ACF of the residuals of a forecastingmethod.We expect these to look like white noise.
Dow-Jones naive forecasts revisited
yt|t−1 = yt−1
et = yt − yt−1
Forecasting using R White noise 12
ACF of residuals
We assume that the residuals are white noise(uncorrelated, mean zero, constant variance). Ifthey aren’t, then there is information left in theresiduals that should be used in computingforecasts.So a standard residual diagnostic is to checkthe ACF of the residuals of a forecastingmethod.We expect these to look like white noise.
Dow-Jones naive forecasts revisited
yt|t−1 = yt−1
et = yt − yt−1
Forecasting using R White noise 12
Forecasting Dow-Jones index
Forecasting using R White noise 13
Day
Cha
nge
in D
ow−
Jone
s in
dex
0 50 100 150 200 250 300
−10
0−
500
50
Forecasting Dow-Jones index
Forecasting using R White noise 14
−0.
15−
0.05
0.05
0.10
0.15
Lag
AC
F
1 2 3 4 5 6 7 8 9 10 12 14 16 18 20 2211 13 15 17 19 21 23
Example: Dow-Jones residuals
−0.
15−
0.05
0.05
0.10
0.15
Lag
AC
F
1 2 3 4 5 6 7 8 9 10 12 14 16 18 20 2211 13 15 17 19 21 23
These look like white noise.
But the ACF is a multiple testing problem.
Forecasting using R White noise 15
Example: Dow-Jones residuals
−0.
15−
0.05
0.05
0.10
0.15
Lag
AC
F
1 2 3 4 5 6 7 8 9 10 12 14 16 18 20 2211 13 15 17 19 21 23
These look like white noise.
But the ACF is a multiple testing problem.
Forecasting using R White noise 15
Portmanteau testsConsider a whole set of rk values, and develop atest to see whether the set is significantly differentfrom a zero set.
Forecasting using R White noise 16
Portmanteau testsConsider a whole set of rk values, and develop atest to see whether the set is significantly differentfrom a zero set.
Box-Pierce test
Q = Th∑
k=1
r2k
where h is max lag being considered and T isnumber of observations.
My preferences: h = 10 for non-seasonal data, h = 2mfor seasonal data.If each rk close to zero, Q will be small.If some rk values large (positive or negative), Q will belarge.
Forecasting using R White noise 16
Portmanteau testsConsider a whole set of rk values, and develop atest to see whether the set is significantly differentfrom a zero set.
Box-Pierce test
Q = Th∑
k=1
r2k
where h is max lag being considered and T isnumber of observations.
My preferences: h = 10 for non-seasonal data, h = 2mfor seasonal data.If each rk close to zero, Q will be small.If some rk values large (positive or negative), Q will belarge.
Forecasting using R White noise 16
Portmanteau testsConsider a whole set of rk values, and develop atest to see whether the set is significantly differentfrom a zero set.
Box-Pierce test
Q = Th∑
k=1
r2k
where h is max lag being considered and T isnumber of observations.
My preferences: h = 10 for non-seasonal data, h = 2mfor seasonal data.If each rk close to zero, Q will be small.If some rk values large (positive or negative), Q will belarge.
Forecasting using R White noise 16
Portmanteau testsConsider a whole set of rk values, and develop atest to see whether the set is significantly differentfrom a zero set.
Box-Pierce test
Q = Th∑
k=1
r2k
where h is max lag being considered and T isnumber of observations.
My preferences: h = 10 for non-seasonal data, h = 2mfor seasonal data.If each rk close to zero, Q will be small.If some rk values large (positive or negative), Q will belarge.
Forecasting using R White noise 16
Portmanteau testsConsider a whole set of rk values, and develop atest to see whether the set is significantly differentfrom a zero set.
Ljung-Box test
Q∗ = T(T + 2)h∑
k=1
(T − k)−1r2k
where h is max lag being considered and T isnumber of observations.
My preferences: h = 10 for non-seasonal data, h = 2mfor seasonal data.Better performance, especially in small samples.
Forecasting using R White noise 16
Portmanteau testsIf data are WN, Q∗ has χ2 distribution with(h− K) degrees of freedom where K = no.parameters in model.
When applied to raw data, set K = 0.For the Dow-Jones example,
res <- residuals(naive(dj))
# lag=h and fitdf=K> Box.test(res, lag=10, fitdf=0)Box-Pierce testX-squared = 14.0451, df = 10, p-value = 0.1709> Box.test(res, lag=10, fitdf=0, type="Lj")Box-Ljung testX-squared = 14.4615, df = 10, p-value = 0.153
Forecasting using R White noise 17
Portmanteau testsIf data are WN, Q∗ has χ2 distribution with(h− K) degrees of freedom where K = no.parameters in model.
When applied to raw data, set K = 0.For the Dow-Jones example,
res <- residuals(naive(dj))
# lag=h and fitdf=K> Box.test(res, lag=10, fitdf=0)Box-Pierce testX-squared = 14.0451, df = 10, p-value = 0.1709> Box.test(res, lag=10, fitdf=0, type="Lj")Box-Ljung testX-squared = 14.4615, df = 10, p-value = 0.153
Forecasting using R White noise 17
Portmanteau testsIf data are WN, Q∗ has χ2 distribution with(h− K) degrees of freedom where K = no.parameters in model.
When applied to raw data, set K = 0.For the Dow-Jones example,
res <- residuals(naive(dj))
# lag=h and fitdf=K> Box.test(res, lag=10, fitdf=0)Box-Pierce testX-squared = 14.0451, df = 10, p-value = 0.1709> Box.test(res, lag=10, fitdf=0, type="Lj")Box-Ljung testX-squared = 14.4615, df = 10, p-value = 0.153
Forecasting using R White noise 17
Exercise
1 Calculate the residuals from a seasonal
naive forecast applied to the quarterly
Australian beer production data from
1992.
2 Test if the residuals are white noise.
Forecasting using R White noise 18
Exercise
1 Calculate the residuals from a seasonal
naive forecast applied to the quarterly
Australian beer production data from
1992.
2 Test if the residuals are white noise.
beer <- window(ausbeer,start=1992)fc <- snaive(beer)res <- residuals(fc)Acf(res)Box.test(res, lag=8, fitdf=0, type="Lj")
Forecasting using R White noise 19
Outline
1 White noise
2 Time series decomposition
3 Seasonal adjustment
4 Forecasting and decomposition
Forecasting using R Time series decomposition 20
Time series decomposition
Yt = f(St, Tt,Et)
where Yt = data at period tSt = seasonal component at period tTt = trend-cycle component at period tEt = remainder (or irregular or error)
component at period t
Additive decomposition: Yt = St + Tt + Et.Multiplicative decomposition: Yt = St × Tt × Et.
Forecasting using R Time series decomposition 21
Time series decomposition
Yt = f(St, Tt,Et)
where Yt = data at period tSt = seasonal component at period tTt = trend-cycle component at period tEt = remainder (or irregular or error)
component at period t
Additive decomposition: Yt = St + Tt + Et.Multiplicative decomposition: Yt = St × Tt × Et.
Forecasting using R Time series decomposition 21
Time series decomposition
Yt = f(St, Tt,Et)
where Yt = data at period tSt = seasonal component at period tTt = trend-cycle component at period tEt = remainder (or irregular or error)
component at period t
Additive decomposition: Yt = St + Tt + Et.Multiplicative decomposition: Yt = St × Tt × Et.
Forecasting using R Time series decomposition 21
Time series decomposition
Additive model appropriate if magnitude ofseasonal fluctuations does not vary with level.
If seasonal are proportional to level of series,then multiplicative model appropriate.
Multiplicative decomposition more prevalentwith economic series
Logs turn multiplicative relationship into anadditive relationship:
Yt = St×Tt×Et ⇒ log Yt = logSt+log Tt+logEt.
Forecasting using R Time series decomposition 22
Time series decomposition
Additive model appropriate if magnitude ofseasonal fluctuations does not vary with level.
If seasonal are proportional to level of series,then multiplicative model appropriate.
Multiplicative decomposition more prevalentwith economic series
Logs turn multiplicative relationship into anadditive relationship:
Yt = St×Tt×Et ⇒ log Yt = logSt+log Tt+logEt.
Forecasting using R Time series decomposition 22
Time series decomposition
Additive model appropriate if magnitude ofseasonal fluctuations does not vary with level.
If seasonal are proportional to level of series,then multiplicative model appropriate.
Multiplicative decomposition more prevalentwith economic series
Logs turn multiplicative relationship into anadditive relationship:
Yt = St×Tt×Et ⇒ log Yt = logSt+log Tt+logEt.
Forecasting using R Time series decomposition 22
Time series decomposition
Additive model appropriate if magnitude ofseasonal fluctuations does not vary with level.
If seasonal are proportional to level of series,then multiplicative model appropriate.
Multiplicative decomposition more prevalentwith economic series
Logs turn multiplicative relationship into anadditive relationship:
Yt = St×Tt×Et ⇒ log Yt = logSt+log Tt+logEt.
Forecasting using R Time series decomposition 22
History of time series decomposition
Classical method originated in 1920s.
In R: decompose().
Census II method introduced in 1957.
Basis for modern X-12-ARIMA method.
STL method introduced in 1983. It only
allows additive decomposition.
In R: stl().
TRAMO/SEATS introduced in 1990s.
Forecasting using R Time series decomposition 23
History of time series decomposition
Classical method originated in 1920s.
In R: decompose().
Census II method introduced in 1957.
Basis for modern X-12-ARIMA method.
STL method introduced in 1983. It only
allows additive decomposition.
In R: stl().
TRAMO/SEATS introduced in 1990s.
Forecasting using R Time series decomposition 23
History of time series decomposition
Classical method originated in 1920s.
In R: decompose().
Census II method introduced in 1957.
Basis for modern X-12-ARIMA method.
STL method introduced in 1983. It only
allows additive decomposition.
In R: stl().
TRAMO/SEATS introduced in 1990s.
Forecasting using R Time series decomposition 23
History of time series decomposition
Classical method originated in 1920s.
In R: decompose().
Census II method introduced in 1957.
Basis for modern X-12-ARIMA method.
STL method introduced in 1983. It only
allows additive decomposition.
In R: stl().
TRAMO/SEATS introduced in 1990s.
Forecasting using R Time series decomposition 23
History of time series decomposition
Classical method originated in 1920s.
In R: decompose().
Census II method introduced in 1957.
Basis for modern X-12-ARIMA method.
STL method introduced in 1983. It only
allows additive decomposition.
In R: stl().
TRAMO/SEATS introduced in 1990s.
Forecasting using R Time series decomposition 23
History of time series decomposition
Classical method originated in 1920s.
In R: decompose().
Census II method introduced in 1957.
Basis for modern X-12-ARIMA method.
STL method introduced in 1983. It only
allows additive decomposition.
In R: stl().
TRAMO/SEATS introduced in 1990s.
Forecasting using R Time series decomposition 23
Classical decomposition
Forecasting using R Time series decomposition 24
3050
7090
data
−10
−5
05
10
seas
onal
3040
5060
tren
d
−10
010
1975 1980 1985 1990 1995
rem
aind
er
time
STL decomposition
Forecasting using R Time series decomposition 25
3050
7090
data
−10
−5
05
10
seas
onal
4050
60
tren
d
−15
−5
05
10
1975 1980 1985 1990 1995
rem
aind
er
time
Examples: US house sales
Forecasting using R Time series decomposition 26
Sales of new one−family houses, USA
Tota
l sal
es
1975 1980 1985 1990 1995
3040
5060
7080
90
Examples: US house sales
Forecasting using R Time series decomposition 27
Sales of new one−family houses, USA
Tota
l sal
es
1975 1980 1985 1990 1995
3040
5060
7080
90
Examples: US house sales
Forecasting using R Time series decomposition 28
Time
Dat
a
1975 1980 1985 1990 1995
3050
7090
Sea
sona
l
1975 1980 1985 1990 1995
−10
05
Examples: US house sales
Forecasting using R Time series decomposition 29
Dat
a
1975 1980 1985 1990 1995
3050
7090
Time
Err
or
1975 1980 1985 1990 1995
−15
−5
515
Examples: US house sales
Forecasting using R Time series decomposition 29
Dat
a
1975 1980 1985 1990 1995
3050
7090
Time
Err
or
1975 1980 1985 1990 1995
−15
−5
515
Examples: US house sales
Forecasting using R Time series decomposition 30
3050
7090
data
−10
−5
05
10
seas
onal
4050
60
tren
d
−15
−5
05
10
1975 1980 1985 1990 1995
rem
aind
er
time
Time series decomposition in R
plot(decompose(hsales))
plot(stl(hsales,s.window="periodic"))
plot(stl(hsales,s.window=15))
Forecasting using R Time series decomposition 31
Euro electrical equipment
Forecasting using R Time series decomposition 32
Electrical equipment manufacturing (Euro area)
New
ord
ers
inde
x
2000 2005 2010
6070
8090
100
110
120
130
Euro electrical equipment
Forecasting using R Time series decomposition 33
Electrical equipment manufacturing (Euro area)
New
ord
ers
inde
x
2000 2005 2010
6070
8090
100
110
120
130
Euro electrical equipment
Forecasting using R Time series decomposition 34
6080
100
120
data
−20
−10
05
10
seas
onal
8090
100
110
tren
d
−8
−4
02
46
2000 2005 2010
rem
aind
er
time
Euro electrical equipment
Forecasting using R Time series decomposition 35
6080
100
120
data
−20
−10
05
10
seas
onal
8090
100
110
tren
d
−8
−4
02
46
2000 2005 2010
rem
aind
er
time
fit <- stl(elecequip, s.window=5)plot(fit)
Euro electrical equipment
Seasonal sub-series plot of the seasonal component
Forecasting using R Time series decomposition 36
Sea
sona
l
J F M A M J J A S O N D
−20
−15
−10
−5
05
1015
Euro electrical equipment
Seasonal sub-series plot of the seasonal component
Forecasting using R Time series decomposition 37
Sea
sona
l
J F M A M J J A S O N D
−20
−15
−10
−5
05
1015
monthplot(fit$time.series[,"seasonal"],ylab="Seasonal")
Euro electrical equipment
Forecasting using R Time series decomposition 38
6080
100
120
data
−15
−5
05
10
seas
onal
8090
100
110
tren
d
−5
05
10
2000 2005 2010
rem
aind
er
time
Euro electrical equipment
Forecasting using R Time series decomposition 39
6080
100
120
data
−15
−5
05
10
seas
onal
8090
100
110
tren
d
−5
05
10
2000 2005 2010
rem
aind
er
time
fit <- stl(elecequip, t.window=15,s.window="periodic", robust=TRUE)
plot(fit)
Euro electrical equipment
Forecasting using R Time series decomposition 40
6080
100
120
data
−15
−5
05
10
seas
onal
8090
100
110
tren
d
−5
05
10
2000 2005 2010
rem
aind
er
time
fit <- stl(elecequip, t.window=15,s.window="periodic", robust=TRUE)
plot(fit)
t.windowcontrolswiggliness oftrendcomponent.
s.windowcontrolsvariation inseasonalcomponent.
Euro electrical equipment
Forecasting using R Time series decomposition 40
6080
100
120
data
−15
−5
05
10
seas
onal
8090
100
110
tren
d
−5
05
10
2000 2005 2010
rem
aind
er
time
fit <- stl(elecequip, t.window=15,s.window="periodic", robust=TRUE)
plot(fit)
t.windowcontrolswiggliness oftrendcomponent.
s.windowcontrolsvariation inseasonalcomponent.
Outline
1 White noise
2 Time series decomposition
3 Seasonal adjustment
4 Forecasting and decomposition
Forecasting using R Seasonal adjustment 41
Seasonal adjustment
Useful by-product of decomposition: an easyway to calculate seasonally adjusted data.
Additive decomposition: seasonally adjusteddata given by
Yt − St = Tt + Et
Multiplicative decomposition: seasonallyadjusted data given by
Yt/St = Tt × Et
Forecasting using R Seasonal adjustment 42
Seasonal adjustment
Useful by-product of decomposition: an easyway to calculate seasonally adjusted data.
Additive decomposition: seasonally adjusteddata given by
Yt − St = Tt + Et
Multiplicative decomposition: seasonallyadjusted data given by
Yt/St = Tt × Et
Forecasting using R Seasonal adjustment 42
Seasonal adjustment
Useful by-product of decomposition: an easyway to calculate seasonally adjusted data.
Additive decomposition: seasonally adjusteddata given by
Yt − St = Tt + Et
Multiplicative decomposition: seasonallyadjusted data given by
Yt/St = Tt × Et
Forecasting using R Seasonal adjustment 42
Euro electrical equipment
Seasonally adjusted series
Forecasting using R Seasonal adjustment 43
Electrical equipment manufacturing
New
ord
ers
inde
x
2000 2005 2010
6070
8090
100
110
120
130
Seasonal adjustment in R
seasadj(obj)
where obj is the output from stl() or
decompose().
Exampleplot(hsales,col="gray")
fit <- stl(hsales,s.window=15)
hsales.sa <- seasadj(fit)
lines(hsales.sa, col="red")
Forecasting using R Seasonal adjustment 44
Seasonal adjustment in R
seasadj(obj)
where obj is the output from stl() or
decompose().
Exampleplot(hsales,col="gray")
fit <- stl(hsales,s.window=15)
hsales.sa <- seasadj(fit)
lines(hsales.sa, col="red")
Forecasting using R Seasonal adjustment 44
Outline
1 White noise
2 Time series decomposition
3 Seasonal adjustment
4 Forecasting and decomposition
Forecasting using R Forecasting and decomposition 45
Forecasting and decomposition
Forecast seasonal component by repeating thelast year
Forecast seasonally adjusted data usingnon-seasonal time series method. E.g.,
Holt’s method — next topicRandom walk with drift model
Combine forecasts of seasonal component withforecasts of seasonally adjusted data to getforecasts of original data.
Sometimes a decomposition is useful just forunderstanding the data before building aseparate forecasting model.
Forecasting using R Forecasting and decomposition 46
Forecasting and decomposition
Forecast seasonal component by repeating thelast year
Forecast seasonally adjusted data usingnon-seasonal time series method. E.g.,
Holt’s method — next topicRandom walk with drift model
Combine forecasts of seasonal component withforecasts of seasonally adjusted data to getforecasts of original data.
Sometimes a decomposition is useful just forunderstanding the data before building aseparate forecasting model.
Forecasting using R Forecasting and decomposition 46
Forecasting and decomposition
Forecast seasonal component by repeating thelast year
Forecast seasonally adjusted data usingnon-seasonal time series method. E.g.,
Holt’s method — next topicRandom walk with drift model
Combine forecasts of seasonal component withforecasts of seasonally adjusted data to getforecasts of original data.
Sometimes a decomposition is useful just forunderstanding the data before building aseparate forecasting model.
Forecasting using R Forecasting and decomposition 46
Forecasting and decomposition
Forecast seasonal component by repeating thelast year
Forecast seasonally adjusted data usingnon-seasonal time series method. E.g.,
Holt’s method — next topicRandom walk with drift model
Combine forecasts of seasonal component withforecasts of seasonally adjusted data to getforecasts of original data.
Sometimes a decomposition is useful just forunderstanding the data before building aseparate forecasting model.
Forecasting using R Forecasting and decomposition 46
Forecasting and decomposition
Forecast seasonal component by repeating thelast year
Forecast seasonally adjusted data usingnon-seasonal time series method. E.g.,
Holt’s method — next topicRandom walk with drift model
Combine forecasts of seasonal component withforecasts of seasonally adjusted data to getforecasts of original data.
Sometimes a decomposition is useful just forunderstanding the data before building aseparate forecasting model.
Forecasting using R Forecasting and decomposition 46
Forecasting and decomposition
Forecast seasonal component by repeating thelast year
Forecast seasonally adjusted data usingnon-seasonal time series method. E.g.,
Holt’s method — next topicRandom walk with drift model
Combine forecasts of seasonal component withforecasts of seasonally adjusted data to getforecasts of original data.
Sometimes a decomposition is useful just forunderstanding the data before building aseparate forecasting model.
Forecasting using R Forecasting and decomposition 46
Seas adj elec equipment
Forecasting using R Forecasting and decomposition 47
Electrical equipment manufacturing
New
ord
ers
inde
x
2000 2005 2010
6070
8090
100
110
120
130
Seas adj elec equipment
Forecasting using R Forecasting and decomposition 48
Naive forecasts of seasonally adjusted data
New
ord
ers
inde
x
2000 2005 2010
7080
9010
011
012
0
Seas adj elec equipment
Forecasting using R Forecasting and decomposition 49
Forecasts from STL + Random walk
New
ord
ers
inde
x
2000 2005 2010
4060
8010
012
0
How to do this in R
fit <- stl(elecequip, t.window=15,s.window="periodic", robust=TRUE)
eeadj <- seasadj(fit)plot(naive(eeadj), xlab="New orders index")
fcast <- forecast(fit, method="naive")plot(fcast, ylab="New orders index")
Forecasting using R Forecasting and decomposition 50
Decomposition and prediction intervals
It is common to take the prediction
intervals from the seasonally adjusted
forecasts and modify them with the
seasonal component.
This ignores the uncertainty in the
seasonal component estimate.
It also ignores the uncertainty in the
future seasonal pattern.
Forecasting using R Forecasting and decomposition 51
Decomposition and prediction intervals
It is common to take the prediction
intervals from the seasonally adjusted
forecasts and modify them with the
seasonal component.
This ignores the uncertainty in the
seasonal component estimate.
It also ignores the uncertainty in the
future seasonal pattern.
Forecasting using R Forecasting and decomposition 51
Decomposition and prediction intervals
It is common to take the prediction
intervals from the seasonally adjusted
forecasts and modify them with the
seasonal component.
This ignores the uncertainty in the
seasonal component estimate.
It also ignores the uncertainty in the
future seasonal pattern.
Forecasting using R Forecasting and decomposition 51