# Analysis of Deviance in R - Which test?

I have two generalized linear models mod1 and mod2.

mod1 <- glm(Score ~ Height + Gene, data=mydata, family=binomial)

mod2 <- glm(Score ~ Height * Gene, data=mydata, family=binomial)


I want to perform an analysis of deviance to test the significance of the interaction term.

At first I did anova(mod1,mod2), and I used the function 1 - pchisq() to obtain a p-value for the deviance result I got from the anova table.

I also did another test: anova(mod2, test="Chisq"). This gave a table for all the terms added sequentially first to last, and I obtained a very different p-value value for the interaction term Height:Gene...

Which one should I use?

• anova(mod1, mod2, test="Chisq") and anova(mod2, test="Chisq") should give identical results for the interaction term. Note that you don't have to manually calculate a p-value in the first case. Without the actual data / minimal example, it's hard to see what's going on. Nov 28 '12 at 10:32
• If you want a better diagnosis of what went wrong you could edit the question and add the full input and output of the two tests you did. The key is how you moved from anova(mod1, mod2) to a chi square test. Nov 29 '12 at 8:59

As @caracal points out, anova(mod2,test="Chisq") should return the desired test. We can't tell what went wrong with 1-pchisq() as we don't know what you put inside the brackets; but one guess would be that you accidentally tested for the significance of all explanatory variables in the model together.
• Analysis of deviance is applied to generalized linear models (McCullagh and Nelder, 1989). anova() deals with both types of analyses, see the help page. The deviance is -2 times the log-likelihood ratio (en.wikipedia.org/wiki/Deviance_(statistics))