tsset firm wave
xtabond2 y L LL K LK Ly dum2 dum3 wood1 textile1 metal1 anystat anyfor capcity, gmm (L LL K LK Ly) iv(dum2 dum3 wood1 textile1 metal1 anystat anyfor capcity ,eq(level)) small two robust
matrix cov1 = e(V)
matrix b1 =e(b)
md_ar1, nx(2) beta(e(b)) cov(e(V))
scalar betaL=theta[1,1]
******************** I have a balanced panel of firms for T=3
******************** Bootstrap program begins here:
capture program drop myboot2
program define myboot2, rclass
preserve
generate newfirm=firm
bsample , cluster(firm) idcluster(newfirm)
tsset newfirm wave
xtabond2 y L LL K LK Ly dum2 dum3 wood1 textile1 metal1 anystat anyfor capcity, gmm (L LL K LK Ly) iv(dum2 dum3 wood1 textile1 metal1 anystat anyfor capcity ,eq(level)) small two robust
tempname cov1
matrix cov1 = e(V)
tempname b1
matrix b1 =e(b)
md_ar1, nx(2) beta(b1) cov(cov1)
tempname betaL
return scalar betaL=theta[1,1]
tempname MRPLb
gen MRPLb=(1/L)
sum MRPLb
tempname MRm
return scalar MRm=r(mean)
restore
end
simulate betaL=theta[1,1] MRm=r(mean) , reps(3) seed(12345) :myboot2 trace
Here is the output in the data editor:
betaL MRm
.531211 .
.013747 .
.300624 .
Clearly, the code is bootstrapping betaL, but unable to calculate MRm.
0 Response to Block bootstrapping panel: Unable to generate new variable using each bootstrap replication
Post a Comment