-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ada98a
commit e0f1a63
Showing
15 changed files
with
211 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"hash": "ee3371da1701f715a268398f50289e8b", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: ETC3550/ETC5550 Applied forecasting\nauthor: \"Week 4: The Forecasters' toolbox\"\nformat:\n beamer:\n aspectratio: 169\n fontsize: 14pt\n section-titles: false\n knitr:\n opts_chunk:\n dev: \"cairo_pdf\"\n pdf-engine: pdflatex\n fig-width: 7.5\n fig-height: 3.5\n include-in-header: ../header.tex\n---\n\n\n\n::: {.cell}\n\n:::\n\n\n\n## Time series cross-validation {-}\n\n**Traditional evaluation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n\\pause\n\n**Time series cross-validation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n## Time series cross-validation {-}\n\n**Traditional evaluation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n**Time series cross-validation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n## Time series cross-validation {-}\n\n**Traditional evaluation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n**Time series cross-validation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n## Time series cross-validation {-}\n\n**Traditional evaluation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n**Time series cross-validation**\n\n\n\n::: {.cell}\n::: {.cell-output-display}\n\n:::\n:::\n\n\n\n\\only<2>{\\begin{textblock}{8}(.5,6.4)\\begin{block}{}\\fontsize{12}{13}\\sf\n\\begin{itemize}\\tightlist\n\\item Forecast accuracy averaged over test sets.\n\\item Also known as \"evaluation on a rolling forecasting origin\"\n\\end{itemize}\\end{block}\\end{textblock}}\n\n\\vspace*{10cm}\n\n\n## Your turn\n\\fontsize{13}{14}\\sf\n\n\n\n\n1. Create a training set for household wealth (`hh_budget`) by withholding the last four years as a test set.\n2. Fit all the appropriate benchmark methods to the training set and forecast the periods covered by the test set.\n3. Compute the accuracy of your forecasts. Which method does best?\n", | ||
"supporting": [ | ||
"slides_files" | ||
], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": null, | ||
"postProcess": false | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
|
||
|
||
* Produce forecasts using an appropriate benchmark method for household wealth (`hh_budget`). Plot the results using `autoplot()`. | ||
* Produce forecasts using an appropriate benchmark method for Australian takeaway food turnover (`aus_retail`). Plot the results using `autoplot()`. | ||
|
||
* Compute seasonal naïve forecasts for quarterly Australian beer production from 1992. | ||
* Test if the residuals are white noise. What do you conclude? | ||
|
||
* Create a training set for household wealth (`hh_budget`) by withholding the last four years as a test set. | ||
* Fit all the appropriate benchmark methods to the training set and forecast the periods covered by the test set. | ||
* Compute the accuracy of your forecasts. Which method does best? | ||
* Repeat the exercise using the Australian takeaway food turnover data (`aus_retail`) with a test set of four years. | ||
1. Create a training set for household wealth (`hh_budget`) by withholding the last four years as a test set. | ||
2. Fit all the appropriate benchmark methods to the training set and forecast the periods covered by the test set. | ||
3. Compute the accuracy of your forecasts. Which method does best? | ||
4. Do the residuals from the best method resemble white noise? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
--- | ||
title: ETC3550/ETC5550 Applied forecasting | ||
author: "Week 4: The Forecasters' toolbox" | ||
format: | ||
beamer: | ||
aspectratio: 169 | ||
fontsize: 14pt | ||
section-titles: false | ||
knitr: | ||
opts_chunk: | ||
dev: "cairo_pdf" | ||
pdf-engine: pdflatex | ||
fig-width: 7.5 | ||
fig-height: 3.5 | ||
include-in-header: ../header.tex | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
source(here::here("setup.R")) | ||
``` | ||
```{r tscvplots, echo=FALSE} | ||
tscv_plot <- function(.init, .step, h = 1) { | ||
expand.grid( | ||
time = seq(26), | ||
.id = seq(trunc(11 / .step)) | ||
) |> | ||
group_by(.id) |> | ||
mutate( | ||
observation = case_when( | ||
time <= ((.id - 1) * .step + .init) ~ "train", | ||
time %in% c((.id - 1) * .step + .init + h) ~ "test", | ||
TRUE ~ "unused" | ||
) | ||
) |> | ||
ungroup() |> | ||
filter(.id <= 26 - .init) |> | ||
ggplot(aes(x = time, y = .id)) + | ||
geom_segment( | ||
aes(x = 0, xend = 27, y = .id, yend = .id), | ||
arrow = arrow(length = unit(0.015, "npc")), | ||
col = "black", size = .25 | ||
) + | ||
geom_point(aes(col = observation), size = 2) + | ||
scale_y_reverse() + | ||
scale_color_manual(values = c(train = "#0072B2", test = "#D55E00", unused = "gray")) + | ||
# theme_void() + | ||
# geom_label(aes(x = 28.5, y = 1, label = "time")) + | ||
guides(col = FALSE) + | ||
labs(x = "time", y = "") + | ||
theme_void() + | ||
theme(axis.title = element_text()) | ||
} | ||
``` | ||
|
||
## Time series cross-validation {-} | ||
|
||
**Traditional evaluation** | ||
|
||
```{r traintest1, fig.height=1, echo=FALSE} | ||
tscv_plot(.init = 18, .step = 10, h = 1:8) + | ||
geom_text(aes(x = 10, y = 0.8, label = "Training data"), color = "#0072B2") + | ||
geom_text(aes(x = 21, y = 0.8, label = "Test data"), color = "#D55E00") + | ||
ylim(1, 0) | ||
``` | ||
|
||
\pause | ||
|
||
**Time series cross-validation** | ||
|
||
```{r tscvggplot1, echo=FALSE, fig.height=2.2} | ||
tscv_plot(.init = 8, .step = 1, h = 1) + | ||
geom_text(aes(x = 21, y = 0, label = "h = 1"), color = "#D55E00") | ||
``` | ||
|
||
## Time series cross-validation {-} | ||
|
||
**Traditional evaluation** | ||
|
||
```{r traintest2, ref.label="traintest1", fig.height=1, echo=FALSE} | ||
``` | ||
|
||
**Time series cross-validation** | ||
|
||
```{r tscvggplot2, echo=FALSE, fig.height=2.2} | ||
tscv_plot(.init = 8, .step = 1, h = 2) + | ||
geom_text(aes(x = 21, y = 0, label = "h = 2"), color = "#D55E00") | ||
``` | ||
|
||
## Time series cross-validation {-} | ||
|
||
**Traditional evaluation** | ||
|
||
```{r traintest3, ref.label="traintest1", fig.height=1, echo=FALSE} | ||
``` | ||
|
||
**Time series cross-validation** | ||
|
||
```{r tscvggplot3, echo=FALSE, fig.height=2.2} | ||
tscv_plot(.init = 8, .step = 1, h = 3) + | ||
geom_text(aes(x = 21, y = 0, label = "h = 3"), color = "#D55E00") | ||
``` | ||
|
||
## Time series cross-validation {-} | ||
|
||
**Traditional evaluation** | ||
|
||
```{r traintest4, ref.label="traintest1", fig.height=1, echo=FALSE} | ||
``` | ||
|
||
**Time series cross-validation** | ||
|
||
```{r tscvggplot4, echo=FALSE, fig.height=2.2} | ||
tscv_plot(.init = 8, .step = 1, h = 4) + | ||
geom_text(aes(x = 21, y = 0, label = "h = 4"), color = "#D55E00") | ||
``` | ||
|
||
\only<2>{\begin{textblock}{8}(.5,6.4)\begin{block}{}\fontsize{12}{13}\sf | ||
\begin{itemize}\tightlist | ||
\item Forecast accuracy averaged over test sets. | ||
\item Also known as "evaluation on a rolling forecasting origin" | ||
\end{itemize}\end{block}\end{textblock}} | ||
|
||
\vspace*{10cm} | ||
|
||
|
||
## Your turn | ||
\fontsize{13}{14}\sf | ||
|
||
```{r} | ||
#| child: activities.md | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters