1
$\begingroup$

I am using the Titanic dataset to understand glm model. These are the two models,

titanic.glm       <- glm(survived ~ pclass,         family=binomial, data=titanic.train)
titanic.glm.title <- glm(survived ~ pclass + title, family=binomial, data=titanic.train)

I have two summaries. Since it has categorical variables, I am not able to interpret it properly and compare it. Can anybody help me in comparing both the models and find out which one is better? following is the summaries of both the models,

> summary(titanic.glm)

Call:
glm(formula = survived ~ pclass, family = binomial, data = titanic.train)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3652  -0.7779  -0.7779   1.0006   1.6388  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)   0.4313     0.1272   3.391 0.000696 ***
pclass2      -0.7086     0.1852  -3.826 0.000130 ***
pclass3      -1.4715     0.1593  -9.237  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1393.6  on 1046  degrees of freedom
Residual deviance: 1301.5  on 1044  degrees of freedom
AIC: 1307.5

Number of Fisher Scoring iterations: 4

> summary(titanic.glm.title)

Call:
glm(formula = survived ~ pclass + title, family = binomial, data = titanic.train)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.2066  -0.6462  -0.4263   0.6521   2.2106  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept)    1.5336     0.3356   4.570 4.88e-06 ***
pclass2       -0.9028     0.2259  -3.997 6.41e-05 ***
pclass3       -1.7950     0.2037  -8.814  < 2e-16 ***
titleMiss      0.4701     0.3207   1.466 0.142706    
titleMr.      -2.0911     0.3131  -6.679 2.40e-11 ***
titleMrs.      0.8092     0.3507   2.308 0.021011 *  
titleNothing  -1.7024     0.5157  -3.301 0.000964 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1393.58  on 1046  degrees of freedom
Residual deviance:  990.66  on 1040  degrees of freedom
AIC: 1004.7

Number of Fisher Scoring iterations: 4

I tried the following,

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

Analysis of Deviance Table

Model 1: survived ~ pclass
Model 2: survived ~ pclass + title
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      1044    1301.47                          
2      1040     990.66  4   310.81 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I am not able to compare both the models. I read somewhere AIC is one of the parameter to compare it. Can anybody help in comparing both the models and decide which one is better? Also how can we find whether a particular model is stable or not?

$\endgroup$

1 Answer 1

1
$\begingroup$

Your models are nested; the former model differs from the latter only by lacking a term (title). Thus, it is possible and appropriate to test them against each other. (That is what your anova() call did.) The nested model test is a test of the variable that differs between the two models. That is, the test is telling you that title is significant.

$\endgroup$
2
  • $\begingroup$ I am not sure what to infer from the anova model. Can you please let me know what to infer from that? $\endgroup$
    – haimen
    Commented Dec 7, 2015 at 7:33
  • $\begingroup$ @haimen, you can infer that title is significant. And by extension, that the latter model is better. $\endgroup$ Commented Dec 7, 2015 at 12:26

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.