Hi all,
Because my old post is too complicated, I wrote an easy code to explain my main problem.
First, the output is the same from the second line to the end. So there must be something wrong with my code structure.
thetae thetay1
.4231397 .1541079
.2788612 .191971
.2788612 .191971
.2788612 .191971
.2788612 .191971
Second, This code runs too slowly when I simulate like 10000 times, any suggestions to make it more efficient?
Sincerely yours,
Fenndy
program progone, rclass
args g0 g1 g2
confirm var `g0'
confirm var `g1'
confirm var `g2'
regress `g0' `g1' `g2'
lincom _b[`g1']-_b[`g2']
return scalar d2=r(estimate)
return scalar q2=r(se)
end
program progtwo, rclass
args t
drop _all
set obs `t'
egen time=seq()
tsset time
gen x=invnorm(runiform())
gen v1=invnorm(runiform())
gen v2=invnorm(runiform())
gen v3=invnorm(runiform())
gen ee=invnorm(runiform())
gen y=x+v1+v2+ee
gen y1=x+v1
gen y2=x+v2+v3
bootstrap dd2=r(d2) qq2=r(q2), reps(100) seed(11) saving(bootstrapsample,replace) nodots: progone y y1 y2
use bootstrapsample, clear
sum dd2, meanonly
return scalar c1=r(mean)
sum qq2, meanonly
return scalar c2=r(mean)
end
simulate thetae=r(c1) thetay1=r(c2), seed(101) reps(5): progtwo 50
Because my old post is too complicated, I wrote an easy code to explain my main problem.
First, the output is the same from the second line to the end. So there must be something wrong with my code structure.
thetae thetay1
.4231397 .1541079
.2788612 .191971
.2788612 .191971
.2788612 .191971
.2788612 .191971
Second, This code runs too slowly when I simulate like 10000 times, any suggestions to make it more efficient?
Sincerely yours,
Fenndy
program progone, rclass
args g0 g1 g2
confirm var `g0'
confirm var `g1'
confirm var `g2'
regress `g0' `g1' `g2'
lincom _b[`g1']-_b[`g2']
return scalar d2=r(estimate)
return scalar q2=r(se)
end
program progtwo, rclass
args t
drop _all
set obs `t'
egen time=seq()
tsset time
gen x=invnorm(runiform())
gen v1=invnorm(runiform())
gen v2=invnorm(runiform())
gen v3=invnorm(runiform())
gen ee=invnorm(runiform())
gen y=x+v1+v2+ee
gen y1=x+v1
gen y2=x+v2+v3
bootstrap dd2=r(d2) qq2=r(q2), reps(100) seed(11) saving(bootstrapsample,replace) nodots: progone y y1 y2
use bootstrapsample, clear
sum dd2, meanonly
return scalar c1=r(mean)
sum qq2, meanonly
return scalar c2=r(mean)
end
simulate thetae=r(c1) thetay1=r(c2), seed(101) reps(5): progtwo 50
Comment