[R] Odds ratios in logistic regression models with interaction

Laviolette, Michael Michael.Laviolette at dhhs.nh.gov
Thu Aug 4 16:24:35 CEST 2016


Thanks. I ended up doing it as a contrast directly from the covariance matrix. There's probably a package that provides a better way, maybe the "contrast" package. For now, this works.

a <- 25   # age
# contrast for estimating OR's for given age
d <- c(1, 1, a, a) - c(1, 0, a, 0)
# estimate of log OR with standard error 
est.ln.or <- crossprod(coef(fit3.14c), d)
se.ln.or <- sqrt(t(d) %*% vcov(fit3.14c) %*% d)
# exponentiate for OR and CI
est.or <- exp(est.ln.or)
lci.or <- exp(est.ln.or - 1.96 * se.ln.or)
uci.or <- exp(est.ln.or + 1.96 * se.ln.or)


-----Original Message-----
From: Michael Dewey [mailto:lists at dewey.myzen.co.uk] 
Sent: Thursday, August 04, 2016 8:32 AM
To: Laviolette, Michael; r-help at r-project.org
Subject: Re: [R] Odds ratios in logistic regression models with interaction

Laviolette, Michael <Michael.Laviolette at dhhs.nh.gov> wrote :

> I'm trying to reproduce some results from Hosmer & Lemeshow's "Applied 
> Logistic Regression" second edition, pp. 74-79. The objective is to 
> estimate odds ratios for low weight births with interaction between 
> mother's age and weight (dichotomized at 110 lb.). I can get the point 
> estimates, but I can't find an interval option. Can anyone provide 
> guidance on computing the confidence intervals?

There is always confint. Not sure if you need MASS first from memory, not got a copy of R running to hand.


 Thanks. -Mike L.
> 
> library(dplyr)
> data(birthwt, package = "MASS")
> birthwt %
>   mutate(low = factor(low, 0:1, c("Not low", "Low")),
>          lwd = cut(lwt, c(0, 110, Inf), right = FALSE,
>                    labels = c("Less than 110", "At least 110")),
>          lwd = relevel(lwd, "At least 110"))
> 
> # p. 77, Table 3.16, Model 3
> fit3.16



More information about the R-help mailing list