For the recent General Social Survey data on X = gender (males, females) and Y = belief in an afterlife (no, yes), Table 7.12 shows results of fitting the independence loglinear model.
a. The deviance is 0.82 with df = 1. What does this suggest? Deviance is the test statistics for chi-square test of goodness of fit.
1-pchisq(0.82,1)
## [1] 0.3651802
0.365>0.5, we fail to reject the null hypothesis that the model is a good model of the goodness of fit test.
b. Report {\(\hatλ_j^y\) }. Interpret \(\hatλ_1^y\) − \(\hatλ_2^y\)
exp(1.4165)
## [1] 4.122666
The estimated odd of belief in afterlife is 4.12 for each level of gender
c. For the saturated model, software reports for \(\hatλ_{ij}^{xy}\)
Estimate the odds ratio.
exp(0.1368)
## [1] 1.146599
The estimated odd ratio is 1.147 for female who belief in haven to female who don’t b
d. The text website has a data file Postlife that cross-classifies belief in life after death with race (black, white, other). Fit the independence model and interpret {\(\hatλ_j^y\) }
fit<-read.table("http://users.stat.ufl.edu/~aa/cat/data/Postlife.dat",header=TRUE)
fit<-glm(formula = count ~ race + postlife, data = fit, family = poisson)
summary(fit)
##
## Call:
## glm(formula = count ~ race + postlife, family = poisson, data = fit)
##
## Deviance Residuals:
## 1 2 3 4 5 6
## 0.15781 -0.33688 -0.01717 0.03631 -0.20194 0.41917
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 4.05242 0.07309 55.44 <2e-16 ***
## raceother -1.05209 0.11075 -9.50 <2e-16 ***
## racewhite 1.64927 0.06152 26.81 <2e-16 ***
## postlifeyes 1.49846 0.05697 26.30 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 2849.21758 on 5 degrees of freedom
## Residual deviance: 0.35649 on 2 degrees of freedom
## AIC: 49.437
##
## Number of Fisher Scoring iterations: 3
1-pchisq(0.356,2)
## [1] 0.8369424
exp(1.49846)
## [1] 4.474793
Goodness of fit: deviance=0.356 and p -value is 0.8 which is >0.05. We accept the h0 that the model is a good fit.
The estimated odd of belief in afterlife is 4.47 for each level of gender.