Get Started

The Fama French 3-factor model

The Fama-French model famously adds two additional factors to the CAPM model to describe asset returns:

$$ R_{P} = RF + \beta_{M}(R_{M}-RF)+b_{SMB} \cdot SMB + b_{HML} \cdot HML + \alpha $$

  • SMB: The small minus big factor
  • \(b_{SMB}\): Exposure to the SMB factor
  • HML: The high minus low factor
  • \(b_{HML}\): Exposure to the HML factor
  • \(\alpha \): Performance which is unexplained by any other factors
  • \(\beta_{M}\): Beta to the broad market portfolio B

The FamaFrenchData DataFrame is available in your workspace and contains the HML and SMB factors as columns for this exercise.

This is a part of the course

“Introduction to Portfolio Risk Management in Python”

View Course

Exercise instructions

  • Define a regression model that explains Portfolio_Excess as a function of Market_Excess, SMB, and HML.
  • Extract the adjusted r-squared value from FamaFrench_fit.

Hands-on interactive exercise

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

# Import statsmodels.formula.api
import statsmodels.formula.api as smf 

# Define the regression formula
FamaFrench_model = smf.ols(formula='____', data=FamaFrenchData)

# Fit the regression
FamaFrench_fit = FamaFrench_model.fit()

# Extract the adjusted r-squared
regression_adj_rsq = ____
print(regression_adj_rsq)

This exercise is part of the course

Introduction to Portfolio Risk Management in Python

IntermediateSkill Level
4.5+
11 reviews

Evaluate portfolio risk and returns, construct market-cap weighted equity portfolios and learn how to forecast and hedge market risk via scenario generation.

Learn about the main factors that influence the returns of your portfolios and how to quantify your portfolio's exposure to these factors.

Exercise 1: The Capital Asset Pricing modelExercise 2: Excess returnsExercise 3: Calculating beta using co-varianceExercise 4: Calculating beta with CAPMExercise 5: Adjusted R-squaredExercise 6: Alpha and multi-factor modelsExercise 7: The Fama French 3-factor model
Exercise 8: p-values and coefficientsExercise 9: Economic intuition in factor modelingExercise 10: The efficient market and alphaExercise 11: Expanding the 3-factor modelExercise 12: The 5-factor modelExercise 13: Alpha vs R-squared

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free