Week 3: Time series decomposition

What you will learn this week

  • Transforming data to remove some sources of variation
  • Decomposing a time series into trend-cycle, seasonal and remainder components
  • Seasonal adjustment

Pre-class activities

Read Chapter 3 of the textbook and watch all embedded videos

Exercises (on your own or in tutorial)

Complete Exercises 6-11 from Section 2.10 of the book.

Solutions to Exercises

Slides for seminar

Download pdf

R code used in seminar

Seminar activities

  1. Produce an STL decomposition as follows

    us_construction <- us_employment |>
      filter(Title == "Construction", year(Month) > 1980)
    dcmp <- us_construction |>
      model(stl = STL(Employed ~ trend(window = 9) + season(window = 11)))
    dcmp |> components() |> autoplot()
  2. What happens as you change the values of the two window arguments?

  3. How does the seasonal shape change over time? [Hint: Try plotting the seasonal component using gg_season.]

  4. Can you produce a plausible seasonally adjusted series? [Hint: season_adjust is returned by components().]

Assignments