Dear Statalist,

I have questions regarding the way that the command -simulation- runs the pre-defined the program. I use the Example 2 in the Stata documentation of -simulate- which can be found here https://www.stata.com/manuals13/rsimulate.pdf. In this example, Monte-Carlo simulations are implemented to get 10000 observations of estimated parameters and corresponding standard error.

Code:
drop _all
set obs 100 
set seed 54321
gen x = rnormal()
gen true_y = 1+2*x
save truth file truth.dta saved

program hetero2
version 13
args c
capture drop y
gen y = true_y + (rnormal() + ‘c’*x)
regress y x
end

simulate _b _se, reps(10000): hetero2 3
When simulating hetero2, the data in memory consists of x, true_y and y. I am curious where the result of the reg y x goes each time and when the data in-memory changes from 100 xs, true_ys and ys to 10000 _bs _ses?

Kind regards,
Yugen