Statalist


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

st: RE: AW: AW: simulate using lroc


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: AW: AW: simulate using lroc
Date   Thu, 3 Sep 2009 18:11:40 +0100

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/



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