Autocorrelation is a major part of the study of time series. It allows us to understand how each observation is linked to its recent past observations in a time series. When autocorrelation in a time series is strong, predicting their future observations becomes easy.
We can also calculate the
correlation between the actual series and the lagged series using
the cor()
function in R.
ACF Function
Instead of calculating the
correlation with each time lag manually, we can use the
acf()
function in R. The function acf computes (and by
default plots) estimates of the autocovariance or autocorrelation
function for different time lags.
Below we get the autocorrelations for lag 1 to 10. Notice that the correlation keeps reducing as the lag increases.
syntax
acf(dataframe, lag.max=10, plot=FALSE)
Get Answers For Free
Most questions answered within 1 hours.