tidy-finance / website

This repository hosts the source code for the website tidy-finance.org
https://tidy-finance.org
Other
86 stars 49 forks source link

Fama-Macbeth Regression #81

Closed mandarpriya closed 10 months ago

mandarpriya commented 12 months ago

Sir, In this part of code risk_premiums <- data_fama_macbeth |> 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)

i see that the result obtained are general. We dont get the results for each id or permno. So if for each permno we need then what modifications are needed?

voigtstefan commented 10 months ago

Should you be interested in computing time-series regressions per permno you likely want to assign permno as a grouping variable. Without having tested the code, it seems like

risk_premiums <- data_fama_macbeth |> nest(data = c(ret_excess_lead, beta, log_mktcap, bm, month)) |> mutate(estimates = map( data, ~ tidy(lm(ret_excess_lead ~ beta + log_mktcap + bm, data = .x)) )) |> unnest(estimates)

may do the job such that you receive a time-series regression for each permno. However, note that the result is not related to Fama-Macbeth regressions anymore but only yields per firm exposure of future excess returns to the different stock characteristics.

I do not see a direct to-do for the codebase of tidy finance and thus close the issue.