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?

  • 9
    $\begingroup$ 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. $\endgroup$
    – caracal
    Nov 28 '12 at 10:32
  • 1
    $\begingroup$ 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. $\endgroup$ 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.


I have to say, I've been doing statistics for 10 years and I've never heard anyone call it Analysis of Deviance before. Where is that from? Just wondering, it is a logical title though of course "Analysis of Variance" is the more universal term, as the portmanteau ANOVA implies.

At any rate, the difference is that in the first ANOVA you were comparing two models (the probability of them being different) and in the second you did an ANOVA on one model to get the p-values of the terms in the model. If you want to know the significance of a particular term, then you're probably looking for the second choice.

Further, just FYI, there's never a need to calculate your own p-value. This ANOVA function gives it to you in the output (Pr > F) as do all the much more common ways of invoking ANOVA in R. Cheers.

  • 6
    $\begingroup$ 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)) $\endgroup$
    – trev
    Nov 14 '13 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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