Aan de slagGa gratis aan de slag

Getting "Warmed" Up: Look at Autocorrelations

Since the temperature series, temp_NY, is a random walk with drift, take first differences to make it stationary. Then compute the sample ACF and PACF. This will provide some guidance on the order of the model.

Deze oefening maakt deel uit van de cursus

Time Series Analysis in Python

Cursus bekijken

Oefeninstructies

  • Import the modules for plotting the sample ACF and PACF
  • Take first differences of the DataFrame temp_NY using the pandas method .diff()
  • Create two subplots for plotting the ACF and PACF
    • Plot the sample ACF of the differenced series
    • Plot the sample PACF of the differenced series

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import the modules for plotting the sample ACF and PACF
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf

# Take first difference of the temperature Series
chg_temp = ___.___
chg_temp = chg_temp.dropna()

# Plot the ACF and PACF on the same page
fig, axes = plt.subplots(2,1)

# Plot the ACF
plot_acf(___, lags=20, ax=axes[0])

# Plot the PACF
plot_pacf(___, lags=20, ax=axes[1])
plt.show()
Code bewerken en uitvoeren