本人想用模拟的方法重现,AB(1991)文章,表2倒数第2列的内容,但模拟结果和文中相差很大,重复多次仍然如此,不知是什么原因?望连老师指点。程序如下,该程序计算了在a=0.2,0.8,0.5时,拒绝原假设的个数。为了节省时间,只循环了20次。原文的链接在
https://bbs.pinggu.org/thread-1138852-1-1.html 的附件中。
local reps=20
foreach b of numlist 0.5 0.2 0.8 {
mat P = J(`reps',1,.)
forval i=1/`reps' {
qui xtarsim y x eta, n(100) t(7) gamma(`b') beta(1) rho(0.8) one(rand 1) sn(9)
xtabond y x
est store onestep
gen ly=l.y
qui reg y ly x
est store ols
qui hausman onestep ols
mat P[`i',1] = scalar(r(chi2))
}
svmat P, names(p)
keep p1
drop if _n>`reps'
qui count if p1>invchi2(1,0.95)
local c=`b'*10
scalar n_onesh_`c'=r(N)
}
dis n_onesh_5
dis n_onesh_2
dis n_onesh_8
运行结果如下:
. dis n_onesh_5
13
.
. dis n_onesh_2
20
.
. dis n_onesh_8
2