Dear Statalists,
I have a problem with the tempvars in the monte carlo simulation of 2sls regression on Stata 13. The "do file" stops working with this error message:
[__000000] not found
an error occurred when simulate executed my2sls
r(111);
I have looked around the web, but almost all the cases were about using the "reshape" command, which is not related to this code. I would appreciate your kind tips. The code is below:
clear all
set seed 10101
* Set the values of the parameters
global numobs = 150 /*numobs = sample size*/
global numsims = 1000 /*numsims = replication number*/
capture program drop my2sls
program my2sls, rclass
version 13
drop _all
set obs $numobs
tempvar x1 x2 x3 eps1 eps2 u1 u2 y1 y2
generate `x1' = runiform()
generate `x2' = runiform()
generate `x3' = runiform()
generate `eps1' = rnormal()
generate `eps2' = rnormal()
generate `u1' = 1.708*`eps1' + 1.404*`eps2'
generate `u2' = 1.732*`eps2'
generate `y1' = -1.412*`x1' - 0.588*`x2' - 2.118*`x3' - 0.588*`u1' - 0.882*`u2'
generate `y2' = -1.412*`x1' - 0.588*`x2' - 2.118*`x3' - 0.882*`u1' - 0.558*`u2'
ivregress 2sls `y2' (`y1' = `x2')
return scalar b1 = _b[`x1']
return scalar b2 = _b[`x2']
return scalar b3 = _b[`x3']
end
set matsize 11000
simulate b1=r(b1) b2=r(b2) b3=r(b3), reps($numsims) saving(results, replace) nolegend nodots: my2sls
use results, clear
summarize
Thanks in advance,
Homa
I have a problem with the tempvars in the monte carlo simulation of 2sls regression on Stata 13. The "do file" stops working with this error message:
[__000000] not found
an error occurred when simulate executed my2sls
r(111);
I have looked around the web, but almost all the cases were about using the "reshape" command, which is not related to this code. I would appreciate your kind tips. The code is below:
clear all
set seed 10101
* Set the values of the parameters
global numobs = 150 /*numobs = sample size*/
global numsims = 1000 /*numsims = replication number*/
capture program drop my2sls
program my2sls, rclass
version 13
drop _all
set obs $numobs
tempvar x1 x2 x3 eps1 eps2 u1 u2 y1 y2
generate `x1' = runiform()
generate `x2' = runiform()
generate `x3' = runiform()
generate `eps1' = rnormal()
generate `eps2' = rnormal()
generate `u1' = 1.708*`eps1' + 1.404*`eps2'
generate `u2' = 1.732*`eps2'
generate `y1' = -1.412*`x1' - 0.588*`x2' - 2.118*`x3' - 0.588*`u1' - 0.882*`u2'
generate `y2' = -1.412*`x1' - 0.588*`x2' - 2.118*`x3' - 0.882*`u1' - 0.558*`u2'
ivregress 2sls `y2' (`y1' = `x2')
return scalar b1 = _b[`x1']
return scalar b2 = _b[`x2']
return scalar b3 = _b[`x3']
end
set matsize 11000
simulate b1=r(b1) b2=r(b2) b3=r(b3), reps($numsims) saving(results, replace) nolegend nodots: my2sls
use results, clear
summarize
Thanks in advance,
Homa
Comment