[R] Odds ratios for categorical variable

Frank E Harrell Jr feh3k at spamcop.net
Fri Dec 5 20:23:40 CET 2003


On Fri, 05 Dec 2003 14:00:05 -0500
Sabrina Russo <srusso at oeb.harvard.edu> wrote:

> Dear R-users:
> How does one calculate in R  the odds ratios for a CATEGORICAL predictor
> 
> variable that has 4 levels.  I see r-help inquiries regarding odds
> ratios for what looked like a continuous predictor variable.  I was
> wondering how to get the pairwise odds ratios for comparisons of levels
> of a categorical predictor variable.  I can't seem to get the correct
> output using:
>  > sp.glm=glm(cohort$logreg~cohort$hab, family=binomial)
>  > summary(sp.glm)
> 
> This gives me the coefficient for the effect of hab overall, but not the
> 
> coefficients for the comparisons of each of the levels. I suspect this
> has something to do with the contrasts statement, but I can't figure it
> out, and would be very appreciative of any help you can provide.
> Thank you,
> Sabrina
> 
> ______________________________________________________________
> Sabrina E. Russo
> Postdoctoral Fellow
> Center for Tropical Forest Science - Arnold Arboretum Asia Program
> Harvard University
> 22 Divinity Avenue
> Cambridge, MA 02138 USA
> 
> 617-496-2380 phone
> 617-495-9484 FAX
> srusso at oeb.harvard.edu
> 

library(Design)
f <- lrm(. . .)
summary(f)
---
Frank E Harrell Jr    Professor and Chair            School of Medicine
                      Department of Biostatistics    Vanderbilt University




More information about the R-help mailing list