Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • where does -simulate- save the returned results each time?

    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





  • #2
    -simulate- use the -postfile- mechanism to store the results as it goes along. So, while -simulate- is running, results are being accumulated in a temporary file, with your original data retained in active memory. After all 10,000 replications are finished, that temporary file is read into active memory, replacing the original data.

    Comment


    • #3
      I see, and thanks a lot!

      Comment

      Working...
      X