用stata做EVENT STUDY遇到问题,http://dss.princeton.edu/usingdata/stata/analysis/eventstudy.html#car 用了这个LINK提供的步骤,但是到Estimating Normal Performance这个部分的时候指令出现错误forvalues i=1(1)N { /*note: replace N with the highest value of id */ l id company_id if id==`i' & dif==0 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} 主要是这个指令,有哪位能帮我解决这个问题一下,比较急,麻烦了
sum id
local N=r(max)
forvalues i=1(1)`N' { /*note: replace N with the highest value of id */
list id company_id if id==`i' & dif==0
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
}
或者加入2行。
forvalues i=1(1)`N' { /*note: replace N with the highest value of id */
list id company_id if id==`i' & dif==0
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
}
forvalues i=1(1)N {
2. /*note: replace N with the highest value of id */
3. id company_id if id==`i' & dif==0
4. reg ret market_return if id==`i' & estimation_window==1
5. predict p if id==`i'
6.
. replace predicted_return = p if id==`i' & event_window==1
7.
. drop p
8.
. }
invalid syntax
r(198);
请大家帮忙啊
/*
forvalues i=1(1)N { /*note: replace N with the highest value of id */
list id company_id if id==`i' & dif==0
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
}
forvalues i=1(1)`N' { /*note: replace N with the highest value of id */
list id company_id if id==`i' & dif==0
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
}
或者加入2行。
我加入这两行出现的结果 sum id
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
id | 15654 31.5573 17.91308 1 62
.
. local N=r(max)
.
. forvalues i=1(1)`N' {
2.
. list id company_id if id==`i' & dif==0
3.
. reg ret market_return if id==`i' & estimation_window==1
4.
. predict p if id==`i'
5.
. replace predicted_return = p if id==`i' & event_window==1
6.
. drop p
7.
. }
insufficient observations
r(2001);
这是把两行加在中间
forvalues i=1(1)`N' {
2.
. sum id
3.
. local N=r(max)
4.
. list id company_id if id==`i' & dif==0
5.
. reg ret market_return if id==`i' & estimation_window==1
6.
. predict p if id==`i'
7.
. replace predicted_return = p if id==`i' & event_window==1
8.
. drop p
9.
. }
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
id | 15654 31.5573 17.91308 1 62
Source | SS df MS Number of obs = 2
-------------+------------------------------ F( 1, 0) = .
Model | 5.5778 1 5.5778 Prob > F = .
Residual | 0 0 . R-squared = 1.0000
-------------+------------------------------ Adj R-squared = .
Total | 5.5778 1 5.5778 Root MSE = 0