Aan de slagGa gratis aan de slag

Fama French Factor model

In this exercise, you are going focus on efficiently obtaining just the beta coefficients of the Fama French model. As you've seen in the video, those betas indicate how much of the portfolio's return changes if that particular factor's return changes.

Sometimes, all you want to do is to check whether the factor relates negatively, or positively to you portfolio returns. You can see this directly from the signs of the coefficients. Available again is the factor_returns data for you. Let's try!

Deze oefening maakt deel uit van de cursus

Introduction to Portfolio Analysis in Python

Cursus bekijken

Oefeninstructies

  • Import the statsmodels package as sm.
  • Fit the linear model to the portfolio returns and Fama French factors, and obtain only the three beta coefficients by extracting the parameters.
  • Print the three betas.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import statsmodels
import ____.____ as ____

# Obtain the beta coefficients
b1, b2, b3 = ____.____(____['____'], factor_returns[['Mkt-RF','SMB', 'HML']]).____().____

# Print the betas
print ('Sensitivities of active returns to factors:\nMkt-Rf: %f\nSMB: %f\nHML: %f' %  (____, ____, ____))
Code bewerken en uitvoeren