Error:'no variables defined' in stata when using monte carlo simulation
问题 I have written the program below and keep getting the error message that my variables are not defined. Can somebody plese see where the error is and how I should adapt the code? Really nothing seems to work. program define myreg, rclass drop all set obs 200 gen x= 2*uniform() gen z = rnormal(0,1) gen e = (invnorm(uniform()))^2 e=e-r(mean) replace e=e-r(mean) more gen y = 1 + 1*x +1*z + 1*e reg y x z e=e-r(mean) replace e=e-r(mean) more gen y = 1 + 1*x +1*z + 1*e reg y x z more return scalar