ACF plot
If a GARCH model is doing a good job, the standardized residuals should not exhibit autocorrelations. In this exercise, you will practice using an ACF plot to detect autocorrelations in the data.
The coefficient of correlation between two values in a time series is called the autocorrelation function (ACF), and an ACF plot is a visual representation of correlations between different lags. There are pre-defined functions in Python statsmodels
packages that enable you to generate ACF plots easily.
A GARCH model has been fitted with the S&P 500 return data, and its standardized residuals have been calculated and saved in std_resid
. The matplotlib.pyplot
has been imported as plt
.
This exercise is part of the course
GARCH Models in Python
Exercise instructions
- Import the module needed for ACF plots from the
statsmodels
package. - Plot the GARCH model standardized residuals saved in
std_resid
. - Generate an ACF plot of the standardized residuals, and set the confidence level to 0.05.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the Python module
from statsmodels.graphics.tsaplots import ____
# Plot the standardized residuals
plt.plot(____)
plt.title('Standardized Residuals')
plt.show()
# Generate ACF plot of the standardized residuals
____(std_resid, ____ = ____)
plt.show()