|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: loops
Hi,
I am dealing with huge datasets for which I have to estimate
percentile exposure time within two to three subsets. I noticed
something that happened there and tried duplicating it with a stata
example dataset [webuse beetle] and I noticed it again. Attached
below is the do file modified for beetle dataset.
/* Stata/IC 10.0 for Macintosh */
/* Do file to assess LD10-90 for beetle.dta */
/* Obtain beetle from webuse beetle */
use ~/desktop/beetle.dta
gen p=r/n
forvalues i=1/3 {
glm p ldose if beetle==`i', f(b)
forvalues j=0.1(0.1)0.9 {
local k=`j'*100
display as text "LD `k' = " as result (log(`j'/(1-`j'))-_b[_cons])/_b
[ldose]
}
}
A part of the result for beetle.dta looks like this...
Generalized linear models No. of obs
= 8
Optimization : ML Residual df
= 6
Scale parameter
= 1
Deviance = .4046285206 (1/df) Deviance
= .0674381
Pearson = .3998784961 (1/df) Pearson
= .0666464
Variance function: V(u) = u*(1-u/1) [Binomial]
Link function : g(u) = ln(u/(1-u)) [Logit]
AIC
= 1.029287
Log likelihood = -2.117148142 BIC =
-12.07202
------------------------------------------------------------------------
------
| OIM
p | Coef. Std. Err. z P>|z| [95% Conf.
Interval]
-------------
+----------------------------------------------------------------
ldose | 36.74959 24.12731 1.52 0.128
-10.53907 84.03825
_cons | -65.29355 43.00475 -1.52 0.129
-149.5813 18.99422
------------------------------------------------------------------------
------
LD 10 = 1.7169257
LD 20 = 1.7389921
LD 30 = 1.7536588
LD 40 = 1.7656816
LD 50 = 1.7767148
LD 60 = 1.787748
LD 70 = 1.7997708
LD 80 = 1.8144375
LD 89.99999999999999 = 1.8365039
Why is this last LD 90 showing as 89.99... ... . Am I doing something
odd (bad math) in the do file?
Thanks,
A
Arun Rajamohan
Department of Biology
University of Western Ontario
London, Ontario N6A 5B7, CANADA.
519 661 2111 80582
*
* 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/