Factor Loadings

Estimate the loadings of a time series factor model.

It is the regression of every asset’s returns on factor returns, by default the five factors of Fama and French (market, size, value, profitability and investment), \(r_{i,t} = \alpha_{i} + \sum_{f} \beta_{i,f} F_{f,t} + \epsilon_{i,t}\). The loadings are what the factor covariance, the factor risk contributions, the factor attribution and the augmented and Bayesian Black-Litterman models build on.

  • Ordinary least squares on every factor.
  • Forward selection: starting without factors, add the factor with the lowest p-value as long as every p-value stays at or below the threshold (or, with another criterion, as long as it improves); the factors left out load zero.
  • Backward selection: starting with every factor, drop the one with the highest p-value until all are at or below the threshold (or as long as dropping one improves the criterion). Both stepwise selections keep at least the single best factor on the p-value.
  • Principal components regression: the standardized factors’ first principal components that explain the given share of their variance as regressors, mapped back to loadings on the factors, which removes the instability that correlated factors give OLS (Jolliffe, 1982).

The Alpha is the annualized intercept, \(\alpha\) times the number of periods in a year. The R Squared is the share of an asset’s variance the factors explain and the Residual Volatility (ddof=1, annualized) what they leave, the idiosyncratic risk the factor covariance keeps on the diagonal.

Also known as: factor exposures, factor betas, loadings matrix, stepwise regression, principal components regression.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_factor_loadings:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_factor_loadings(selection="forward")

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

What were the Fama and French factor loadings of Apple, Microsoft, Johnson & Johnson and ExxonMobil from 2021 to 2025, keeping only the factors a forward selection picks?

Which returns:

Parameters

get_factor_loadings accepts the following parameters.

ParameterTypeDescriptionExample
selectionstrOptions are: “ols” (every factor), “forward” (forward selection), “backward” (backward selection), “pcr” (principal components regression). Defaults to “ols”."ols"
criterionstrWhat the stepwise selections compare. Options are: “pvalue” (p-value), “aic” (Akaike information criterion), “bic” (Schwarz information criterion), “r_squared” (R squared), “adjusted_r_squared” (adjusted R squared). Defaults to “pvalue”."pvalue"
thresholdfloatThe highest p-value a selected factor may have. Defaults to 0.05.0.05
componentsfloatThe principal components the principal components regression keeps: a number of 1 or more, or between 0 and 1 the share of the variance of the standardized factors to explain. Defaults to 0.95.0.95
factorspd.DataFrame | NoneThe factor returns, one column per factor, at the frequency of the period. Defaults to None, the Fama and French five factors of the region.None, the Fama and French five factors of the region
regionstrThe region of the Fama and French factors. Options are: “United States”, “Developed”, “Developed ex US”, “Europe”, “Japan”, “Asia Pacific ex Japan”, “North America”. Defaults to “United States”."Europe"
periodstrThe frequency of the returns. Options are: “daily” (daily returns), “weekly” (weekly returns), “monthly” (monthly returns), “quarterly” (quarterly returns), “yearly” (yearly returns). Defaults to “daily”."weekly"
include_benchmarkboolWhether to include the benchmark as an asset. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding.2
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Fama, E. F. and French, K. R. (1993). “Common Risk Factors in the Returns on Stocks and Bonds.” Journal of Financial Economics, 33(1), 3-56.
  • Paper Fama, E. F. and French, K. R. (2015). “A Five-Factor Asset Pricing Model.” Journal of Financial Economics, 116(1), 1-22.
  • Paper Connor, G. (1995). “The Three Types of Factor Models: A Comparison of Their Explanatory Power.” Financial Analysts Journal, 51(3), 42-46.
  • Paper Jolliffe, I. T. (1982). “A Note on the Use of Principal Components in Regression.” Journal of the Royal Statistical Society, Series C, 31(3), 300-303.
  • Library Referenced against Riskfolio-Lib’s loadings_matrix (backward selection, every factor kept)
  • Library Referenced against Riskfolio-Lib’s PCR
  • Library Shares similar logic as Riskfolio-Lib’s forward_regression
  • Library Shares similar logic as Riskfolio-Lib’s backward_regression
Share