On Fri, 5 Dec 2003, Sabrina Russo 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)
>
If the predictor isn't already coded as a factor, use
sp.glm=glm(cohort$logreg~factor(cohort$hab), family=binomial)
This will give contrasts with the first level of the factor. A tidier way
to specify the same thing is
sp.glm <- glm(logreg~factor(hab), data=cohort, family=binomial)
-thomas
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help