The autocorrelation function
Autocorrelations can be estimated at many lags to better assess how a time series relates to its past. We are typically most interested in how a series relates to its most recent past.
The acf(..., lag.max = ..., plot = FALSE) function will estimate all autocorrelations from 0, 1, 2,…, up to the value specified by the argument lag.max. In the previous exercise, you focused on the lag-1 autocorrelation by setting the lag.max argument to 1.
In this exercise, you'll explore some further applications of the acf() command. Once again, the time series x has been preloaded for you and is shown in the plot on the right.
This exercise is part of the course
Time Series Analysis in R
Exercise instructions
- Use
acf()to view the autocorrelations of seriesxfrom 0 to 10. Set thelag.maxargument to10and keep theplotargument asFALSE. - Run the
acf()code, and copy and paste the autocorrelation estimate (ACF) at lag-10 from the output. - Repeat this for the autocorrelation estimate (ACF) at lag-5.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Generate ACF estimates for x up to lag-10
acf(___, lag.max = ___, plot = FALSE)
# Type the ACF estimate at lag-10
# Type the ACF estimate at lag-5