GRS Test (Gibbons-Ross-Shanken)
Calculate the Gibbons, Ross and Shanken (GRS) test: whether the Fama and French factors explain the returns of all the Toolkit’s tickers together, judged by whether their alphas are jointly zero.
Each ticker’s daily excess return is regressed on the factors, as in get_fama_and_french_model. One alpha can look significant by chance when many tickers are tested; the GRS statistic tests all of them at once, taking into account that the tickers’ residuals are correlated. A low p-value means that at least one ticker earns a return the factors do not explain, so the factor model does not price this set of assets. With only the market factor it is the original test of whether the market portfolio is mean-variance efficient (the CAPM).
The formula is as follows:
\[r_{i,t} - \text{RF}_{t} = \alpha_{i} + \beta'_{i} \cdot f_{t} + \epsilon_{i,t}\] \[\hat{\Sigma} = \frac{\hat{\epsilon}' \cdot \hat{\epsilon}}{T}\] \[\hat{\Omega} = \frac{\sum_{t=1}^{T} d_{t} \cdot d'_{t}}{T}\] \[\text{where}\;\; d_{t} = f_{t} - \bar{f}\] \[\text{GRS} = \frac{\frac{T - N - L}{N} \cdot \hat{\alpha}' \cdot \hat{\Sigma}^{-1} \cdot \hat{\alpha}}{1 + \bar{f}' \cdot \hat{\Omega}^{-1} \cdot \bar{f}}\] \[\hat{\theta}_{p}^{2} = \bar{f}' \cdot \hat{\Omega}^{-1} \cdot \bar{f}\] \[\hat{\theta}^{2} = \hat{\theta}_{p}^{2} + \hat{\alpha}' \cdot \hat{\Sigma}^{-1} \cdot \hat{\alpha}\]The first line is fitted by least squares for each ticker i on the T days all tickers and factors have, with \(f_{t}\) the factors (by default Mkt-RF, SMB, HML, RMW and CMA) and RF the risk-free rate of the Fama and French dataset. hat(Sigma) is the covariance of the residuals and hat(Omega) the covariance of the factors. GRS is F-distributed with N and T - N - L degrees of freedom, for N tickers and L factors. hat(theta_p)^2 is the squared (daily) Sharpe ratio of the factors and hat(theta)^2 that of the factors and tickers together: the GRS statistic is large when adding the tickers improves the best Sharpe ratio.
Also known as: GRS test, Gibbons-Ross-Shanken test, joint alpha test, test of mean-variance efficiency.
Example · XLK, XLF, XLE, XLV, 2 more · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_grs_test:
from financetoolkit import Toolkit
toolkit = Toolkit(
["XLK", "XLF", "XLE", "XLV", "XLU", "XLP"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_grs_test(factors_to_calculate=["Mkt-RF", "SMB", "HML"])
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
Did the Fama-French three factors explain the daily returns of the technology, financials, energy, health care, utilities and consumer staples Select Sector SPDR ETFs from 2021 to 2025, by the GRS test of their alphas?
Which returns:
| Item | 0 |
|---|---|
| GRS Statistic | 0.5320 |
| P-Value | 0.7843 |
| Mean Absolute Alpha | 0.0001 |
| Squared Sharpe Ratio Factors | 0.0061 |
| Squared Sharpe Ratio Factors and Assets | 0.0087 |
| Observations | 1,254.0000 |
| Assets | 6.0000 |
| Factors | 3.0000 |
8 rows
Parameters
get_grs_test accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
factors_to_calculate | list[str] | None | The factors. Options are: “Mkt-RF”, “SMB”, “HML”, “RMW”, “CMA”. Defaults to None, which takes all five; [“Mkt-RF”] tests the CAPM and [“Mkt-RF”, “SMB”, “HML”] the three-factor model. | ["Mkt-RF", "SMB", "HML"] |
region | str | The region whose factors to use (the factors of Ken French’s library for that region’s stocks). Options are: “United States”, “Developed”, “Developed ex US”, “Europe”, “Japan”, “Asia Pacific ex Japan”, “North America”. Every region’s factors are U.S. dollar returns. 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 |
show_columns | str | list[str] | None | The 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 Gibbons, M.R., Ross, S.A. and Shanken, J. (1989). “A Test of the Efficiency of a Given Portfolio.” Econometrica, 57(5), 1121-1152.
- Paper Fama, E.F. and French, K.R. (2015). “A Five-Factor Asset Pricing Model.” Journal of Financial Economics, 116(1), 1-22.
- Library Shares similar logic as statsmodels’ OLS