Hi,
I am new to Stata. I have a monthly panel data consisting of securities (ids) and factors for 20 years. I am trying to estimate a rolling 24 month step-wise regression and store adj r2, t-stat, p values, coefficients etc. for each id and 24 month period.
I am not able to get the code work. Any help will be much appreciated.
xtset id date
tempfile results
levelsof id, local(ids)
foreach id of local ids {
keep if id==`id'
quietly rolling: window(24) stepsize(1) saving(C:\Users\John\`results'.dta, replace), ///
stepwise, pr(.15) pe(.10): regress y x1 x2 x3
merge id using "`results'", sort update replace nokeep
drop _merge
}
Thanks,
John
I am new to Stata. I have a monthly panel data consisting of securities (ids) and factors for 20 years. I am trying to estimate a rolling 24 month step-wise regression and store adj r2, t-stat, p values, coefficients etc. for each id and 24 month period.
I am not able to get the code work. Any help will be much appreciated.
xtset id date
tempfile results
levelsof id, local(ids)
foreach id of local ids {
keep if id==`id'
quietly rolling: window(24) stepsize(1) saving(C:\Users\John\`results'.dta, replace), ///
stepwise, pr(.15) pe(.10): regress y x1 x2 x3
merge id using "`results'", sort update replace nokeep
drop _merge
}
Thanks,
John
Comment