# ¿How to compaire nested logit models using anova in R?

I have two logit models:

• Model A:
model_logit_house <- glm( health_status ~ sex + age + weight + study_level + chronic_ill +  laboral_situation +
sport_frec   + GHQ_12 + income_level +
n_bedrooms + indust_pollution +    delinquency, # study variables
data = model_data, family = binomial(link = "logit"),na.action = "na.omit")

• Model B (a nested model from Model A):
model_logit <- glm( health_status ~ sex + age + weight + study_level + chronic_ill +  laboral_situation +
sport_frec   + GHQ_12 + income_level +,
data = model_logit_house\$model, family = binomial(link = "logit"))


c(age,weight,GHQ_12,income_level) are continuous variables, the rest variables are cualitatives (factor).

I want to analyze if the housing characteristics (study variables) have influence on the health status. All variables are significant in both models. However, I want to do an analysis of variance (ANOVA) between these two models for to be sure that model A is better than model B. So:

anova(model_logit,model_logit_house) And the output is:

  Resid. Df Resid. Dev Df Deviance
1     16805      15439
2     16802      15420  3   18.644


How do I interpret this table? Can the interpretation of this table tell me if there is an influence between the housing characteristics and the health status? If not. How can I compaire these two models with an ANOVA in R?

The deviance terms you see in anova, is the binomial deviance, a sum of errors of the predictions. So if your model predicts better, then the deviance gets lower.

If you include some more terms, and the deviance decreases substantially, this suggest the variables have explanatory power or some association with the dependent variable. And you already saw that with the significant p-values for the coefficients.

You can test this using a likelihood ratio test, implemented under anova, I use a example dataset below:

data = iris
data$$Species=ifelse(data$$Species=="versicolor",1,0)
full_model = glm(Species ~ .,data=data,family=binomial)
red_model = glm(Species ~ Sepal.Width,data=data,family=binomial)

anova(red_model,full_model,test="Chisq")
Analysis of Deviance Table

Model 1: Species ~ Sepal.Width
Model 2: Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1       148     151.93
2       145     145.07  3   6.8562  0.07662 .


Essentially, if your included variables are significant under the Wald test(when you do summary(..)), then the likelihood ratio ratio should give a similar result. You can check more about this here.

• Then, looking the deviance difference from my models 18.664 and knowing that when I execute the Chi-square with anova this value is Pr(>Chi) = 0.0003 ¿Can we conclude that the study variables has explanatory power on the health-status? Apr 26, 2020 at 12:42
• Hi @JuanLuisAndiónTápiz, more or less yes. Apr 26, 2020 at 20:12