Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Saving simulation runs

From   John Antonakis <[email protected]>
To   [email protected]
Subject   Re: st: RE: Saving simulation runs
Date   Mon, 11 Oct 2010 09:15:31 +0200


Right....I was playing around with the regression model and matrixes prior to writing the simulate code and did not realize my mistake (i.e, the first time I ran simulate it was pulling up the previous regression results; after revisting the code later it did not work, DUH!), which Stas nicely pointed to me.



Prof. John Antonakis, Associate Dean
Faculty of Business and Economics (HEC)
Department of Organizational Behavior
University of Lausanne
Internef #618
CH-1015 Lausanne-Dorigny

Tel ++41 (0)21 692-3438
Fax ++41 (0)21 692-3305

Home page:

On 10.10.2010 18:16, Nick Cox wrote:
This looks confused to me.

What e(b) are you expecting to be lying around after -simulate-? It seems to me that at most you could expect just the _last_ e(b) from the -regress- within your -sim- that -simulate- is calling, i.e. in this example just the 100th of 100 calls. The other 99 incarnations of e(b) will have disappeared.

As to why this is no longer working, my wild guess is that you seeing a consequence of the change to -clear- in 11.0, which is documented in -help whatsnew10to11- and [U] 1.3.

In fact I doubt that this ever worked as you intended; it just gave results that looked OK to you. One key aim of -simulate- is to manage storage of results; it's not necessary to do much management yourself.

Re-reading the help for -simulate- is one possibility.

[email protected]

John Antonakis

My code here, which seemed to work fine before, stopped working (I am
sure that I did not change it, though can't find anything wrong with it).

capture program drop sim
   version 11.1
program define sim, rclass
          drop _all
syntax , nobs(integer )
set obs `nobs'

gen x1 = rnormal()
gen x2 = 2*x1 + .1*rnormal()
gen y = x1 + x2 + rnormal()
reg y x1 x2

mat b=e(b)
mat save = b

foreach nobs of numlist 100(100)1000 {
simulate _b _se, reps(100) seed (123) : sim, nobs(`nobs')
mat b=e(b)
mat save = save \ b

mat list save

Also, how would I save the mean of the standard errors, along with the
mean of the coefficients, from each of the monte carlo runs?

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index