Autocorrelation of seasonal and cyclic time series
When data are either seasonal or cyclic, the ACF will peak around the seasonal lags or at the average cycle length.
You will investigate this phenomenon by plotting the annual sunspot series (which follows the solar cycle of approximately 10-11 years) in sunspot.year
and the daily traffic to the Hyndsight blog (which follows a 7-day weekly pattern) in hyndsight
. Both objects have been loaded into your workspace.
This exercise is part of the course
Forecasting in R
Exercise instructions
- Produce a time plot and ACF plot of
sunspot.year
. - By observing the ACF plot, at which lag value (x) can you find the maximum autocorrelation (y)? Set this equal to
maxlag_sunspot
. - Produce a time plot and ACF plot of
hyndsight
. - By observing the ACF plot, at which lag value (x) can you find the maximum autocorrelation (y)? Set this equal to
maxlag_hyndsight
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot the annual sunspot numbers
autoplot(___)
ggAcf(___)
# Save the lag corresponding to maximum autocorrelation
maxlag_sunspot <- ___
# Plot the traffic on the Hyndsight blog
___
___
# Save the lag corresponding to maximum autocorrelation
maxlag_hyndsight <- ___