6  Fama and Macbeth Regression Analysis

WarningEarly draft

This chapter is an early draft and I have not yet carefully reviewed it. Also the APIs used in the examples may change as I continue working on the book.

This chapter illustrates the two steps of a Fama–MacBeth regression. The first step fits a cross-sectional regression in each formation year. The second averages the coefficients across years and estimates their standard errors from the time series of annual coefficients.

import polars as pl
import statspai as sp

from eap_pl import build_annual_panel, format_fit

I use build_annual_panel() to assemble the data for BEM’s 1988–2012 methodologies sample, as described in Section 2.2. For each stock-year with a December beta estimate, the panel includes that beta, market capitalization and its log, the signed book-to-market ratio, and the following calendar year’s excess return when available.

annual_panel = build_annual_panel(vintage="201406")

6.1 Implementation

6.1.1 Periodic Cross-Sectional Regressions

Compare three univariate regressions with a regression that includes beta, size, and book-to-market together. The outcome is the next year’s excess return in percent.

specifications = [["Beta"], ["Size"], ["BM"], ["Beta", "Size", "BM"]]
term_labels = {"BM": "Book-to-market"}

Following Bali et al. (2016, chap. 6), winsorize the regressors at 0.5% in each year’s regression sample. Use six Newey–West lags when estimating standard errors for the averages.

fits = []
for terms in specifications:
    sample = (
        annual_panel
        .select("year", "excess", *terms)
        .drop_nulls()
        .with_columns(
            pl.col(terms).eap.winsorize(prob=0.005, quantile_method="linear").over("year")
        )
    )
    fits.append(sp.fama_macbeth("excess ~ " + " + ".join(terms),
                               data=sample, time="year", lags=6))
Code
def periodic_results(fit, terms):
    result = pl.from_pandas(fit.model_info["period_coefs"].reset_index())
    return result.with_columns(
        adj_r2=1 - (1 - pl.col("r2")) * (pl.col("nobs") - 1) / (pl.col("nobs") - len(terms) - 1)
    )

periodic = [periodic_results(fit, terms) for fit, terms in zip(fits, specifications)]
pl.concat([
    frame.with_columns(pl.lit(str(i)).alias("Model"))
    for i, frame in enumerate(periodic, 1)
], how="diagonal").select("Model", pl.exclude("Model")).rename(term_labels).eap.show_table()
Table 6.1: Annual cross-sectional regressions (BEM Table 6.1)
Model year Intercept Beta nobs r2 adj_r2 Size Book-to-market
1 1988 1.68 5.53 5646 0.00 0.00
1 1989 -29.54 2.30 5470 0.00 0.00
1 1990 41.07 11.83 5361 0.00 0.00
1 1991 36.33 -17.56 5265 0.01 0.01
1 1992 28.10 -9.25 5354 0.01 0.01
1 1993 -5.20 -0.51 5635 0.00 -0.00
1 1994 25.42 2.89 6108 0.00 0.00
1 1995 18.27 -5.39 6235 0.00 0.00
1 1996 31.08 -17.36 6529 0.02 0.02
1 1997 -9.35 4.42 6797 0.00 0.00
1 1998 1.44 45.91 6520 0.02 0.02
1 1999 -0.83 -14.62 6035 0.01 0.01
1 2000 37.17 -24.53 5816 0.03 0.03
1 2001 7.81 -27.27 5447 0.11 0.11
1 2002 72.27 2.18 5035 0.00 -0.00
1 2003 28.62 -13.75 4695 0.02 0.02
1 2004 7.85 -5.94 4533 0.01 0.01
1 2005 12.63 -1.48 4463 0.00 0.00
1 2006 -12.06 4.41 4408 0.00 0.00
1 2007 -41.05 -0.67 4303 0.00 -0.00
1 2008 62.64 -1.41 4218 0.00 -0.00
1 2009 17.97 7.79 3940 0.01 0.01
1 2010 0.60 -6.85 3772 0.01 0.01
1 2011 25.99 -5.90 3648 0.00 0.00
2 1988 -7.67 6001 0.01 0.01 3.16
2 1989 -32.76 5807 0.00 0.00 1.10
2 1990 66.80 5671 0.01 0.01 -5.39
2 1991 52.85 5726 0.02 0.02 -7.14
2 1992 45.03 5854 0.02 0.02 -5.49
2 1993 -3.69 6389 0.00 0.00 -0.65
2 1994 30.71 6683 0.00 0.00 -0.63
2 1995 18.45 6904 0.00 0.00 -1.10
2 1996 14.86 7384 0.00 0.00 0.56
2 1997 -17.50 7367 0.00 0.00 2.12
2 1998 68.04 6918 0.01 0.01 -6.87
2 1999 -16.07 6589 0.00 0.00 1.08
2 2000 56.70 6271 0.03 0.03 -8.07
2 2001 4.71 5591 0.02 0.02 -3.48
2 2002 143.00 5168 0.05 0.05 -13.82
2 2003 32.94 4857 0.01 0.01 -2.45
2 2004 -3.70 4792 0.00 0.00 1.00
2 2005 14.29 4721 0.00 0.00 -0.54
2 2006 -24.21 4661 0.01 0.01 2.76
2 2007 -51.07 4589 0.01 0.01 1.51
2 2008 130.99 4306 0.02 0.02 -13.15
2 2009 28.88 4055 0.00 0.00 -0.52
2 2010 -21.60 3922 0.01 0.01 2.35
2 2011 27.39 3757 0.00 0.00 -1.35
3 1988 3.50 4379 0.00 0.00 3.00
3 1989 -24.69 4320 0.00 0.00 -1.08
3 1990 54.84 4255 0.00 0.00 -6.56
3 1991 13.39 4249 0.01 0.01 7.38
3 1992 15.84 4250 0.01 0.01 6.58
3 1993 -10.59 4549 0.01 0.01 6.68
3 1994 25.18 4912 0.00 -0.00 1.88
3 1995 6.28 5098 0.01 0.01 10.46
3 1996 7.03 5280 0.01 0.01 11.33
3 1997 -9.33 5558 0.00 0.00 4.57
3 1998 46.32 5374 0.00 0.00 -9.88
3 1999 -10.05 4969 0.00 0.00 2.46
3 2000 12.84 4696 0.00 0.00 8.27
3 2001 -23.83 4514 0.02 0.02 5.80
3 2002 75.04 4157 0.00 0.00 5.74
3 2003 15.25 3892 0.01 0.01 4.66
3 2004 -1.05 3748 0.00 0.00 5.85
3 2005 7.94 3942 0.00 0.00 6.43
3 2006 -5.64 3897 0.00 -0.00 -1.30
3 2007 -40.21 3789 0.00 0.00 -1.87
3 2008 53.43 3741 0.00 0.00 18.74
3 2009 24.84 3565 0.01 0.00 1.99
3 2010 -6.09 3412 0.00 -0.00 -0.14
3 2011 13.86 3328 0.01 0.01 7.22
4 1988 -10.82 -1.53 4361 0.02 0.02 3.69 4.15
4 1989 -28.49 0.05 4300 0.00 0.00 0.87 -0.74
4 1990 79.25 25.14 4245 0.02 0.02 -10.40 -9.32
4 1991 42.75 -7.15 4245 0.03 0.02 -5.64 5.31
4 1992 41.09 -3.44 4241 0.03 0.03 -4.80 4.27
4 1993 -8.74 2.37 4540 0.01 0.01 -0.75 6.87
4 1994 28.83 4.37 4903 0.00 0.00 -1.53 1.88
4 1995 14.28 -4.19 5085 0.01 0.01 -0.89 9.15
4 1996 7.44 -12.69 5278 0.02 0.02 2.05 9.64
4 1997 -20.58 2.01 5552 0.01 0.01 1.85 6.49
4 1998 69.41 61.43 5364 0.04 0.04 -14.31 -8.30
4 1999 -30.68 -23.90 4950 0.03 0.03 5.84 4.18
4 2000 70.10 -20.69 4685 0.04 0.04 -6.89 -3.24
4 2001 -2.55 -22.25 4505 0.09 0.09 -0.13 3.64
4 2002 152.88 30.54 4154 0.06 0.06 -18.97 -1.02
4 2003 30.70 -15.61 3878 0.03 0.03 -0.46 3.51
4 2004 -6.14 -8.05 3742 0.02 0.02 2.45 4.88
4 2005 12.47 -0.39 3934 0.00 0.00 -0.66 6.03
4 2006 -24.08 1.08 3894 0.01 0.01 2.68 0.44
4 2007 -49.15 -2.95 3784 0.01 0.01 1.84 -1.06
4 2008 133.83 24.86 3738 0.03 0.03 -17.86 7.97
4 2009 23.23 9.48 3557 0.02 0.02 -1.43 1.57
4 2010 -15.32 -11.48 3411 0.03 0.03 3.34 0.79
4 2011 18.95 -2.36 3326 0.01 0.01 -0.35 6.59

6.1.2 Average Cross-Sectional Regression Results

Code
rows = [
    [i, term_labels.get(term, term), fit.params[term], fit.std_errors[term],
     fit.tvalues[term], f"{fit.pvalues[term]:.3f}"]
    for i, fit in enumerate(fits, 1) for term in fit.params.index
]
pl.DataFrame(rows, schema=["Model", "Term", "Average", "SE", "t", "p"], orient="row").eap.show_table()
Table 6.2: Average coefficients and Newey–West inference (BEM Table 6.2)
Model Term Average SE t p
1 Intercept 14.95 2.99 5.01 0.000
1 Beta -2.72 1.92 -1.42 0.170
2 Intercept 23.22 5.01 4.63 0.000
2 Size -2.29 0.63 -3.64 0.001
3 Intercept 10.17 2.19 4.65 0.000
3 Book-to-market 4.09 0.71 5.80 0.000
4 Intercept 22.03 5.29 4.17 0.000
4 Beta 1.03 1.86 0.55 0.586
4 Size -2.52 0.64 -3.96 0.001
4 Book-to-market 2.65 0.73 3.64 0.001

6.2 Interpreting FM Regressions

The ordinary Fama–MacBeth standard error is the standard deviation of the annual slopes divided by the square root of the number of years. For the size slope in the regression with all three characteristics, compare the ordinary \(t\)-statistic with the six-lag Newey–West \(t\)-statistic.

Code
size_slopes = periodic[-1]["Size"]
ordinary_se = size_slopes.std() / len(size_slopes)**0.5
pl.DataFrame({
    "Standard error": ["Ordinary", "Newey–West (six lags)"],
    "t": [size_slopes.mean() / ordinary_se, fits[-1].tvalues["Size"]],
}).with_columns(pl.col("t").round(2))
shape: (2, 2)
Standard error t
str f64
"Ordinary" -1.84
"Newey–West (six lags)" -3.96

The six-lag adjustment changes the significance decision at the 5% level in this example.

6.3 Presenting FM Regressions

Code
terms = ["Beta", "Size", "BM", "Intercept"]
labels = [term_labels.get(term, term) for term in terms]
columns = {"Term": [*labels, "R²", "Adjusted R²", "n"]}
for i, (fit, frame) in enumerate(zip(fits, periodic), 1):
    columns[f"({i})"] = [
        format_fit(fit, term) if term in fit.params else "" for term in terms
    ] + [f"{frame['r2'].mean():.3f}", f"{frame['adj_r2'].mean():.3f}", f"{frame['nobs'].mean():.0f}"]
pl.DataFrame(columns).eap.show_table()
Table 6.3: Compact Fama–MacBeth regression table (BEM Table 6.3)
Term (1) (2) (3) (4)
Beta -2.72
(-1.42)
1.03
(0.55)
Size -2.29
(-3.64)
-2.52
(-3.96)
Book-to-market 4.09
(5.80)
2.65
(3.64)
Intercept 14.95
(5.01)
23.22
(4.63)
10.17
(4.65)
22.03
(4.17)
R² 0.011 0.010 0.005 0.024
Adjusted R² 0.011 0.009 0.005 0.023
n 5218 5583 4328 4320