Get startedGet started for free

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!

This exercise is part of the course

Introduction to Portfolio Analysis in Python

View Course

Exercise instructions

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

Hands-on interactive exercise

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

# 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' %  (____, ____, ____))
Edit and Run Code