Skip to content

Commit

Permalink
Week 9 seminar updated
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Apr 29, 2024
1 parent 9d24ff7 commit 178045e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 54 deletions.
8 changes: 4 additions & 4 deletions week9/activities.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

For the Australian tourism data (from `tourism`):
For the Australian accommodation data (`aus_accommodation`)

* Fit a suitable ARIMA model for all data.
* Produce forecasts of your fitted models.
* Check the forecasts for the "Snowy Mountains" and "Melbourne" regions. Do they look reasonable?
* Fit a suitable ARIMA model to Occupancy for each states, using data from 2010.
* Produce 4-year forecasts of your fitted models.
* Check the forecasts for Victoria. Do they look reasonable?
11 changes: 10 additions & 1 deletion week9/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ Complete Exercises 6-10 from [Section 9.11 of the book](https://otexts.com/fpp3/
```{r}
#| output: asis
show_slides(week)
show_activity(week)
```

## Seminar activities

```{r}
#| child: activities.md
```

```{r}
#| output: asis
show_assignments(week)
```
3 changes: 2 additions & 1 deletion week9/seminar_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ leisure <- us_employment |>
) |>
mutate(Employed = Employed / 1000) |>
select(Month, Employed)
autoplot(leisure, Employed) +
leisure |>
autoplot(Employed) +
labs(
title = "US employment: leisure and hospitality",
y = "Number of people (millions)"
Expand Down
97 changes: 49 additions & 48 deletions week9/slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,6 @@ library(purrr)
```


## Point forecasts

1. Rearrange ARIMA equation so $y_t$ is on LHS.
2. Rewrite equation by replacing $t$ by $T+h$.
3. On RHS, replace future observations by their forecasts, future errors by zero, and past errors by corresponding residuals.

Start with $h=1$. Repeat for $h=2,3,\dots$.

## Prediction intervals
\vspace*{0.2cm}\fontsize{14}{15}\sf

\begin{block}{95\% prediction interval}
$$\hat{y}_{T+h|T} \pm 1.96\sqrt{v_{T+h|T}}$$
where $v_{T+h|T}$ is estimated forecast variance.
\end{block}\pause\vspace*{-0.3cm}

* $v_{T+1|T}=\hat{\sigma}^2$ for all ARIMA models regardless of parameters and orders.\pause
* Multi-step prediction intervals for ARIMA(0,0,$q$):
\centerline{$\displaystyle y_t = \varepsilon_t + \sum_{i=1}^q \theta_i \varepsilon_{t-i}.$}
\centerline{$\displaystyle
v_{T|T+h} = \hat{\sigma}^2 \left[ 1 + \sum_{i=1}^{h-1} \theta_i^2\right], \qquad\text{for~} h=2,3,\dots.$}

## Prediction intervals

* Prediction intervals **increase in size with forecast horizon**.
* Prediction intervals can be difficult to calculate by hand
* Calculations assume residuals are **uncorrelated** and **normally distributed**.
* Prediction intervals tend to be too narrow.
* the uncertainty in the parameter estimates has not been accounted for.
* the ARIMA model assumes historical patterns will not change during the forecast period.
* the ARIMA model assumes uncorrelated future \rlap{errors}


## Seasonal ARIMA models

| ARIMA | $~\underbrace{(p, d, q)}$ | $\underbrace{(P, D, Q)_{m}}$ |
Expand Down Expand Up @@ -136,6 +103,39 @@ the PACF and ACF.
* a single significant spike at lag 12 in the PACF.
## Point forecasts
1. Rearrange ARIMA equation so $y_t$ is on LHS.
2. Rewrite equation by replacing $t$ by $T+h$.
3. On RHS, replace future observations by their forecasts, future errors by zero, and past errors by corresponding residuals.
Start with $h=1$. Repeat for $h=2,3,\dots$.
## Prediction intervals
\fontsize{14}{15}\sf
\begin{block}{95\% prediction interval}
$$\hat{y}_{T+h|T} \pm 1.96\sqrt{v_{T+h|T}}$$
where $v_{T+h|T}$ is estimated forecast variance.
\end{block}\pause\vspace*{-0.3cm}

* $v_{T+1|T}=\hat{\sigma}^2$ for all ARIMA models regardless of parameters and orders.\pause
* Multi-step prediction intervals for ARIMA(0,0,$q$):
\centerline{$\displaystyle y_t = \varepsilon_t + \sum_{i=1}^q \theta_i \varepsilon_{t-i}.$}
\centerline{$\displaystyle
v_{T|T+h} = \hat{\sigma}^2 \left[ 1 + \sum_{i=1}^{h-1} \theta_i^2\right], \qquad\text{for~} h=2,3,\dots.$}

## Prediction intervals

* Prediction intervals **increase in size with forecast horizon**.
* Prediction intervals can be difficult to calculate by hand
* Calculations assume residuals are **uncorrelated** and **normally distributed**.
* Prediction intervals tend to be too narrow.
* the uncertainty in the parameter estimates has not been accounted for.
* the ARIMA model assumes historical patterns will not change during the forecast period.
* the ARIMA model assumes uncorrelated future \rlap{errors}


## ARIMA vs ETS
\fontsize{14}{16}\sf

Expand All @@ -151,7 +151,7 @@ the PACF and ACF.

```{r venn, echo=FALSE}
#| fig-height: 3
#| fig-width: 5
#| fig-width: 4.8
library(latex2exp)
cols <- c(ets = "#D55E00", arima = "#0072b2")
tibble(
Expand Down Expand Up @@ -179,17 +179,18 @@ tibble(
```

## Equivalences
\fontsize{13}{15}\sf
|**ETS model** | **ARIMA model** | **Parameters** |
| :------------ | :-------------------------- | :----------------------------------- |
| ETS(A,N,N) | ARIMA(0,1,1) | $\theta_1 = \alpha-1$ |
| ETS(A,A,N) | ARIMA(0,2,2) | $\theta_1 = \alpha+\beta-2$ |
| | | $\theta_2 = 1-\alpha$ |
| ETS(A,A\damped,N) | ARIMA(1,1,2) | $\phi_1=\phi$ |
| | | $\theta_1 = \alpha+\phi\beta-1-\phi$ |
| | | $\theta_2 = (1-\alpha)\phi$ |
| ETS(A,N,A) | ARIMA(0,0,$m$)(0,1,0)$_m$ | |
| ETS(A,A,A) | ARIMA(0,1,$m+1$)(0,1,0)$_m$ | |
| ETS(A,A\damped,A) | ARIMA(1,0,$m+1$)(0,1,0)$_m$ | |
\fontsize{14}{15}\sf

|**ETS model** | **ARIMA model** | **Parameters** |
| :------------ | :-------------------------- | :----------------------------------- |
| ETS(A,N,N) | ARIMA(0,1,1) | $\theta_1 = \alpha-1$ |
| ETS(A,A,N) | ARIMA(0,2,2) | $\theta_1 = \alpha+\beta-2$ |
| | | $\theta_2 = 1-\alpha$ |
| ETS(A,A\damped,N) | ARIMA(1,1,2) | $\phi_1=\phi$ |
| | | $\theta_1 = \alpha+\phi\beta-1-\phi$ |
| | | $\theta_2 = (1-\alpha)\phi$ |
| ETS(A,N,A) | ARIMA(0,0,$m$)(0,1,0)$_m$ | |
| ETS(A,A,A) | ARIMA(0,1,$m+1$)(0,1,0)$_m$ | |
| ETS(A,A\damped,A) | ARIMA(1,0,$m+1$)(0,1,0)$_m$ | |

: {tbl-colwidths="22,43,35"}

0 comments on commit 178045e

Please sign in to comment.