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

st: loop


From   "Hans J. Baumgartner" <[email protected]>
To   statalist <[email protected]>
Subject   st: loop
Date   Thu, 18 Dec 2003 18:54:58 +0100

Dear statalisters,

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')
}
}

Many thanks
Hans

--
Hans J. Baumgartner DIW Berlin
Deutsches Institut f�r Wirtschaftsforschung
German Institute for Economic Research
Abt. Staat / Dept. Public Economics
K�nigin-Luise-Str. 5; 14195 Berlin; Germany Tel.: +49/30/89789-307; Fax.: +49/30/89789-114
http://www.diw.de
http://www.hansbaumgartner.de



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