-
Notifications
You must be signed in to change notification settings - Fork 167
/
8-ets_b.qmd
264 lines (213 loc) · 10.1 KB
/
8-ets_b.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
---
title: "ETC3550/ETC5550 Applied forecasting"
author: "Ch8. Exponential smoothing"
institute: "OTexts.org/fpp3/"
pdf-engine: pdflatex
fig-width: 7.5
fig-height: 3
format:
beamer:
theme: monash
aspectratio: 169
fontsize: 14pt
section-titles: false
knitr:
opts_chunk:
dev: "cairo_pdf"
include-in-header: header.tex
execute:
echo: false
message: false
warning: false
---
```{r setup, include=FALSE}
source("setup.R")
library(patchwork)
library(gganimate)
library(purrr)
library(rlang)
library(magick)
```
## ETS models
\begin{block}{}
\hspace*{-0.25cm}\begin{tabular}{l@{}p{2.3cm}@{}c@{}l}
\alert{General n\rlap{otation}}
& & ~E T S~ & ~:\hspace*{0.3cm}\textbf{E}xponen\textbf{T}ial \textbf{S}moothing \\ [-0.2cm]
& \hfill{$\nearrow$\hspace*{-0.1cm}} & {$\uparrow$} & {\hspace*{-0.2cm}$\nwarrow$} \\
& \hfill{\textbf{E}rror\hspace*{0.2cm}} & {\textbf{T}rend} & {\hspace*{0.2cm}\textbf{S}eason}
\end{tabular}
\end{block}
\alert{\textbf{E}rror:} Additive (`"A"`) or multiplicative (`"M"`)
\pause
\alert{\textbf{T}rend:} None (`"N"`), additive (`"A"`), multiplicative (`"M"`), or damped (`"Ad"` or `"Md"`).
\pause
\alert{\textbf{S}easonality:} None (`"N"`), additive (`"A"`) or multiplicative (`"M"`)
## ETS(A,N,N): SES with additive errors
\fontsize{14}{16}\sf\vspace*{0.2cm}
\begin{block}{ETS(A,N,N) model}\vspace*{-0.8cm}
\begin{align*}
\text{Observation equation}&& y_t &= \ell_{t-1} + \varepsilon_t\\
\text{State equation}&& \ell_t&=\ell_{t-1}+\alpha \varepsilon_t
\end{align*}
\end{block}
where $\varepsilon_t\sim\text{NID}(0,\sigma^2)$.
* "innovations" or "single source of error" because equations have the same error process, $\varepsilon_t$.
* Measurement equation: relationship between observations and states.
* State equation(s): evolution of the state(s) through time.
## ETS(A,A,N)
Holt's methods method with additive errors.\phantom{p}
\begin{block}{}\vspace*{-0.8cm}
\begin{align*}
\text{Forecast equation} && \hat{y}_{t+h|t} &= \ell_{t} + hb_{t}\\
\text{Observation equation}&& y_t&=\ell_{t-1}+b_{t-1} + \varepsilon_t\\
\text{State equations}&& \ell_t&=\ell_{t-1}+b_{t-1}+\alpha \varepsilon_t\\
&& b_t&=b_{t-1}+\beta \varepsilon_t
\end{align*}
\end{block}
* Forecast errors: $\varepsilon_{t} = y_t - \hat{y}_{t|t-1}$
\vspace*{10cm}
## ETS(A,A,A)
Holt-Winters additive method with additive errors.\phantom{p}
\begin{block}{}\vspace*{-0.8cm}
\begin{align*}
\text{Forecast equation} && \hat{y}_{t+h|t} &= \ell_{t} + hb_{t} + s_{t+h-m(k+1)}\\
\text{Observation equation}&& y_t&=\ell_{t-1}+b_{t-1}+s_{t-m} + \varepsilon_t\\
\text{State equations}&& \ell_t&=\ell_{t-1}+b_{t-1}+\alpha \varepsilon_t\\
&& b_t&=b_{t-1}+\beta \varepsilon_t \\
&&s_t &= s_{t-m} + \gamma\varepsilon_t
\end{align*}
\end{block}
* Forecast errors: $\varepsilon_{t} = y_t - \hat{y}_{t|t-1}$
* $k$ is integer part of $(h-1)/m$.
## ETS(M,A,M)
Holt-Winters multiplicative method with multiplicative errors.
\begin{block}{}\vspace*{-0.8cm}
\begin{align*}
\text{Forecast equation} && \hat{y}_{t+h|t} &= (\ell_{t} + hb_{t}) s_{t+h-m(k+1)}\\
\text{Observation equation}&& y_t&= (\ell_{t-1}+b_{t-1})s_{t-m}(1 + \varepsilon_t)\\
\text{State equations}&& \ell_t&=(\ell_{t-1}+b_{t-1})(1+\alpha \varepsilon_t)\\
&& b_t&=b_{t-1} +\beta(\ell_{t-1}+b_{t-1}) \varepsilon_t \\
&&s_t &= s_{t-m}(1 + \gamma\varepsilon_t)
\end{align*}
\end{block}
* Forecast errors: $\varepsilon_{t} = (y_t - \hat{y}_{t|t-1})/\hat{y}_{t|t-1}$
* $k$ is integer part of $(h-1)/m$.
## ETS model specification
```{r ann-spec, echo = TRUE, eval=FALSE}
ETS(y ~ error("A") + trend("N") + season("N"))
```
By default, optimal values for $\alpha$, $\beta$, $\gamma$, and the states at time 0 are used.
The values for $\alpha$, $\beta$ and $\gamma$ can be specified:
```{r alpha-spec, echo = TRUE, eval = FALSE}
trend("A", alpha = 0.5, beta = 0.2)
trend("A", alpha_range = c(0.2, 0.8), beta_range = c(0.1, 0.4))
season("M", gamma = 0.04)
season("M", gamma_range = c(0, 0.3))
```
## Exponential smoothing methods
\fontsize{12}{13}\sf
\begin{block}{}
\begin{tabular}{ll|ccc}
& &\multicolumn{3}{c}{\bf Seasonal Component} \\
\multicolumn{2}{c|}{\bf Trend}& N & A & M\\
\multicolumn{2}{c|}{\bf Component} & (None) & (Additive) & (Multiplicative)\\
\cline{3-5} &&&&\\[-0.4cm]
N & (None) & (N,N) & (N,A) & (N,M)\\
&&&&\\[-0.4cm]
A & (Additive) & (A,N) & (A,A) & (A,M)\\
&&&&\\[-0.4cm]
A\damped & (Additive damped) & (A\damped,N) & (A\damped,A) & (A\damped,M)
\end{tabular}
\end{block}\fontsize{12}{13}\sf
\begin{tabular}{lp{9.7cm}}
\alert{(N,N)}: & Simple exponential smoothing\\
\alert{(A,N)}: & Holt's linear method\\
\alert{(A\damped,N)}: & Additive damped trend method\\
\alert{(A,A)}:~~ & Additive Holt-Winters' method\\
\alert{(A,M)}: & Multiplicative Holt-Winters' method\\
\alert{(A\damped,M)}: & Damped multiplicative Holt-Winters' method
\end{tabular}
\only<2>{\begin{textblock}{5}(10,6)
\begin{alertblock}{}\fontsize{12}{14}\sf
There are also multiplicative trend methods (not recommended).
\end{alertblock}
\end{textblock}}
## ETS models
\fontsize{11}{12}\sf
\begin{block}{}
\begin{tabular}{ll|ccc}
\multicolumn{2}{l}{\alert{\bf Additive Error}} & \multicolumn{3}{c}{\bf Seasonal Component} \\
\multicolumn{2}{c|}{\bf Trend} & N & A & M \\
\multicolumn{2}{c|}{\bf Component} & ~(None)~ & (Additive) & (Multiplicative) \\ \cline{3-5}
& & & & \\[-0.4cm]
N & (None) & A,N,N & A,N,A & A,N,M \\
& & & & \\[-0.4cm]
A & (Additive) & A,A,N & A,A,A & A,A,M \\
& & & & \\[-0.4cm]
A\damped & (Additive damped) & A,A\damped,N & A,A\damped,A & A,A\damped,M
\end{tabular}
\end{block}
\begin{block}{}
\begin{tabular}{ll|ccc}
\multicolumn{2}{l}{\alert{\bf Multiplicative Error}} & \multicolumn{3}{c}{\bf Seasonal Component} \\
\multicolumn{2}{c|}{\bf Trend} & N & A & M \\
\multicolumn{2}{c|}{\bf Component} & ~(None)~ & (Additive) & (Multiplicative) \\ \cline{3-5}
& & & & \\[-0.4cm]
N & (None) & M,N,N & M,N,A & M,N,M \\
& & & & \\[-0.4cm]
A & (Additive) & M,A,N & M,A,A & M,A,M \\
& & & & \\[-0.4cm]
A\damped & (Additive damped) & M,A\damped,N & M,A\damped,A & M,A\damped,M
\end{tabular}
\end{block}
## ETS models
\fontsize{11}{12}\sf
\begin{block}{}
\begin{tabular}{ll|ccc}
\multicolumn{2}{l}{\alert{\bf Additive Error}} & \multicolumn{3}{c}{\bf Seasonal Component} \\
\multicolumn{2}{c|}{\bf Trend} & N & A & M \\
\multicolumn{2}{c|}{\bf Component} & ~(None)~ & (Additive) & (Multiplicative) \\ \cline{3-5}
& & & & \\[-0.4cm]
N & (None) & A,N,N & A,N,A & \str{A,N,M} \\
& & & & \\[-0.4cm]
A & (Additive) & A,A,N & A,A,A & \str{A,A,M} \\
& & & & \\[-0.4cm]
A\damped & (Additive damped) & A,A\damped,N & A,A\damped,A & \str{A,A\damped,M}
\end{tabular}
\end{block}
\begin{block}{}
\begin{tabular}{ll|ccc}
\multicolumn{2}{l}{\alert{\bf Multiplicative Error}} & \multicolumn{3}{c}{\bf Seasonal Component} \\
\multicolumn{2}{c|}{\bf Trend} & N & A & M \\
\multicolumn{2}{c|}{\bf Component} & ~(None)~ & (Additive) & (Multiplicative) \\ \cline{3-5}
& & & & \\[-0.4cm]
N & (None) & M,N,N & M,N,A & M,N,M \\
& & & & \\[-0.4cm]
A & (Additive) & M,A,N & M,A,A & M,A,M \\
& & & & \\[-0.4cm]
A\damped & (Additive damped) & M,A\damped,N & M,A\damped,A & M,A\damped,M
\end{tabular}
\end{block}
## AIC and cross-validation
\Large
\begin{alertblock}{}
Minimizing the AIC assuming Gaussian residuals is asymptotically equivalent to minimizing one-step time series cross validation MSE.
\end{alertblock}
## Automatic forecasting
**From Hyndman et al.\ (IJF, 2002):**
* Apply each model that is appropriate to the data.
Optimize parameters and initial values using MLE (or some other
criterion).
* Select best method using AICc:
* Produce forecasts using best method.
* Obtain forecast intervals using underlying state space model.
Method performed very well in M3 competition.
## Residuals
\vspace*{0.2cm}
### Response residuals
\centerline{$\hat{e}_t = y_t - \hat{y}_{t|t-1}$}
### Innovation residuals
Additive error model:
\centerline{$\hat\varepsilon_t = y_t - \hat{y}_{t|t-1}$}
Multiplicative error model:
\centerline{$\hat\varepsilon_t = \frac{y_t - \hat{y}_{t|t-1}}{\hat{y}_{t|t-1}}$}