1. Learn
  2. /
  3. Courses
  4. /
  5. Quantitative Risk Management in Python

Exercise

Least-squares factor model

As you've seen, there is a negative correlation between minimum quarterly returns and mortgage delinquency rates from 2005 - 2010. This can be made more precise with an OLS regression factor model.

You'll compare three factor models with three different quarterly dependent variables: average returns, minimum returns, and average volatility. The independent variable is the mortgage delinquency rate. In the regression summary, examine the coefficients' t-statistic for statistical significance, as well as the overall R-squared for goodness of fit.

The statsmodels.api library is available as sm.

Instructions 1/3

undefined XP
  • 1
    • Regress average returns, port_q_mean, against delinquencies mort_del with statsmodels.api's .OLS() method.
  • 2
    • Next regress minimum returns, port_q_min, against mort_del with the .OLS() and .fit() methods.
  • 3
    • Finally, regress average volatility, vol_q_mean, against mort_del with the .OLS() and .fit() methods.