ComeçarComece de graça

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!

Este exercício faz parte do curso

Introduction to Portfolio Analysis in Python

Ver curso

Instruções do exercício

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

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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' %  (____, ____, ____))
Editar e executar o código