*-The Excess Return using extended-CAPM
*-假设 id year month 分别为公司代码,年度和月度标示。
*- Ri 和 Rm 分别表示个股和市场月度回报率。
egen m123 = group(year month), label lname(month123)
tsset id m123
xtdes
global N = r(N)
global y "Ri"
global x "L.Rm Rm F.Rm"
cap drop res
cap drop R2
cap drop R2_adj
gen res = .
gen R2 = .
gen R2_adj = .
forvalues i = 1/$N{
qui reg $y $x if (m123==`i')
qui predict e if e(sample), res
qui replace res = e if e(sample)
qui replace R2 = e(r2) if e(sample)
qui replace R2_adj = e(r2_a) if e(sample)
drop e
}
请问:
1 global y "Ri"
global x "L.Rm Rm F.Rm"
——这两句,什么意思?
cap drop res
cap drop R2
cap drop R2_adj
这组命令的作用是避免在进行第二组循环时出现 res already defined ?
2 drop e 的作用是什么?
3 这依然是个一重的循环;STATA可否做两重的循环?
3Q