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
.
Diese Übung ist Teil des Kurses
GARCH Models in Python
Anleitung zur Übung
- 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
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# 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()