[R] More Logistic Regression Tools?

Frank E Harrell Jr fharrell at virginia.edu
Mon Oct 21 21:11:49 CEST 2002


On Mon, 21 Oct 2002 06:26:46 -0700
Eric Rescorla <ekr at rtfm.com> wrote:

> I've been using R to do logistic regresssion, and that's working
> well, but there are two things I haven't figured out how to do.
> 
> (1) Is there some pre-existing function that will let you compute the
>     odds ratios and confidence intervals for them for a specific fit. I know
>     how to do this manually or even write a function that I can call with
>     the coefficients and se, but extending the printing function was a
>     little more work than I expected.
> 
>     I.e. I'm looking for something where you'd type
>     odds.ratios(fit)
> 
>     and get:
> 
>     Coefficient		Odds ratio	95%	CI
>     XXX			5.2		1.5	7.2
>     
>     etc.
> 

library(Design)  # see hesweb1.med.virginia.edu/biostat/rms
d <- datadist(mydataframe); options(datadist='d') # defines data ranges etc.
f <- lrm(y ~ ....)
summary(f, age=c(21,65))
# 65:21 year OR (even if age is nonlinear)
# other continuous variables: use quartiles

See all the contrast function in Design.

> (2) I'd like to compute goodness-of-fit statistics for my fit
>     (Hosmer-Lemeshow, Pearson, etc.). I didn't see a package that
>     did this. Have I missed one?

Hosmer-Lemeshow has low power and relies on arbitrary binning of predicted probabilities.  The Hosmer-Le Cessie omnibus test is unique and has more power usually.  To get it:

f <- update(f, x=T, y=T)
resid(f, 'gof')  # uses residuals.lrm

Frank Harrell

> 
> Thanks,
> -Ekr
> 
>     
>     
>   
> 
> 	
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


-- 
Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list