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))
# 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")
)
Run the code above in your browser using DataLab