Hello,

I would like to run a Fama-MacBeth regression with time varying betas and risk prices. I have m_return as independent variable and five independent risk factors. Without any rolling window my regression would be:

*First pass: Time-series Fit

foreach i in `r(levels)' {
reg m_return f1 f2 f3 f4 f5 if a== `i'
replace beta_f1 = _b[f1] if a== `i'
replace beta_f2 = _b[f2] if a== `i'
replace beta_f3 = _b[f3] if a== `i'
replace beta_f4 = _b[f4] if a== `i'
replace beta_f5 = _b[f5] if a== `i'
}

*Second pass: Cross-sectional fit

xtfmb m_return beta_f1 beta_f2 beta_f3 beta_f4 beta_f5

I would like to estimate the risk quantities β for each individual m in m_return using rolling 60-month regressions of excess returns r on the macro factors f:

Any suggestion on how to do it?