Vocabulary and Nomenclature Matching Activity (10 min)
TipCheck 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\).
A. \(n\)
2. Number of observations of a time series
B. \(k\)
3. Lead time
C. \(m_t\)
4. The trend as observed at time \(t\)
D. \(\hat m_t\)
5. The seasonal effect, as observed at time \(t\)
E. \(s_t\)
6. The error term (a sequence of correlated random variables with mean zero), as observed at time \(t\)
F. \(\hat s_t = x_t - \hat m_t\)
7. Centered moving average for observations made monthly
G. \(\hat s_t = \dfrac{x_t}{\hat m_t}\)
8. Estimate of monthly additive effect
H. \(\{x_t\}\)
9. Estimate of monthly multiplicative effect
I. \(z_t\)
10. Forecast made at time \(t\) for a future value \(k\) time units in the future
J. \(\bar s_t\)
11. Additive decomposition model
K. \(x_t = m_t + s_t + z_t\)
12. Additive decomposition model after taking the logarithm
L. \(x_t = m_t \cdot s_t + z_t\)
13. Multiplicative decomposition model
M. \(\log(x_t) = m_t + s_t + z_t\)
14. Seasonally adjusted mean for the month corresponding to time \(t\)
N. \(x_t - \bar s_t\)
15. Seasonal adjusted series (additive seasonal effect)
O. \(\frac{x_t}{\bar s_t}\)
16. Seasonal adjusted series (multiplicative seasonal effect)
P. \(\hat x_{t+k \mid t}\)
Team Activity: Moving Averages (45 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.
TipCheck 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?)
TipCheck 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?)
TipCheck Your Understanding
Note that neither of the two means above are appropriately located on an integer value of \(t\).
Give a 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, so it is centered on any given value of \(t\), not just \(t=7\).
TipCheck 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?
Application: Google Trends Searches for “Chocolate”
Recall the Google Trends data for the term “chocolate” given in the file chocolate.csv.
# read in the data from a csvchocolate_month <- rio::import("https://byuistats.github.io/timeseries/data/chocolate.csv") |># creating a date column mutate(dates =ym(Month))# create a tibble including variables dates, year, month, valuechocolate_tibble <- chocolate_month |>transmute( dates,year =year(dates), month =month(dates),value = chocolate )chocolate_month_ts <- chocolate_tibble |>mutate(index = tsibble::yearmonth(dates)) |>as_tsibble(index = index)
TipCheck Your Understanding
Using any tool (except R functions that automate the process) compute the centered moving average for the chocolate data. To help your check yourself, the value of \(\hat m\) in month 7 should be 35.6667.
Create a plot of your centered moving average. Here are some examples of ways you could display your centered moving average.
TipCheck Your Understanding
What does the centered moving average reveal about the chocolate search time series?
Suppose the chocolate data were reported daily. How would you compute the moving average? (Note: there are 365 days in a year.)
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))
TipCheck 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 (10 min)
TipCheck 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?
If you stored your centered moving average in a variable called “m_hat” in the “chocolate_month_ts” tsibble, you can generate the superimposed plot with the R command: