Averages for Time Series

Chapter 1: Lesson 3

Learning Outcomes

Decompose time series into trends, seasonal variation, and residuals
  • Define smoothing
  • Compute the centered moving average for a time series
  • Estimate the trend component using moving averages
Plot time series data to visualize trends, seasonal patterns, and potential outliers
  • Plot the estimated trend of a time series using a moving average
  • Make box plots to examine seasonality
  • Interpret the trend and seasonal pattern observed in a time series

Preparation

  • Read Sections 1.5.1-1.5.3

Learning Journal Exchange (10 min)

  • Review another student’s journal
  • What would you add to your learning journal after reading your partner’s?
  • What would you recommend your partner add to their learning journal?
  • Sign the Learning Journal review sheet for your peer

Vocabulary and Nomenclature Matching Activity (10 min)

Check Your Understanding

Working with a partner, match the definitions on the left with the terms on the right.

Nomenclature Matching

  1. Discrete observations of a time series, taken at times \(1, 2, \ldots, n\).
  2. Number of observations of a time series
  3. Lead time
  4. The trend as observed at time \(t\)
  5. The seasonal effect, as observed at time \(t\)
  6. The error term (a sequence of correlated random variables with mean zero), as observed at time \(t\)
  7. Centered moving average for obsrvations made monthly
  8. Estimate of monthly additive effect
  9. Estimate of monthly multiplicative effect
  1. \(n\)
  2. \(k\)
  3. \(m_t\)
  4. \(\hat m_t\)
  5. \(s_t\)
  6. \(\hat s_t = x_t - \hat m_t ~~~~~~~~~~~~~~~~~~~~~~~~~\)
  7. \(\hat s_t = \dfrac{x_t}{\hat m_t}\)
  8. \(\{x_t\}\)
  9. \(z_t\)

where \(\hat m_t = \dfrac{\frac{1}{2}x_{t-6} + x_{t-5} + \cdots + x_{t-1} + x_t + x_{t+1} + \cdot + x_{t+5} + \frac{1}{2} x_{t+6}}{12}\).

Additional Nomenclature Matching

  1. Forecast made at time \(t\) for a future value \(k\) time units in the future \(~~~~~~~~~~~~~~~~~~~~~~\)
  2. Additive decomposition model
  3. Additive decomposition model after taking the logarithm
  4. Multiplicative decomposition model
  5. Seasonally adjusted mean for the month corresponding to time \(t\)
  6. Seasonal adjusted series (additive seasonal effect)
  7. Seasonal adjusted series (multiplicative seasonal effect)
  1. \(\bar s_t\)
  2. \(x_t = m_t + s_t + z_t\)
  3. \(x_t = m_t \cdot s_t + z_t\)
  4. \(\log(x_t) = m_t + s_t + z_t\)
  5. \(x_t - \bar s_t\)
  6. \(\frac{x_t}{\bar s_t}\)
  7. \(\hat x_{t+k \mid t}\)

Team Activity: Moving Averages (30 min)

Derivation

Data representing some value have been collected each month for a few years. This plot represents the first 12 observations in this time series.

Check Your Understanding
  • Suppose you wanted to compute the mean of the observations from the first year (\(t = 1\) to \(t=12\).) What is the formula you would use to compute this mean? Write this expression without a summation symbol.
  • To what value of \(t\) should this mean be assigned? (If you were to plot this mean on a time plot, where should it go?)

Check Your Understanding
  • Suppose you want to compute the mean of one year’s worth of observations, beginning at month \(t=2\). Write the formula you would use to compute this mean without using a summation symbol.
  • To what value of \(t\) should this mean be assigned? (If you were to plot this mean on a time plot, where should it go?)

Check Your Understanding
  • Note that neither of the two means above are appropriately located on an integer value of \(t\).
  • Give the formula that combines the two means above to give one mean that is centered on an integer value of \(t\). Do not include a summation symbol in your formula. (Hint: try averaging the two means.)
  • Upon what value of \(t\) is your new mean centered?

We will now adjust this moving average adjusted so it is centered on any given value of \(t\), not just \(t=7\).

Check Your Understanding
  • Consider the values \(x_{t-6}\), \(x_{t-5}\), \(x_{t-4}\), \(x_{t-3}\), \(x_{t-2}\), \(x_{t-1}\), \(x_{t}\), \(x_{t+1}\), \(x_{t+2}\), \(x_{t+3}\), \(x_{t+4}\), and \(x_{t+5}\).
    • Give an expression for the mean of the values.
    • Where will this mean be centered?
  • Consider the values \(x_{t-5}\), \(x_{t-4}\), \(x_{t-3}\), \(x_{t-2}\), \(x_{t-1}\), \(x_{t}\), \(x_{t+1}\), \(x_{t+2}\), \(x_{t+3}\), \(x_{t+4}\), \(x_{t+5}\), and \(x_{t+6}\).
    • Give an expression for the mean of the values.
    • Where will this mean be centered?
  • We now combine these two means by averaging them.
    • Give an expression for the mean of these two means.
    • Where will this combined mean be centered?

Estimating the Seasonal Effect: Side-by-Side Box Plots by Month (10 min)

To better visualize the effect of seasonal variation, we can make box plots by month.

ggplot(chocolate_month_ts, aes(x = factor(month), y = value)) +
    geom_boxplot() +
  labs(
    x = "Month Number",
    y = "Searches",
    title = "Boxplots of Google Searches for 'Chocolate' by Month"
  ) +
  theme(plot.title = element_text(hjust = 0.5))

Check Your Understanding
  • What do you observe?
  • Which months tend to have the most searches? Which months tend to have the fewest seraches?
    • Can you provide an explanation for this?

Summary

Check Your Understanding
  • What does the centered moving average tell us?
  • Why is a centered moving average helpful when there are seasonal effects?
  • For the chocolate search data, answer the following questions:
    • How many values of \(t\) were not assigned a value of the centered moving average?
    • Interpret that number in years.
    • Does this number depend on the length of the time series?

Homework Preview (5 min)

  • Review upcoming homework assignment
  • Clarify questions

Homework

Download Assignment

Matching

Team Activity