Skip to main content
3 of 4
fixed stray word in title, capitalized, added "?"
Glen_b
  • 290.4k
  • 37
  • 652
  • 1.1k

Logistic regression with categorical predictors, do log-odds differ from 0?

(My title is probably not very clear, but I don't know how to state it more clearly. So feel free to edit it. Thanks!)

I have a 3 by 2 design, with a total of 6 conditions. The outcome is binary (0 or 1). Below is a sample dataset generated in R:

set.seed(2)
mockdata<-data.frame(outcome=sample(1:0, 48, prob=c(0.5, 0.5), replace=TRUE),
                     f1=rep(letters[1:2], each=24), 
                     f2=rep(letters[1:3], each=8))

head(mockdata)
#  outcome f1 f2
#1       0  a  a
#2       1  a  a
#3       1  a  a
#4       0  a  a
#5       1  a  a
#6       1  a  a

One of the things I would like to look at is whether the log-odds of the outcome for each of the 6 conditions is significantly different from 0. I can create a new condition variable as follows:

mockdata$f12 <- paste(mockdata$f1, mockdata$f2, sep=".")

then, I can do logistic regression using the newly created variable (see below for output). The intercept below tells me that for the condition that is treated as the baseline condition, the log-odds is not significant different 0.

My questions are:

(1). to check the other conditions, should I simply change the baseline condition, and after testing all 6 conditions, I adjust the p-values accordingly?

(2). Are there better ways of testing what I want to test?

summary(glm(outcome ~f12, family="binomial", data=mockdata))

Call:
glm(formula = outcome ~ f12, family = "binomial", data = mockdata)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.6651  -1.1774  -0.5168   1.0215   2.0393  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)  
(Intercept)  -0.1412     0.3281  -0.430   0.6669  
f121          0.6520     0.6806   0.958   0.3380  
f122          0.1412     0.6641   0.213   0.8316  
f123         -0.3696     0.6806  -0.543   0.5871  
f124         -1.8047     0.9325  -1.935   0.0530 .
f125          1.2398     0.7430   1.669   0.0952 .
---

EDIT

I would also like to check how the log-odds differ amongst the different conditions. For that, I was gonna just run a regular logistic regression with the main effects of f1 and f2, and the interaction of the two, and conduct additional multiple comparisons dependent on the kind of result I get from the omnibus test.

Alex
  • 467
  • 1
  • 5
  • 15