ComenzarEmpieza gratis

Autocorrelation

Another important piece of information is the relationship between one point in the time series and points that come before it. This is called autocorrelation and it can be displayed as a chart which indicates the correlation between points separated by various time lags.

In R, you can plot the autocorrelation function using acf(), which by default, displays the first 30 lags (i.e. the correlation between points n and n - 1, n and n - 2, n and n - 3 and so on up to 30). The autocorrelogram, or the autocorrelation chart, tells you how any point in the time series is related to its past as well as how significant this relationship is. The significance levels are given by 2 horizontal lines above and below 0.

You saw in the video that using this function is fairly straightforward:

> acf(amazon_stocks,
      main = "AMAZON return autocorrelations")

In this exercise, you will create an autocorrelation plot of the Apple stock price return data in rtn.

Este ejercicio forma parte del curso

Visualizing Time Series Data in R

Ver curso

Instrucciones del ejercicio

  • Draw an autocorrelation plot of rtn and title it "Apple return autocorrelation"
  • Redraw the plot and change the maximum lag to 10 by adding lag.max = 10

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Draw autocorrelation plot


# Redraw with a maximum lag of 10
Editar y ejecutar código