library(tidyverse)
library(RSQLite)
library(sandwich)
library(broom)
Fama-MacBeth Regressions
You are reading Tidy Finance with R. You can find the equivalent chapter for the sibling Tidy Finance with Python here.
In this chapter, we present a simple implementation of Fama and MacBeth (1973), a regression approach commonly called Fama-MacBeth regressions. Fama-MacBeth regressions are widely used in empirical asset pricing studies. We use individual stocks as test assets to estimate the risk premium associated with the three factors included in Fama and French (1993).
Researchers use the two-stage regression approach to estimate risk premiums in various markets, but predominately in the stock market. Essentially, the two-step Fama-MacBeth regressions exploit a linear relationship between expected returns and exposure to (priced) risk factors. The basic idea of the regression approach is to project asset returns on factor exposures or characteristics that resemble exposure to a risk factor in the cross-section in each time period. Then, in the second step, the estimates are aggregated across time to test if a risk factor is priced. In principle, Fama-MacBeth regressions can be used in the same way as portfolio sorts introduced in previous chapters.
The Fama-MacBeth procedure is a simple two-step approach: The first step uses the exposures (characteristics) as explanatory variables in \(T\) cross-sectional regressions. For example, if \(r_{i,t+1}\) denote the excess returns of asset \(i\) in month \(t+1\), then the famous Fama-French three-factor model implies the following return generating process (see also Campbell et al. 1998): \[\begin{aligned}r_{i,t+1} = \alpha_i + \lambda^{M}_t \beta^M_{i,t} + \lambda^{SMB}_t \beta^{SMB}_{i,t} + \lambda^{HML}_t \beta^{HML}_{i,t} + \epsilon_{i,t}.\end{aligned}\] Here, we are interested in the compensation \(\lambda^{f}_t\) for the exposure to each risk factor \(\beta^{f}_{i,t}\) at each time point, i.e., the risk premium. Note the terminology: \(\beta^{f}_{i,t}\) is a asset-specific characteristic, e.g., a factor exposure or an accounting variable. If there is a linear relationship between expected returns and the characteristic in a given month, we expect the regression coefficient to reflect the relationship, i.e., \(\lambda_t^{f}\neq0\).
In the second step, the time-series average \(\frac{1}{T}\sum_{t=1}^T \hat\lambda^{f}_t\) of the estimates \(\hat\lambda^{f}_t\) can then be interpreted as the risk premium for the specific risk factor \(f\). We follow Zaffaroni and Zhou (2022) and consider the standard cross-sectional regression to predict future returns. If the characteristics are replaced with time \(t+1\) variables, then the regression approach captures risk attributes rather than risk premiums.
Before we move to the implementation, we want to highlight that the characteristics, e.g., \(\hat\beta^{f}_{i}\), are often estimated in a separate step before applying the actual Fama-MacBeth methodology. You can think of this as a step 0. You might thus worry that the errors of \(\hat\beta^{f}_{i}\) impact the risk premiums’ standard errors. Measurement error in \(\hat\beta^{f}_{i}\) indeed affects the risk premium estimates, i.e., they lead to biased estimates. The literature provides adjustments for this bias (see, e.g., Shanken 1992; Kim 1995; Chen, Lee, and Lee 2015, among others) but also shows that the bias goes to zero as \(T \to \infty\). We refer to Gagliardini, Ossola, and Scaillet (2016) for an in-depth discussion also covering the case of time-varying betas. Moreover, if you plan to use Fama-MacBeth regressions with individual stocks, Hou, Xue, and Zhang (2020) advocates using weighted-least squares to estimate the coefficients such that they are not biased toward small firms. Without this adjustment, the high number of small firms would drive the coefficient estimates.
The current chapter relies on this set of R packages.
Data Preparation
We illustrate Fama and MacBeth (1973) with the monthly CRSP sample and use three characteristics to explain the cross-section of returns: market capitalization, the book-to-market ratio, and the CAPM beta (i.e., the covariance of the excess stock returns with the market excess returns). We collect the data from our SQLite
-database introduced in Accessing and Managing Financial Data and WRDS, CRSP, and Compustat.
<- dbConnect(
tidy_finance SQLite(),
"data/tidy_finance_r.sqlite",
extended_types = TRUE
)
<- tbl(tidy_finance, "crsp_monthly") |>
crsp_monthly select(permno, gvkey, date, ret_excess, mktcap) |>
collect()
<- tbl(tidy_finance, "compustat") |>
compustat select(datadate, gvkey, be) |>
collect()
<- tbl(tidy_finance, "beta") |>
beta select(date, permno, beta_monthly) |>
collect()
We use the Compustat and CRSP data to compute the book-to-market ratio and the (log) market capitalization. Furthermore, we also use the CAPM betas based on monthly returns we computed in the previous chapters.
<- compustat |>
characteristics mutate(date = floor_date(ymd(datadate), "month")) |>
left_join(crsp_monthly, join_by(gvkey, date)) |>
left_join(beta, join_by(permno, date)) |>
transmute(gvkey,
bm = be / mktcap,
log_mktcap = log(mktcap),
beta = beta_monthly,
sorting_date = date %m+% months(6)
)
<- crsp_monthly |>
data_fama_macbeth left_join(characteristics, join_by(gvkey, date == sorting_date)) |>
group_by(permno) |>
arrange(date) |>
fill(c(beta, bm, log_mktcap), .direction = "down") |>
ungroup() |>
left_join(crsp_monthly |>
select(permno, date, ret_excess_lead = ret_excess) |>
mutate(date = date %m-% months(1)),
join_by(permno, date)
|>
) select(permno, date, ret_excess_lead, beta, log_mktcap, bm) |>
drop_na()
Cross-Sectional Regression
Next, we run the cross-sectional regressions with the characteristics as explanatory variables for each month. We regress the returns of the test assets at a particular time point on the characteristics of each asset. By doing so, we get an estimate of the risk premiums \(\hat\lambda^{f}_t\) for each point in time.
<- data_fama_macbeth |>
risk_premiums nest(data = c(ret_excess_lead, beta, log_mktcap, bm, permno)) |>
mutate(estimates = map(
data,~ tidy(lm(ret_excess_lead ~ beta + log_mktcap + bm, data = .x))
|>
)) unnest(estimates)
Time-Series Aggregation
Now that we have the risk premiums’ estimates for each period, we can average across the time-series dimension to get the expected risk premium for each characteristic. Similarly, we manually create the \(t\)-test statistics for each regressor, which we can then compare to usual critical values of 1.96 or 2.576 for two-tailed significance tests.
<- risk_premiums |>
price_of_risk group_by(factor = term) |>
summarize(
risk_premium = mean(estimate),
t_statistic = mean(estimate) / sd(estimate) * sqrt(n())
)
It is common to adjust for autocorrelation when reporting standard errors of risk premiums. As in Univariate Portfolio Sorts, the typical procedure for this is computing Whitney K. Newey and West (1987) standard errors. We again recommend the data-driven approach of Whitney K. Newey and West (1994) using the NeweyWest()
function, but note that you can enforce the typical 6 lag settings via NeweyWest(., lag = 6, prewhite = FALSE)
.
<- risk_premiums |>
regressions_for_newey_west select(date, factor = term, estimate) |>
nest(data = c(date, estimate)) |>
mutate(
model = map(data, ~ lm(estimate ~ 1, .)),
mean = map(model, tidy)
)
<- regressions_for_newey_west |>
price_of_risk_newey_west mutate(newey_west_se = map_dbl(model, ~ sqrt(NeweyWest(.)))) |>
unnest(mean) |>
mutate(t_statistic_newey_west = estimate / newey_west_se) |>
select(factor,
risk_premium = estimate,
t_statistic_newey_west
)
left_join(price_of_risk,
|>
price_of_risk_newey_west select(factor, t_statistic_newey_west),
join_by(factor)
)
# A tibble: 4 × 4
factor risk_premium t_statistic t_statistic_newey_west
<chr> <dbl> <dbl> <dbl>
1 (Intercept) 0.0119 4.67 3.93
2 beta 0.0000126 0.0123 0.0111
3 bm 0.00146 3.18 2.73
4 log_mktcap -0.000990 -2.83 -2.48
Finally, let us interpret the results. Stocks with higher book-to-market ratios earn higher expected future returns, which is in line with the value premium. The negative value for log market capitalization reflects the size premium for smaller stocks. Consistent with results from earlier chapters, we detect no relation between beta and future stock returns.
You can also replicate the results using the tidyfinace
package via the estimate_fama_macbeth()
function:
library(tidyfinance)
estimate_fama_macbeth(
data = data_fama_macbeth,
model = "ret_excess_lead ~ beta + bm + log_mktcap",
vcov = "newey-west"
)
Exercises
- Download a sample of test assets from Kenneth French’s homepage and reevaluate the risk premiums for industry portfolios instead of individual stocks.
- Use individual stocks with weighted-least squares based on a firm’s size as suggested by Hou, Xue, and Zhang (2020). Then, repeat the Fama-MacBeth regressions without the weighting scheme adjustment but drop the smallest 20 percent of firms each month. Compare the results of the three approaches.