amelia812 发表于 2015-3-5 10:34 
用循环计算
//predict
set more off
您好,我用了改善后的程序后仍有误,stata显示invalid syntax,麻烦帮忙看看是否程序有误。非常感谢
gen predicted_return=.
egen id=group(company_id)
qui tabulate id
local N = r(r)
forvalues i=1(1)'N' {
qui reg ret market_return if (id== 'i' & estimation_window==1)
predict p if id=='i'
replace predicted_return = p if (id=='i' & event_window==1)
drop p
}