Hello everyone, this problem has been bothering me for a while. I've tried different sets of code, but it still fails. While it might be simple for many, I really don't know what the issue is. I'm seeking help. 😢
I want to estimate monthly beta for each firm (PERMNO) using a rolling regression with a twelve-month window, similar to the illustration below:

My code is as follows:
gen beta_EPU = .
levelsof PERMNO, local(PERMNO_values)
foreach PERMNO in `PERMNO_values' {
bysort PERMNO: gen beta_EPU = .
rolling, window(12): regress mr d_EPU
replace beta_EPU = _b[d_EPU] if _n == 12
}
However, after execution, all the beta_EPU values are still missing. I'm not sure what went wrong, hope someone can help me. Thank you!
I want to estimate monthly beta for each firm (PERMNO) using a rolling regression with a twelve-month window, similar to the illustration below:
My code is as follows:
gen beta_EPU = .
levelsof PERMNO, local(PERMNO_values)
foreach PERMNO in `PERMNO_values' {
bysort PERMNO: gen beta_EPU = .
rolling, window(12): regress mr d_EPU
replace beta_EPU = _b[d_EPU] if _n == 12
}
However, after execution, all the beta_EPU values are still missing. I'm not sure what went wrong, hope someone can help me. Thank you!
Comment