View source: R/estimate_fama_macbeth.R
| estimate_fama_macbeth | R Documentation |
Estimates Fama-MacBeth regressions (Fama and MacBeth, 1973) by first running cross-sectional regressions for each time period and then aggregating the results over time to obtain average risk premia and corresponding t-statistics.
estimate_fama_macbeth(
data,
model,
vcov = "newey-west",
vcov_options = NULL,
data_options = NULL,
detail = FALSE
)
data |
A data frame containing the data for the regression. It must
include a column representing the time periods (defaults to |
model |
A character string describing the model to be estimated in
each cross-section (e.g., |
vcov |
A character string indicating the type of standard errors to
compute. Options are |
vcov_options |
A list of additional arguments to be passed to the
|
data_options |
A list of class |
detail |
A logical value indicating whether to return additional
summary statistics. If |
If detail = FALSE (default), a tibble with columns
factor, risk_premium, n (number of time periods),
standard_error, and t_statistic.
If detail = TRUE, a named list with two elements:
The same tibble described above.
A one-row tibble with r_squared (mean
cross-sectional R-squared) and n_obs (mean cross-sectional
observation count).
Fama, E. F., & MacBeth, J. D. (1973). Risk, return, and equilibrium: Empirical tests. Journal of Political Economy, 81(3), 607-636. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1086/260061")}
Newey, W. K., & West, K. D. (1987). A simple, positive semi-definite, heteroskedasticity and autocorrelation consistent covariance matrix. Econometrica, 55(3), 703-708. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/1913610")}
Other estimation functions:
estimate_betas(),
estimate_model()
set.seed(1234)
data <- tibble::tibble(
date = rep(seq.Date(from = as.Date("2020-01-01"),
to = as.Date("2020-12-01"), by = "month"), each = 50),
permno = rep(1:50, times = 12),
ret_excess = rnorm(600, 0, 0.1),
beta = rnorm(600, 1, 0.2),
bm = rnorm(600, 0.5, 0.1),
log_mktcap = rnorm(600, 10, 1)
)
estimate_fama_macbeth(data, "ret_excess ~ beta + bm + log_mktcap")
estimate_fama_macbeth(
data,
"ret_excess ~ beta + bm + log_mktcap",
vcov = "iid"
)
estimate_fama_macbeth(
data,
"ret_excess ~ beta + bm + log_mktcap",
vcov = "newey-west",
vcov_options = list(lag = 6, prewhite = FALSE)
)
# Return detailed output including R-squared and observation counts
estimate_fama_macbeth(
data,
"ret_excess ~ beta + bm + log_mktcap",
detail = TRUE
)
# Use different column name for date
data |>
dplyr::rename(month = date) |>
estimate_fama_macbeth(
"ret_excess ~ beta + bm + log_mktcap",
data_options = data_options(date = "month")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.