2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Could you add some more context to your description? What other questions do you want to ask of your data? $\endgroup$ Commented Oct 17, 2013 at 20:17

2 Answers 2

2
$\begingroup$

One thing you can do is to exclude the constant and main effects from your model and don't leave out the reference categories. That way the coefficients will be the (adjusted) log odds, and the test commonly reported next to the coefficients will be the test you are looking for. I wrote a brief discussion on that trick for Stata here. I don't know enough about R to tell you which commands to type, but I am certain one can also do it R.

$\endgroup$
1
  • $\begingroup$ This is a great trick! It actually (I think) does exactly what changing the reference level does, but without the hassle of having to change the reference levels multiple times for each condition/category. Thanks! $\endgroup$
    – Alex
    Commented Oct 18, 2013 at 8:40
0
$\begingroup$

Try running ANOVA on your model, e.g.

anova(glm(...),test="Chisq")

The drop1, add1 and step functions might also be useful.

http://data.princeton.edu/R/glms.html

$\endgroup$
1
  • $\begingroup$ My main questions (the two in bold) cannot be addressed using anova(). I want to see whether the log-odds in each of the conditions is significantly different from 0. $\endgroup$
    – Alex
    Commented Oct 18, 2013 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.