Fama and French Model (FF)
Calculate Fama and French 5 Factor model scores and residuals for a set of financial assets.
The Fama and French 5 Factor model is a widely used financial model that helps estimate the expected return of financial assets, such as stocks or portfolios, based on five key factors:
- Market Risk Premium (Mkt-RF): Represents the additional return that investors expect to earn for taking on the risk of investing in the overall market as opposed to a risk-free asset.
- Size Premium (SMB): Reflects the historical excess return of small-cap stocks over large-cap stocks.
- Value Premium (HML): Captures the historical excess return of value stocks over growth stocks.
- Profitability (RMW): Measures the historical excess return of high profitability stocks over low profitability stocks.
- Investment (CMA): Quantifies the historical excess return of low investment stocks over high investment stocks.
The model can perform both a Simple Linear Regression on each factor as well as a Multi Linear Regression which includes all factors. Generally, a multi linear regression is applied but if you wish to see individual R-squared values for each factor you can select the simple linear regression method.
The model performs a Linear Regression on each factor and defines the regression parameters and residuals for each asset over time based on its exposure to these factors.
The regression formula is as follows for the Multi Linear Regression:
\[\text{Excess Return} = \text{Intercept} + \text{Beta1} \cdot \text{Mkt-RF} + \text{Beta2} \cdot \text{SMB} + \text{Beta3} \cdot \text{HML} + \text{Beta4} \cdot \text{RMW} + \text{Beta5} \cdot \text{CMA} + \text{Residuals}\]And the following for the Simple Linear Regression:
\[\text{Excess Return} = \text{Intercept} + \text{Slope} \cdot \text{Factor Value} + \text{Residuals}\]So for a given factor, it should hold that the Excess Return equals the entire regression. Note that in this calculation the Excess Return refers to the Asset Return minus the Risk Free Rate as reported in the Fama and French dataset and will not be the same as the defined Excess Return in the historical data given that this is based on the Risk Free Rate defined in the initialization.
The regression is estimated on the daily observations falling inside each period, so its Intercept, Slope and Residuals are all on a daily scale. The Factor Value and Residuals columns reported by the Simple Linear Regression therefore describe the last daily observation within the period, which is the only reading for which the identity above holds - they are not period-aggregated quantities.
What is relevant to look at is the influence these factors have on each stock and how much each factor explains the stock return. E.g. you will generally see a pretty high influence (Beta or Slope) for the Market Risk Premium (Mkt-RF) factor as this is the main factor that explains the stock return (as also prevalent in the CAPM). The other factors can fluctuate greatly between stocks depending on which stocks you look at.
The slopes are read as tilts: a positive HML slope is a value tilt and a negative one a growth tilt, a negative SMB slope marks a large-cap profile, and RMW and CMA show exposure to profitable and conservatively investing firms. With about 250 daily observations per year the slopes of the smaller factors are noisy, so only loadings that are large and persist across periods say much about a stock or fund. The R Squared shows how much of the daily excess return the factors explain; a low value leaves most of the return to stock-specific news.
Also known as: Fama-French model, three-factor model, five-factor model, FF3, FF5.
Fama and French Model (FF) in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_fama_and_french_model as shown below.
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",
)
# Calculate Fama and French 5 Factor model scores
toolkit.performance.get_fama_and_french_model()["IWM"].drop(columns="Mean Squared Error (MSE)")
Or, after setting up the Finance Toolkit MCP, ask:
What were the Fama and French five-factor loadings and R-squared of IWM in each year from 2021 to 2025?
Which returns:
| Intercept | Mkt-RF Slope | SMB Slope | HML Slope | RMW Slope | CMA Slope | R Squared | |
|---|---|---|---|---|---|---|---|
| 2021 | -0.0003 | 1.0529 | 0.8267 | 0.0728 | -0.1204 | -0.0334 | 0.9868 |
| 2022 | -0.0001 | 1.0343 | 0.893 | 0.0645 | -0.0553 | 0.0654 | 0.9917 |
| 2023 | -0.0001 | 1.0292 | 0.8647 | 0.141 | -0.0731 | 0.0794 | 0.9871 |
| 2024 | 0 | 1.0396 | 0.8723 | 0.1568 | -0.0685 | 0.0143 | 0.9838 |
| 2025 | 0 | 0.9702 | 0.8649 | 0.1317 | -0.1871 | -0.0235 | 0.9826 |
Parameters
get_fama_and_french_model accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period for the calculation (e.g., “weekly”, “monthly”, “quarterly”, “yearly”). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "monthly" |
method | str | The regression method to use for the calculation. Defaults to ‘multi’. | "simple" |
factors_to_calculate | list of str | List of factors to calculate scores and residuals for. Defaults to [“Mkt-RF”, “SMB”, “HML”, “RMW”, “CMA”]. | ["Mkt-RF", "SMB", "HML"] |
include_daily_residuals | bool | Whether to also return the pointwise (daily) regression residuals as a second DataFrame. Defaults to False. | True |
region | str | The region whose factors to use: “United States”, “Developed”, “Developed ex US”, “Europe”, “Japan”, “Asia Pacific ex Japan” or “North America” (the factors of Ken French’s library for that region’s stocks). Every region’s factors are U.S. dollar returns with the U.S. one-month Treasury bill as the risk-free rate (RF), so a ticker quoted in another currency is best analysed with its U.S. dollar returns; otherwise the exchange rate’s moves end up in the factor loadings, mostly the market beta. Defaults to “United States”. | "Europe" |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the ratio values. Defaults to False. | True |
lag | int or list of int | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
show_columns | list of str | Restrict the result to these top level columns. Defaults to None, which returns every column. | ["Intercept", "R Squared"] |