Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: loop


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: loop
Date   Thu, 18 Dec 2003 18:08:47 -0000

Guesswork follows.

Nearby numbers could easily round to
different multiples of 0.000001.

Why not go with

local equal = (r(P_p1) - r(P_n0)) < 1e-6

Also, watch out for binary-decimal precision
issues. A power of 2 might be practical.

Nick
[email protected]

Hans J. Baumgartner
>
> I would like the prediction after a probit to be equal for 1 and 0
> classified.
> Thus, I have to adjust the cutoff(x). But which value should x have?
> The following loop should do the job, but somehow I have a
> problem with
> the rounding. I.e. the thing flips between the first two sub-loops.
> Can somebody help me on this?
>
> local cutoff = 0.33                         /* starting value */
> forvalue x = 1/100000 {
>     display `x'
>     qui lstat, cutoff(`cutoff')
>     local equal = round(r(P_p1),0.000001) -
> round(r(P_n0),000001)
> /* Sensitivity - Specificity */
>     display `equal'
>     if `equal' > 0 {
>         local cutoff = `cutoff' + 0.000001
>         display `cutoff'
>     }
>     else if `equal' < 0 {
>         local cutoff = `cutoff' - 0.000001
>         display `cutoff'
>     }
>
>     else if `equal' == round(0,0.000001) {
>         lstat, cutoff(`cuttoff')
>     }
> }
>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index