Statalist


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

RE: st: Repeating a program


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: Repeating a program
Date   Thu, 11 Sep 2008 12:48:44 +0200

It is hard to see why you would not want to use -simulate- here. See the
bottom of -h simulate- for a helpful example. AFAIK, there is nothing in
there that would prevent you from changing the covariates for each run of
the -program- or from -summariz(e)-ing- predicted values. Let me illustrate
this with OLS, tune it to your -logit- command as you see fit.


   ******************
   cap pr drop sim
   
    pr def sim, rclass
        version 10.1
        drop _all
        set obs 10000
        tempvar y x1 x2 pred
        g `x1'=runiform()*2
        g `x2'=rchi2(4)
        gen `y' = 0.5+2*`x1'+4*`x2'+rnormal()
        reg `y' `x1' `x2'
        predict `pred'
        su `pred'
        ret sca mean = r(mean)
        ret sca Var  = r(Var)
    end

    simulate mean=r(mean) var=r(Var), reps(1000): sim
    
    su,d
    ******************

HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Maarten buis
Sent: Thursday, September 11, 2008 12:36 PM
To: [email protected]
Subject: Re: st: Repeating a program

--- On 9/11/08, Larraine Becker <[email protected]> wrote:
>>> I want to run a logit program 1000 times, outputting the predicted
>>> y values each time. I'm not sure how to go about this - I was
>>> I was thinking of doing a simulation, but before I submit the logit
>>> command, I also use a random number generator to randomly change
>>> variables in order to compare the predicted values each time.

-simulate- sounds appropriate for this kind of problem. The real trick
is to decide what it is that you want to store after each -logit-
command. I gave a tutorial on how to use -simulate- at Summer North
American stata Users meeting in Chicago, you can download the material
from here: http://ideas.repec.org/p/boc/nsug08/14.html (Also see
http://www.stata.com/statalist/archive/2008-08/msg01365.html on how to
view this material)

-- 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 N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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