Factor Models
A factor model explains the returns of an asset with its exposures to a few common sources of return, the factors, plus a part specific to the asset. The exposures, or factor loadings, are the slopes of a regression of the excess return of the asset on the returns of the factors. They show what drives an investment: whether a fund beats the market through skill or because it holds small or cheap stocks that have earned more on average.
The Capital Asset Pricing Model of Sharpe (1964) is the model with one factor, the excess return of the market, whose loading is the Beta. Ross (1976) gave the arbitrage pricing theory, in which several factors can be priced. Fama and French (1993) added a size factor, small minus big (SMB), and a value factor, high minus low book-to-market (HML), Carhart (1997) a momentum factor, and Fama and French (2015) a profitability factor, robust minus weak (RMW), and an investment factor, conservative minus aggressive (CMA).
The formula for the five factor model of Fama and French is as follows:
\[\text{Excess Return} = \text{Alpha} + \text{Beta}_{1} \cdot (\text{Mkt} - \text{RF}) + \text{Beta}_{2} \cdot \text{SMB} + \text{Beta}_{3} \cdot \text{HML} + \text{Beta}_{4} \cdot \text{RMW} + \text{Beta}_{5} \cdot \text{CMA} + \text{Residual}\]Where the excess return is the return of the asset minus the risk-free rate, Mkt - RF the excess return of the market and the other terms the returns of the long-short factor portfolios. The alpha is the return the factors do not explain and the R-squared the share of the variance they do.
The Finance Toolkit estimates the Capital Asset Pricing Model, the Fama and French model and the Carhart four factor model with the factor returns of Kenneth French’s data library, for several regions. The factor loadings, the factor risk contributions and the factor attribution of a portfolio split its risk and return by factor, the style analysis of Sharpe finds the asset class mix behind a fund, and the Fama-MacBeth regression estimates the premium a factor earns across many assets.
Example · IWM, VTV, MTUM · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then:
from financetoolkit import Toolkit
toolkit = Toolkit(
["IWM", "VTV", "MTUM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_fama_and_french_model(period="yearly")["IWM"].drop(columns="Mean Squared Error (MSE)")
Which returns:
| Item | Intercept | Mkt-RF Slope | SMB Slope | HML Slope | RMW Slope | CMA Slope | R Squared |
|---|---|---|---|---|---|---|---|
| 2021 | -0.0003 | 1.0531 | 0.827 | 0.0728 | -0.1205 | -0.0333 | 0.9868 |
| 2022 | -0.0001 | 1.0346 | 0.8939 | 0.064 | -0.0552 | 0.0663 | 0.9917 |
| 2023 | -0.0001 | 1.0292 | 0.864 | 0.1416 | -0.0731 | 0.0793 | 0.9871 |
| 2024 | 0 | 1.0402 | 0.8721 | 0.1572 | -0.0685 | 0.014 | 0.9838 |
| 2025 | 0 | 0.9702 | 0.8647 | 0.1317 | -0.1869 | -0.0232 | 0.9826 |
References
- Paper Sharpe, W.F. (1964). “Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk.” The Journal of Finance, 19(3), 425-442.
- Paper Fama, E.F. & French, K.R. (1993). “Common Risk Factors in the Returns on Stocks and Bonds.” Journal of Financial Economics, 33(1), 3-56.
- Paper Carhart, M.M. (1997). “On Persistence in Mutual Fund Performance.” The Journal of Finance, 52(1), 57-82.
- Paper Fama, E.F. & French, K.R. (2015). “A Five-Factor Asset Pricing Model.” Journal of Financial Economics, 116(1), 1-22.