Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: looping with tolerance level


From   Andres Silva <[email protected]>
To   [email protected]
Subject   st: looping with tolerance level
Date   Fri, 7 Sep 2012 15:27:43 +0200

Dear Stata Users,

I want to do a loop per observation with a tolerance level. In concrete, I
want to increase the payment (k) until I get a probability (prob) close to 0.5

program med, rclass
set trace on
forvalues j=1/33         {/* looping across observations*/
forvalues k=1/1          {/* looping across level of payment starting from 1*/
scalar prob`j'_`k'=(probability expression including `j' and `k')
scalar tolerance=abs(0.5-prob`j'_`k')

if tolerance<=0.001 {continue} else {k=`k'+1}
}
}

end
med

However, line 4 and 8 are causing me problems. I appreciate any advice.
Thank you,

Andres
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index