Workshop Activities: Week 6
Week 6 Mini-Studio
This page follows the same sequence as week6-code.R. It is designed as a stable seminar companion: read the code, run the matching block in R or RStudio, then answer the short prompts here in words. That keeps the focus on the class code, which is the style you are most likely to meet in the exam.
- Open week6-code.R beside this page.
- Work through the sections in order.
- Run the matching block in RStudio.
- Use the prompts here to practise explanation and model choice, not just syntax.
A. Build the holidays series
This opening block creates the tourism series used in the first half of the seminar.
Build the holidays series exactly as it appears in class, then plot it before fitting any models.
holidays <- tourism |>
filter(State %in% c("Victoria", "Queensland")) |>
filter(Purpose == "Holiday") |>
as_tibble() |>
summarise(Trips = sum(Trips), .by = c("State", "Quarter")) |>
as_tsibble(index = Quarter, key = State)
holidays |>
autoplot()A time series plot showing holiday trips for Victoria and Queensland over quarters, with clear seasonal patterns and potential multiplicative seasonality in Victoria.
- Compare the overall level of Victoria and Queensland.
- Look at whether the seasonal swings stay roughly constant or get larger when the series level gets larger.
- Keep that visual impression in mind before fitting any ETS models.
B. Fit competing ETS models
This is the core model comparison block from the seminar. The point is not just to run ETS(), but to compare several reasonable choices.
Fit additive, multiplicative, and automatic ETS models to the same series so you can compare them properly.
fit <- holidays |>
model(
additive = ETS(Trips ~ error("A")),
multiplicative = ETS(Trips ~ error("M")),
auto = ETS(Trips)
)
fit
fit |>
glance()fit |>
filter(State == "Victoria") |>
select(multiplicative) |>
report()Model table showing fitted ETS models, glance() with AIC/BIC, and report() detailing the multiplicative model structure for Victoria (likely ETS(M,N,M)).
model()fits the three ETS variants to the same series.glance()gives quick model-comparison metrics.report()gives model details for the selected specification.
- Do not treat
glance()as the whole answer. - Use
report()to see what the model is actually doing. - Link the model output back to the visual pattern you saw in the time plot.
C. Check components and residuals
Good model choice is not just about a criterion value. You also need to inspect what the fitted model is doing and whether the residuals look reasonable.
Inspect the fitted structure for Victoria, then check whether the residuals still show obvious leftover pattern.
fit |>
filter(State == "Victoria") |>
select(multiplicative) |>
components() |>
autoplot()fit |>
filter(State == "Victoria") |>
select(multiplicative) |>
gg_tsresiduals()Components plot showing level, trend, and seasonal patterns; residuals plot with ACF/PACF and histogram showing approximate white noise.
Change State == "Victoria" to State == "Queensland" and compare the outputs.
components()shows the fitted level, trend, and seasonality.gg_tsresiduals()checks whether residuals are roughly well-behaved.- Together they move you from “the software picked this” to “does this model make sense?”
- In the components plot, ask what trend and seasonal pattern the model is trying to capture.
- In the residual diagnostics, ask whether there is still obvious structure left behind.
- You do not need perfect residuals to say something useful, but you should be able to explain whether the model seems adequate.
D. Forecast and defend the model choice
This section turns model choice into forecast interpretation, which is much closer to exam reasoning than simply listing the chosen ETS form.
Generate forecasts from the fitted models, then compare the forecast shape for additive and multiplicative choices.
fc <- fit |>
forecast()
fc |>
autoplot(holidays) +
labs(title = "Overnight trips (thousands)")fc |>
filter(State == "Victoria", !.model == "auto") |>
autoplot(holidays) +
labs(title = "Victoria: Overnight trips (thousands)") +
facet_wrap(vars(.model), ncol = 1)forecast()generates future values from each fitted model.- The first plot shows all states together.
- The second plot isolates Victoria so the additive and multiplicative forecasts are easier to compare.
- Compare the shape of the forecasts, not just the labels.
- Ask whether the amplitude of the seasonal pattern scales with the level.
- That scaling idea is the main reason multiplicative seasonality becomes attractive here.
E. Build and inspect h02
The seminar then switches to the PBS example. This is a fresh model-choice problem, so start again from the series features.
Create h02, plot it, and describe the main features before asking the software to choose a model.
h02 <- PBS |>
filter(ATC2 == "H02") |>
summarise(Cost = sum(Cost))
h02 |>
autoplot(Cost)- Filters the
PBSdata down to theH02series. - Aggregates total cost across each period.
- Plots the finished series so you can read its features first.
- Look for trend.
- Look for seasonality.
- Look for whether the variation changes with the level.
- Try to predict the sort of ETS structure you expect before asking the software.
F. Auto ETS and damped trend
Now compare what automatic ETS suggests with a more deliberate trend choice.
Use automatic ETS to inspect the suggested model, then compare a plain additive trend forecast with a damped version.
h02 |>
model(ETS(Cost)) |>
report()h02 |>
model(ETS(Cost ~ trend("A"))) |>
forecast(h = "8 years") |>
autoplot(h02)Change trend("A") to trend("Ad"). Then change h = "8 years" to h = "20 years".
ETS(Cost)lets the model choose a suitable structure automatically.trend("A")forces a plain additive trend so you can compare the forecast behaviour.- Changing to
trend("Ad")lets you see what damping does, especially over longer horizons.
- A damped trend matters most when the forecast horizon gets longer.
- The question is not whether the trend exists, but whether it should continue indefinitely at the same rate.
- That is an interpretation question, not just a software question.
G. STL plus ETS
The last block combines decomposition and forecasting. This is useful when you want to separate pattern description from the final forecasting step.
Decompose h02 first, then fit a forecasting model to the seasonally adjusted series.
h02 |>
model(STL(Cost)) |>
components() |>
autoplot()stl_fit <- h02 |>
model(
decomposition_model(
STL(Cost),
ETS(season_adjust),
SNAIVE(season_year)
)
)
stl_fit |>
report()
stl_fit |>
forecast(h = "20 years") |>
autoplot(h02)Change STL(Cost) to STL(log(Cost) ~ season(window = "periodic")) and compare how that changes the decomposition story.
STL()decomposes the series into trend, seasonality, and remainder.decomposition_model()then forecasts the seasonally adjusted part and the seasonal part separately.- This gives you a different workflow from fitting one ETS model directly to the original series.
- STL helps you think separately about trend, seasonality, and remainder.
- After decomposition, you still have to justify the final forecasting choice.
- The aim is not “use STL because it is fancy”; the aim is to explain when decomposition gives a more sensible forecasting workflow.
Final Week 6 check
If you revise only three things from Week 6, make them these:
- Start with the series features before naming a model.
- Use
glance(),report(), residual checks, and forecast shape together. - Explain why a model is sensible in words, not just by quoting the chosen ETS form.
For the full seminar workflow, keep week6-code.R open while you work through this page. For additional worked material, you can also compare with Week 6 Tutorial Solution.html.