Fama-MacBeth Regression: A Practical Walkthrough
A practical walkthrough of the two-pass Fama-MacBeth (1973) procedure: rolling-beta time-series regressions, period-by-period cross-sectional regressions, then averaging the slopes with Newey-West HAC
Category: Factor Research
What Fama-MacBeth estimates
Fama-MacBeth (1973) is a two-pass method for estimating factor risk premia. Pass 1 runs time-series regressions to estimate each asset's betas. Pass 2 runs a cross-sectional regression of returns on those betas each period. You then average the period-by-period slopes and compute Newey-West HAC t-statistics.
The central question it answers is: across the cross-section of assets, is exposure to a given factor (say, value or momentum) compensated with a return premium over time? Rather than fitting a single pooled regression, Fama-MacBeth deliberately separates the estimation of risk exposures from the pricing of those exposures, which sidesteps a major statistical problem and produces honest standard errors. Cochrane's textbook treatment and the original Fama and MacBeth (1973) paper remain the standard references for the procedure.
The two-pass procedure, step by step
Pass 1 - estimate betas (time series). For each asset i, regress its excess returns on the factor returns over a rolling estimation window:
r_{i,t} = a_i + b_i' F_t + e_{i,t}
Using a rolling window (rather than the full sample) lets each asset's loadings drift over time, which matters because exposures are not constant. The output is a panel of estimated betas, one set per asset per period.
Pass 2 - price the betas (cross section). For each period t, run a single cross-sectional regression of that period's asset returns on the betas estimated up to t:
r_{i,t} = gamma_{0,t} + gamma_t' beta_i + u_{i,t}
This yields a time series of slope estimates gamma_t - one realized 'premium' per factor per period.
Aggregate and test. Average the slopes across the T periods:
gamma_hat = (1/T) * sum_t gamma_t
The naive t-statistic divides this mean by the standard error of the slope series. Because the slope series is serially correlated and heteroskedastic, the standard correction is Newey-West HAC (Newey and West, 1987) with a lag length chosen for the data frequency. This is the key reason Fama-MacBeth is preferred over a pooled OLS: averaging period-by-period slopes and applying HAC errors handles cross-sectional correlation in residuals that would otherwise understate the standard errors. Note that Pass-1 betas are estimated, so an errors-in-variables bias can remain; Shanken (1992) derives a correction, and grouping assets into portfolios is a common mitigation.
How SurgeFlow applies it
SurgeFlow's factor system builds daily factor returns for Fama-French style factors - SMB, HML, RMW, CMA, WML and LIQ - behind a publication gate and an effective-direction resolver, with VIF diagnostics to flag collinearity among factors. Cross-sectional estimation of factor premia uses Fama-MacBeth, and model-level tests include the GRS joint F-test (Gibbons, Ross and Shanken, 1989) for whether a set of intercepts is jointly zero.
An explicit honesty note: the current Factor Backtest V2 Phase-1 run is research_backtest_insample - it is in-sample factor attribution, not live out-of-sample rolling-signal evidence. GRS and the other diagnostics are reported as labels, not used as sleeve-exclusion gates; in the live UI and API, diagnostics are labels, not portfolio gates. The data-quality gates that do bind apply to the data itself: point-in-time alignment, survivorship handling and minimum-observation thresholds. Read those numbers as research attribution, not as a validated trading signal.
What SurgeFlow data this uses
The factor returns, betas and cross-sectional premia draw on SurgeFlow's multi-market equity data science stack across four markets: US, China, Japan and Hong Kong. Underlying price and fundamental data come from FMP (US), Tushare (China, Hong Kong), and J-Quants and EDINET (Japan). Factor returns are computed daily and passed through the publication gate and direction resolver before they enter any cross-sectional regression.
For the composite-ranked Factor Backtest V2 sleeves (equal-weight and risk-parity, ranked by argmax of 0.5*z(Sharpe) + 0.5*z(InfoRatio)), the US composite winner is the WML+RMW Top-30 risk-parity sleeve, which ranks #1 by both Sharpe and Information Ratio over roughly ten years - reported qualitatively, and again as in-sample attribution. Exact premia, Sharpe values and observation counts are not stated here; query the live data instead through /factors, /backtesting and the public API.
Reproduce it with the free API
You can pull the same daily factor returns and screening data that feed these regressions and run the two-pass procedure yourself. Create a free (beta) API key at /account; the public API (free beta) allows 2,000 requests per day across all four markets, with endpoints for realtime, screen, hotlist and summary data plus open JSON/CSV snapshots. The OpenAPI spec is at /api/public/openapi.json and an AI-readable index is at /llms.txt.
If you prefer spreadsheets, you can load SurgeFlow snapshots into Google Sheets today via the public CSV/JSON endpoints with =IMPORTDATA(...) or via Apps Script using your key - there is no published Google Workspace add-on (any add-on is in review at most). A starter kit lives on GitHub. None of this is investment advice; it is research data for you to test the Fama-MacBeth premia yourself.
Sources and further reading
Primary, academic, and SurgeFlow data references for the claims above: - Fama, E. F. and MacBeth, J. D. (1973), 'Risk, Return, and Equilibrium: Empirical Tests', Journal of Political Economy - Newey, W. K. and West, K. D. (1987), 'A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix', Econometrica - Shanken, J. (1992), 'On the Estimation of Beta-Pricing Models', Review of Financial Studies - Gibbons, M. R., Ross, S. A. and Shanken, J. (1989), 'A Test of the Efficiency of a Given Portfolio', Econometrica - SurgeFlow factor system and Factor Backtest V2 (research_backtest_insample), /factors and /backtesting