Get startedGet started for free

Autocorrelation of non-seasonal time series

Another way to look at time series data is to plot each observation against another observation that occurred some time previously by using gglagplot(). For example, you could plot \(y_t\) against \(y_{t-1}\). This is called a lag plot because you are plotting the time series against lags of itself.

The correlations associated with the lag plots form what is called the autocorrelation function (ACF). The ggAcf() function produces ACF plots.

In this exercise, you will work with the pre-loaded oil data (available in the package fpp2), which contains the annual oil production in Saudi Arabia from 1965-2013 (measured in millions of tons).

This exercise is part of the course

Forecasting in R

View Course

Exercise instructions

  • Use the autoplot() function to plot the oil data.
  • For the oil data, plot the relationship between \(y_t\) and \(y_{t-k}\), \(k=1,\dots,9\) using one of the two functions introduced above. Look at how the relationships change as the lag increases.
  • Likewise, plot the correlations associated with each of the lag plots using the other appropriate new function.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create an autoplot of the oil data
___

# Create a lag plot of the oil data
___

# Create an ACF plot of the oil data
___
Edit and Run Code