Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

GARCH Models in Python

Cursus bekijken

Oefeninstructies

  • 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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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()
Code bewerken en uitvoeren