Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Saving intermediate results (variables) when running -simulate-


From   Rachel <academicgirl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Saving intermediate results (variables) when running -simulate-
Date   Wed, 22 Aug 2007 16:06:39 -0400

Hi Marteen,

I do want to save the dataset, which is randomly generated with each
repetition. So whether I use simulate or write my own simulation
program, I would have to loop.

Does simulate produce some sort of scalar that keeps track of the
number of repetitions that have been completed?  If so, I could
generate a new variable (i.e. gen x`i'=x where i is the repetition
number) for each covariate in each repetition.

Thanks,
Rachel

On 8/22/07, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
> --- Rachel <academicgirl@gmail.com> wrote:
> > I am using simulate to run a series of regressions and return the
> > coefficients and standard errors.  What's the easiest way to have
> > Stata save the values of the independent and the residuals for each
> > observation after each repetition?
>
> I am assuming you do not want to save the dataset but some coeficients.
> (If you want to save the dataset aswell it is better to just create one
> big dataset in one go and not loop over various randomly generated
> smaller datasets, which is essentially what -simulate- does.)
>
> what about this:
> *------------------ begin example -----------------
> capture program drop simprog
> program simprog, eclass
> drop _all
> set obs 1000
> gen x=uniform()
> drawnorm resid
> local beta=2
> gen y=`beta'*x+resid
> regress y x
> matrix b = e(b)
> matrix V = e(V)
> local rmse = e(rmse)
> ereturn post b V
> ereturn scalar rmse = `rmse'
> end
>
> simulate _b _se rmse=e(rmse), reps(20): simprog
> *------------------ end example -------------------
>
> Hope this helps,
> Maarten
>
>
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology
> Vrije Universiteit Amsterdam
> Boelelaan 1081
> 1081 HV Amsterdam
> The Netherlands
>
> visiting address:
> Buitenveldertselaan 3 (Metropolitan), room Z434
>
> +31 20 5986715
>
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
>
>
>       ___________________________________________________________
> Want ideas for reducing your carbon footprint? Visit Yahoo! For Good  http://uk.promotions.yahoo.com/forgood/environment.html
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index