The Fama-Macbeth regression method is a common empirical technique for estimating risk premiums in asset pricing models. It involves a two-step procedure that assumes a linear relation between the expected returns of assets and their exposures to priced risk factors. In the first stage, the returns of individual assets are regressed on their factor loadings in each time period. In the second stage, the time-series averages of the regression coefficients are tested for statistical significance. In this study, I use individual stocks as test assets and examine the risk premiums associated with three Fama-French factors: MKT, SMB, and HML.
install.packages(c("tidyverse", "plm", "broom", "lmtest", "sandwich"),
repos = "https://cloud.r-project.org")
library(tidyverse)
library(plm)
library(broom)
library(lmtest)
library(sandwich)
Tsedata = read.csv("data.csv")
fmdata = Tsedata %>%
select(symbol, date, ri, MKT, SMB, HML) %>%
drop_na()
head(fmdata)
## symbol date ri MKT SMB HML
## 1 AAPL 4-Jan-11 0.0052062641 -0.001313890 -0.0065 0.0008
## 2 AAPL 5-Jan-11 0.0081462879 0.004994670 0.0018 0.0013
## 3 AAPL 6-Jan-11 -0.0008082435 -0.002125228 0.0001 -0.0025
## 4 AAPL 7-Jan-11 0.0071360567 -0.001846505 0.0022 -0.0006
## 5 AAPL 10-Jan-11 0.0186572890 -0.001377275 0.0041 0.0039
## 6 AAPL 11-Jan-11 -0.0023681840 0.003718222 0.0016 0.0036
Step 1 employs the factor exposures as independent variables in T cross-sectional regressions, one for each time period.
riskpremium = fmdata %>%
nest(data = c(symbol, ri, MKT, SMB, HML)) %>%
mutate(etimates = map(data,
~tidy(lm(ri ~ MKT + SMB + HML,
data = .x)))) %>%
select(-data) %>%
unnest(etimates)
head(riskpremium, 4)
## # A tibble: 4 × 6
## date term estimate std.error statistic p.value
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 4-Jan-11 (Intercept) 0.00950 0.00350 2.72 0.0419
## 2 4-Jan-11 MKT NA NA NA NA
## 3 4-Jan-11 SMB NA NA NA NA
## 4 4-Jan-11 HML NA NA NA NA
In the second step, the estimates are aggregated across time to test if risk is priced.
riskprice <- riskpremium %>%
group_by(characteristics = term) %>%
summarize(
risk_premium = mean(estimate, na.rm = TRUE),
t_statistic = mean(estimate, na.rm = TRUE) / sd(estimate, na.rm = TRUE) * sqrt(n())
)
print(riskprice)
## # A tibble: 4 × 3
## characteristics risk_premium t_statistic
## <chr> <dbl> <dbl>
## 1 (Intercept) 0.000211 0.559
## 2 HML NaN NaN
## 3 MKT NaN NaN
## 4 SMB NaN NaN
The Fama-Macbeth regression outcome can be obtained by applying the standard Mean Groups estimator. The pmg output shows that the results are consistent with Fama-Macbeth step2.
fm = pmg(ri ~ MKT + SMB + HML,
data = fmdata,
index = c("date", "symbol"),
model = "mg")
coeftest(fm)
##
## t test of coefficients:
##
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.00021093 0.00037706 0.5594 0.5759
## MKT NA NA NA NA
## SMB NA NA NA NA
## HML NA NA NA NA
The results show the estimated risk premiums for the three Fama-French factors. A positive and significant coefficient on HML confirms the value premium. A negative SMB coefficient would indicate returns are higher for larger stocks, while a positive SMB suggests a size premium for smaller stocks. The MKT coefficient captures the market risk premium.
sources: tidy-finance.org, r-bloggers.com