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.

TipHow to use this page
  1. Open week6-code.R beside this page.
  2. Work through the sections in order.
  3. Run the matching block in RStudio.
  4. 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.

TipSeminar step

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.

NoteWhat to notice
  • 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.

TipSeminar step

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)).

NoteWhat this code is doing
  • model() fits the three ETS variants to the same series.
  • glance() gives quick model-comparison metrics.
  • report() gives model details for the selected specification.
NoteWhat to notice
  • 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.

TipSeminar step

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.

NoteTry this

Change State == "Victoria" to State == "Queensland" and compare the outputs.

NoteWhat this code is doing
  • 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?”
NoteWhat to notice
  • 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.

TipSeminar step

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)
NoteWhat this code is doing
  • 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.
NoteWhat to notice
  • 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.

TipSeminar step

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)
NoteWhat this code is doing
  • Filters the PBS data down to the H02 series.
  • Aggregates total cost across each period.
  • Plots the finished series so you can read its features first.
NoteWhat to notice
  • 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.

TipSeminar step

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)
NoteTry this

Change trend("A") to trend("Ad"). Then change h = "8 years" to h = "20 years".

NoteWhat this code is doing
  • 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.
NoteWhat to notice
  • 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.

TipSeminar 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)
NoteTry this

Change STL(Cost) to STL(log(Cost) ~ season(window = "periodic")) and compare how that changes the decomposition story.

NoteWhat this code is doing
  • 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.
NoteWhat to notice
  • 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:

  1. Start with the series features before naming a model.
  2. Use glance(), report(), residual checks, and forecast shape together.
  3. 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.