Statalist


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

Re: st: RE: AW: AW: simulate using lroc


From   Andrzej Niemierko <[email protected]>
To   Stata <[email protected]>
Subject   Re: st: RE: AW: AW: simulate using lroc
Date   Thu, 03 Sep 2009 14:12:47 -0400

Thank you Nick and Martin. Your comments were very helpful, and both your
approaches worked perfectly.
Andrzej

PS. Martin, I didn't call my program "prog" or my variables "y" and "x", it
just made it that way in my email. :-)



On 9/3/09 1:11 PM, "Nick Cox" <[email protected]> wrote:

> Note that baton changing is not necessary.
> 
> (In the original, -lroc- passed a r(class) result to -myprog- which
> passed it to -simulate-. However, if -myprog- is not made r(class) the
> result needed will be lying around when -myprog- has finished.)
> 
> clear*
> set obs 1000
> 
> //covariates
> gen x1=rchi2(2)  
> gen x2=rnormal() 
> gen x3=runiform()
> 
> //DGP
> gen y=runiform()< /*
>  */ invlogit(1+0.3*x1+ /*
>  */ 0.6*x2+0.5*x3)
> 
> 
> program define myprog
>     preserve
>     bsample 1000
>         logistic y x1 x2 x3
>         qui lroc, nograph
>         restore
> end
> 
> simulate roc=r(area),  /*
>  */ reps(100): myprog
> 
> 
> list, noobs
> 
> Nick 
> [email protected]
> 
> Martin Weiss
> 
> BTW, -bsample- has no mandatory arguments, so it is your prerogative no
> to
> supply any, but it does not have any effect, then...
> 
> Martin Weiss
> 
> You also asked Stata for "r(area)", although your "prog" returns
> "r(roc)"...
> 
> Here is a possible solution:
> 
> ******
> capt pr drop myprog
> 
> clear*
> set obs 1000
> 
> //covariates
> gen x1=rchi2(2)  
> gen x2=rnormal() 
> gen x3=runiform()
> 
> //DGP
> gen y=runiform()< /*
>  */ invlogit(1+0.3*x1+ /*
>  */ 0.6*x2+0.5*x3)
> 
> 
> program define myprog, rclass
>     preserve
>     bsample 1000
>         logistic y x1 x2 x3
>         qui lroc, nograph
>         return scalar roc=r(area)
>     restore
> end
> 
> simulate roc=r(roc),  /*
>  */ reps(100): myprog
> 
> 
> list, noobs
> 
> Andrzej Niemierko
> 
> What's the reason that the below -simulate command creates all missing
> values for the scalar roc? Also, is it possible to suppress plotting of
> the
> ROC curves after each -lroc?
> 
> program define prog, rclass
>     preserve
>     bsample
>         logistic y x1 x2 x3
>         lroc
>         return scalar roc=r(area)
>     restore
> end
> 
> simulate roc=r(area), reps(100): prog
> 
> 
> *
> *   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/



The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

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