Plot distribution of standardized residuals

GARCH models make distribution assumptions of the standardized residuals. Recall residuals are the differences between predicted returns and the mean returns. And standardized residuals are the residuals divided by the model estimated volatility.

In this exercise, you will practice computing the standardized residuals from a fitted GARCH model, and then plot its histogram together with a standard normal distribution normal_resid.

A GARCH model has been defined and fitted with S&P 500 price return data. The fitted result can be accessed as gm_result. In addition matplotlib has been preloaded as plt.

This is a part of the course

“GARCH Models in Python”

View Course

Exercise instructions

  • Obtain model estimated residuals and save it in gm_resid.
  • Obtain model estimated volatility and save it in gm_std.
  • Calculate the standardized residuals gm_std_resid.
  • Plot a histogram of gm_std_resid.

Hands-on interactive exercise

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

# Obtain model estimated residuals and volatility
gm_resid = gm_result.____
gm_std = gm_result.____

# Calculate the standardized residuals
gm_std_resid = ____ /____

# Plot the histogram of the standardized residuals
plt.____(____, bins = 50, 
         facecolor = 'orange', label = 'Standardized residuals')
plt.____(normal_resid, bins = 50, 
         facecolor = 'tomato', label = 'Normal residuals')
plt.legend(loc = 'upper left')
plt.show()