Kom igångKom igång gratis

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.

Den här övningen är en del av kursen

Time Series Analysis in Python

Visa kurs

Övningsinstruktioner

  • 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

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

# 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()
Redigera och kör kod