library(foreign)
library(Zelig)
library(memisc)
library(magrittr)
options(digits=3)
nes1948.por <- UnZip("anes/NES1948.ZIP","NES1948.POR", package="memisc")
nes1948 <- spss.portable.file(nes1948.por)
print(nes1948)
##
## SPSS portable file 'C:/Users/Max/AppData/Local/Temp/Rtmp65dVrn/NES1948.POR'
## with 67 variables and 662 observations
dim(nes1948)
## [1] 662 67
library(plyr)
vote.48 <- subset(nes1948, select=c(v480018, v480029, v480030, v480045, v480046, v480047, v480048, v480049, v480050))
str(vote.48)
## Data set with 662 obs. of 9 variables:
## $ v480018: Nmnl. item w/ 7 labels for 1,2,3,... + ms.v. num 1 2 1 2 1 2 2 1 2 1 ...
## $ v480029: Nmnl. item w/ 12 labels for 10,20,30,... + ms.v. num 70 30 40 10 10 20 80 80 40 40 ...
## $ v480030: Nmnl. item w/ 4 labels for 1,2,8,... + ms.v. num 1 2 2 2 2 2 2 2 1 1 ...
## $ v480045: Nmnl. item w/ 3 labels for 1,2,9 + ms.v. num 1 2 2 2 1 2 1 2 1 1 ...
## $ v480046: Nmnl. item w/ 4 labels for 1,2,3,... + ms.v. num 1 1 1 1 1 1 1 1 1 1 ...
## $ v480047: Nmnl. item w/ 7 labels for 1,2,3,... + ms.v. num 3 3 2 3 2 3 4 5 2 2 ...
## $ v480048: Nmnl. item w/ 4 labels for 1,2,3,... + ms.v. num 1 2 2 3 3 2 1 1 2 2 ...
## $ v480049: Nmnl. item w/ 8 labels for 1,2,3,... + ms.v. num 4 7 5 7 5 7 5 2 5 6 ...
## $ v480050: Nmnl. item w/ 6 labels for 1,2,3,... + ms.v. num 1 1 2 1 2 1 1 1 1 2 ...
vote.48 <- rename(vote.48,
c(v480018="vote",
v480029="occu",
v480030="union",
v480045="gender",
v480046="race",
v480047="age",
v480048="edu",
v480049="income",
v480050="relig"
))
str(vote.48)
## Data set with 662 obs. of 9 variables:
## $ vote : Nmnl. item w/ 7 labels for 1,2,3,... + ms.v. num 1 2 1 2 1 2 2 1 2 1 ...
## $ occu : Nmnl. item w/ 12 labels for 10,20,30,... + ms.v. num 70 30 40 10 10 20 80 80 40 40 ...
## $ union : Nmnl. item w/ 4 labels for 1,2,8,... + ms.v. num 1 2 2 2 2 2 2 2 1 1 ...
## $ gender: Nmnl. item w/ 3 labels for 1,2,9 + ms.v. num 1 2 2 2 1 2 1 2 1 1 ...
## $ race : Nmnl. item w/ 4 labels for 1,2,3,... + ms.v. num 1 1 1 1 1 1 1 1 1 1 ...
## $ age : Nmnl. item w/ 7 labels for 1,2,3,... + ms.v. num 3 3 2 3 2 3 4 5 2 2 ...
## $ edu : Nmnl. item w/ 4 labels for 1,2,3,... + ms.v. num 1 2 2 3 3 2 1 1 2 2 ...
## $ income: Nmnl. item w/ 8 labels for 1,2,3,... + ms.v. num 4 7 5 7 5 7 5 2 5 6 ...
## $ relig : Nmnl. item w/ 6 labels for 1,2,3,... + ms.v. num 1 1 2 1 2 1 1 1 1 2 ...
attach(vote.48)
vote.48$voteGroup[vote==1] <- 1
vote.48$voteGroup[vote==2] <- 2
vote.48$voteGroup[(vote >= 3) & (vote <=4)] <- 3
detach(vote.48)
voteType <- c("Truman", "Dewey", "Other")
vote.48$voteGroup <-factor(vote.48$voteGroup, labels = voteType)
summary(vote.48$voteGroup)
## Truman Dewey Other NA's
## 212 178 12 260
attach(vote.48)
vote.48$occuGroup[occu==10] <- 1
vote.48$occuGroup[occu==20] <- 1
vote.48$occuGroup[occu==30] <- 2
vote.48$occuGroup[(occu >= 40) & (occu <= 70)] <- 3
vote.48$occuGroup[occu==80] <- 4
detach(vote.48)
occuType <- c(" Upper White collar ", " Other white collar ", " Blue collar ", " Farmer ")
vote.48$occuGroup <-factor(vote.48$occuGroup, labels = occuType)
summary(vote.48$occuGroup)
## Upper White collar Other white collar Blue collar
## 117 79 255
## Farmer NA's
## 105 106
attach(vote.48)
vote.48$reliGroup[relig==1] <- 1
vote.48$reliGroup[relig==2] <- 2
vote.48$reliGroup[(relig >=3) & (relig <=5)] <- 3
detach(vote.48)
reliType <- c(" Protestant ", " Catholic ", " Other, none ")
vote.48$reliGroup <-factor(vote.48$reliGroup, labels = reliType)
summary(vote.48$reliGroup)
## Protestant Catholic Other, none NA's
## 460 140 57 5
attach(vote.48)
vote.48$raceGroup[race==1] <- 1
vote.48$raceGroup[race==2] <- 2
detach(vote.48)
raceType <- c("White", "Black")
vote.48$raceGroup <-factor(vote.48$raceGroup, labels = raceType)
summary(vote.48$raceGroup)
## White Black NA's
## 585 60 17
attach(vote.48)
vote.48$incGroup[income ==1] <- 1
vote.48$incGroup[income ==2] <- 2
vote.48$incGroup[income ==3] <- 3
vote.48$incGroup[income ==4] <- 4
vote.48$incGroup[income ==5] <- 5
vote.48$incGroup[income ==6] <- 6
vote.48$incGroup[income ==7] <- 7
detach(vote.48)
incType <-c("Under$500","$500~$999","$1000~$1999","$2000~$2999","$3000~$3999","$4000~$4999","$5000 and more")
vote.48$incGroup <-factor(vote.48$incGroup, labels = incType)
summary(vote.48$incGroup)
## Under$500 $500~$999 $1000~$1999 $2000~$2999 $3000~$3999
## 25 43 110 185 142
## $4000~$4999 $5000 and more NA's
## 66 84 7
attach(vote.48)
table(voteGroup, occuGroup)
## occuGroup
## voteGroup Upper White collar Other white collar Blue collar Farmer
## Truman 17 30 114 26
## Dewey 67 31 36 14
## Other 2 0 4 3
detach(vote.48)
library(DescTools)
library(plyr)
library(dplyr)
library(stargazer)
options(digits=3)
attach(vote.48)
t.mod1 <- table(voteGroup, occuGroup)
N <- colSums(t.mod1, na.rm =FALSE, dims =1)
t.mod2<-table(occuGroup, voteGroup)%>%prop.table( margin=1)*100
tab1<-cbind(t.mod2, N) %>%stargazer(digits=1, title="2) Percentage Table of Occpation Class", type ="html")
| Truman | Dewey | Other | N | |
| Upper White collar | 19.8 | 77.9 | 2.3 | 86 |
| Other white collar | 49.2 | 50.8 | 0 | 61 |
| Blue collar | 74.0 | 23.4 | 2.6 | 154 |
| Farmer | 60.5 | 32.6 | 7.0 | 43 |
t.mod3<-table(voteGroup, reliGroup)
N <- colSums(t.mod3, na.rm =FALSE, dims =1)
t.relivote <-table(reliGroup, voteGroup)%>%prop.table(margin=1)*100
tab2 <-cbind(t.relivote, N)
stargazer(tab2, digits =1, title="3) Percentage Table of reglion Group", type="html")
| Truman | Dewey | Other | N | |
| Protestant | 44.7 | 51.0 | 4.3 | 255 |
| Catholic | 66.0 | 34.0 | 0 | 103 |
| Other, none | 68.2 | 29.5 | 2.3 | 44 |
t.mod4 <-table(voteGroup, raceGroup)
N <- colSums(t.mod4, na.rm=FALSE, dims =1)
t.racevote <-table(raceGroup, voteGroup) %>%prop.table( margin=1)*100
tab3 <-cbind(t.racevote, N)
stargazer(tab3, digits =1,title="4) Percentage Table of Race Group", type="html")
| Truman | Dewey | Other | N | |
| White | 51.3 | 45.5 | 3.2 | 376 |
| Black | 64.7 | 35.3 | 0 | 17 |
t.mod5 <-table(voteGroup, incGroup)
N <- colSums(t.mod5, na.rm=FALSE, dims=1)
t.incvote <-table(incGroup, voteGroup) %>%prop.table( margin=1)*100
tab4 <-cbind(t.incvote, N)
stargazer(tab4, digits=1, title="5) Percentage Table of Income Class", column.labels = c("Truman", "Dewey", "Other", "N"), column.separate = c(5, 3,3,3),rownames = FALSE, type="html")
| Truman | Dewey | Other | N |
| 50 | 50 | 0 | 8 |
| 61.5 | 38.5 | 0 | 13 |
| 64.4 | 32.2 | 3.4 | 59 |
| 67.0 | 30.1 | 2.9 | 103 |
| 47.5 | 48.5 | 4.0 | 101 |
| 45.8 | 50 | 4.2 | 48 |
| 31.8 | 68.2 | 0 | 66 |
detach(vote.48)
tab4
## Truman Dewey Other N
## Under$500 50.0 50.0 0.00 8
## $500~$999 61.5 38.5 0.00 13
## $1000~$1999 64.4 32.2 3.39 59
## $2000~$2999 67.0 30.1 2.91 103
## $3000~$3999 47.5 48.5 3.96 101
## $4000~$4999 45.8 50.0 4.17 48
## $5000 and more 31.8 68.2 0.00 66
library(gmodels)
CrossTable(vote.48$occuGroup, vote.48$voteGroup)
##
##
## Cell Contents
## |-------------------------|
## | N |
## | Chi-square contribution |
## | N / Row Total |
## | N / Col Total |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 344
##
##
## | vote.48$voteGroup
## vote.48$occuGroup | Truman | Dewey | Other | Row Total |
## ---------------------|-----------|-----------|-----------|-----------|
## Upper White collar | 17 | 67 | 2 | 86 |
## | 18.932 | 24.324 | 0.028 | |
## | 0.198 | 0.779 | 0.023 | 0.250 |
## | 0.091 | 0.453 | 0.222 | |
## | 0.049 | 0.195 | 0.006 | |
## ---------------------|-----------|-----------|-----------|-----------|
## Other white collar | 30 | 31 | 0 | 61 |
## | 0.301 | 0.862 | 1.596 | |
## | 0.492 | 0.508 | 0.000 | 0.177 |
## | 0.160 | 0.209 | 0.000 | |
## | 0.087 | 0.090 | 0.000 | |
## ---------------------|-----------|-----------|-----------|-----------|
## Blue collar | 114 | 36 | 4 | 154 |
## | 10.956 | 13.816 | 0.000 | |
## | 0.740 | 0.234 | 0.026 | 0.448 |
## | 0.610 | 0.243 | 0.444 | |
## | 0.331 | 0.105 | 0.012 | |
## ---------------------|-----------|-----------|-----------|-----------|
## Farmer | 26 | 14 | 3 | 43 |
## | 0.295 | 1.095 | 3.125 | |
## | 0.605 | 0.326 | 0.070 | 0.125 |
## | 0.139 | 0.095 | 0.333 | |
## | 0.076 | 0.041 | 0.009 | |
## ---------------------|-----------|-----------|-----------|-----------|
## Column Total | 187 | 148 | 9 | 344 |
## | 0.544 | 0.430 | 0.026 | |
## ---------------------|-----------|-----------|-----------|-----------|
##
##
CrossTable(vote.48$raceGroup, vote.48$voteGroup)
##
##
## Cell Contents
## |-------------------------|
## | N |
## | Chi-square contribution |
## | N / Row Total |
## | N / Col Total |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 393
##
##
## | vote.48$voteGroup
## vote.48$raceGroup | Truman | Dewey | Other | Row Total |
## ------------------|-----------|-----------|-----------|-----------|
## White | 193 | 171 | 12 | 376 |
## | 0.024 | 0.016 | 0.023 | |
## | 0.513 | 0.455 | 0.032 | 0.957 |
## | 0.946 | 0.966 | 1.000 | |
## | 0.491 | 0.435 | 0.031 | |
## ------------------|-----------|-----------|-----------|-----------|
## Black | 11 | 6 | 0 | 17 |
## | 0.536 | 0.358 | 0.519 | |
## | 0.647 | 0.353 | 0.000 | 0.043 |
## | 0.054 | 0.034 | 0.000 | |
## | 0.028 | 0.015 | 0.000 | |
## ------------------|-----------|-----------|-----------|-----------|
## Column Total | 204 | 177 | 12 | 393 |
## | 0.519 | 0.450 | 0.031 | |
## ------------------|-----------|-----------|-----------|-----------|
##
##
The dependent variable “vote” is an unordered factor response, having several discrete values(“Truman”, “Dewey” and others) which are arranged with no order. So Multinomial logistic regression can be considered to analize the relationship between the response variable “vote” and predictors.The function multinom can fit models in which the observations represent counts in the several response categories, as one would have in a contingency table.(Fox and Weisberg 2011) The following analysis sets “Truman” as the baseline category and then fits a mulitinomial-logit model with the predictors. So this models compares the ratio of probabilities of the possible outcomes of the baseline “Truman” and other categories in the dependent variable “vote”, given a set of independent variables. Therefore, the test hypothesis is as follows.
Ho(null hypothesis): b0=b1=b2 = . bk = 0 (The effect of all predictors on the ratio of other categories to the base line is not significant) and
Ha(alternative hypothesis): Not all coefficients of the predictors on the ratio are 0(The effect of predictors on the response variable is statistically significant).
library(car)
library(nnet)
library(stats)
vote.48$voteGroup <- factor(vote.48$voteGroup, levels=c("Truman", "Dewey", "others"))
mod.multinom <- multinom(voteGroup ~ income + occu+ relig +race+edu+age, data = vote.48)
## # weights: 31 (30 variable)
## initial value 248.839838
## iter 10 value 173.520811
## iter 20 value 172.460712
## iter 30 value 172.381567
## iter 40 value 172.367030
## final value 172.366999
## converged
Anova(mod.multinom)
## Analysis of Deviance Table (Type II tests)
##
## Response: voteGroup
## LR Chisq Df Pr(>Chisq)
## income 6.6 6 0.35663
## occu 43.1 10 4.8e-06 ***
## relig 31.6 4 2.3e-06 ***
## race 0.1 2 0.96334
## edu 19.3 2 6.5e-05 ***
## age 21.5 5 0.00064 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
As a result, the variables “Occupation”, “Religion”, “Education”, and “Age” have statistically significant effects on the response variable “Vote”, but “race” and “income” are not significant on the response variable.
mod.multinom.1 <- update(mod.multinom, .~. - income -race)
## # weights: 23 (22 variable)
## initial value 257.157604
## iter 10 value 182.624456
## iter 20 value 182.027836
## iter 30 value 181.960428
## final value 181.959785
## converged
summary(mod.multinom.1)
## Call:
## multinom(formula = voteGroup ~ occu + relig + edu + age, data = vote.48)
##
## Coefficients:
## Values Std. Err.
## (Intercept) -2.2111 0.910
## occuSELF-EMPLOYED, MANAGERIAL, SUPERVISORY 2.0082 0.688
## occuOTHER WHITE-COLLAR (CLERICAL, SALES, ET -0.1621 0.555
## occuSKILLED AND SEMI-SKILLED -0.9822 0.549
## occuPROTECTIVE SERVICE 0.4546 1.340
## occuUNSKILLED, INCLUDING FARM AND SERVICE W -0.9860 0.625
## occuFARM OPERATORS AND MANAGERS -0.7025 0.626
## occuSTUDENT 0.7438 1.480
## occuUNEMPLOYED 0.0000 NaN
## occuRETIRED, TOO OLD OR UNABLE TO WORK 0.3909 0.745
## occuHOUSEWIFE 0.3704 0.886
## religCATHOLIC -0.4932 0.308
## religJEWISH -16.7659 723.746
## religOTHER -0.2246 0.743
## religNONE -0.0822 0.795
## eduHIGH SCHOOL 0.8647 0.325
## eduCOLLEGE 2.2371 0.480
## age25-34 1.3261 0.757
## age35-44 1.3139 0.742
## age45-54 2.2875 0.766
## age55-64 2.7696 0.805
## age65 AND OVER 1.9921 0.865
##
## Residual Deviance: 364
## AIC: 406
To compare the effects of predictors on voting for candidate “Truman” and others of response variable “vote”, logistic regression is used. The first step of logistic regression is to make binary response variable “voteGroup2” by dividing the set of candidates into 2 groups: “Truman” and “others”
attach(vote.48)
vote.48$voteGroup2[vote==1] <- 1
vote.48$voteGroup2[(vote >= 2) & (vote <=4)] <- 2
detach(vote.48)
voteType2 <- c("Truman", "Other")
vote.48$voteGroup2 <-factor(vote.48$voteGroup2, labels = voteType2)
summary(vote.48$voteGroup2)
## Truman Other NA's
## 212 190 260
Then logistic regression analysis is performed as follows.
data(vote.48)
logit.vote <- glm(voteGroup2 ~ income+occu+relig+race+edu+age, family=binomial(link=logit), data=vote.48)
summary(logit.vote)
##
## Call:
## glm(formula = voteGroup2 ~ income + occu + relig + race + edu +
## age, family = binomial(link = logit), data = vote.48)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3116 -0.7755 -0.0001 0.8102 2.1915
##
## Coefficients:
## Estimate Std. Error z value
## (Intercept) -2.470 1.220 -2.02
## income$500-$999 -0.431 1.031 -0.42
## income$1000-1999 -0.124 0.862 -0.14
## income$2000-2999 0.148 0.859 0.17
## income$3000-3999 0.639 0.878 0.73
## income$4000-4999 1.063 0.937 1.13
## income$5000 AND OVER 0.477 0.910 0.52
## occuSELF-EMPLOYED, MANAGERIAL, SUPERVISORY 1.829 0.710 2.58
## occuOTHER WHITE-COLLAR (CLERICAL, SALES, ET -0.263 0.591 -0.44
## occuSKILLED AND SEMI-SKILLED -0.911 0.587 -1.55
## occuPROTECTIVE SERVICE 0.303 1.372 0.22
## occuUNSKILLED, INCLUDING FARM AND SERVICE W -1.022 0.669 -1.53
## occuFARM OPERATORS AND MANAGERS -0.413 0.651 -0.64
## occuSTUDENT 1.150 1.542 0.75
## occuRETIRED, TOO OLD OR UNABLE TO WORK 0.562 0.798 0.70
## occuHOUSEWIFE 0.553 0.936 0.59
## religCATHOLIC -0.675 0.314 -2.15
## religJEWISH -18.521 797.280 -0.02
## religOTHER -0.367 0.804 -0.46
## religNONE 0.356 0.806 0.44
## raceNEGRO -0.239 0.673 -0.35
## eduHIGH SCHOOL 0.728 0.327 2.23
## eduCOLLEGE 2.041 0.501 4.07
## age25-34 1.449 0.753 1.92
## age35-44 1.425 0.740 1.93
## age45-54 2.391 0.763 3.13
## age55-64 2.874 0.811 3.54
## age65 AND OVER 2.349 0.870 2.70
## Pr(>|z|)
## (Intercept) 0.0430 *
## income$500-$999 0.6758
## income$1000-1999 0.8854
## income$2000-2999 0.8631
## income$3000-3999 0.4667
## income$4000-4999 0.2569
## income$5000 AND OVER 0.6004
## occuSELF-EMPLOYED, MANAGERIAL, SUPERVISORY 0.0100 **
## occuOTHER WHITE-COLLAR (CLERICAL, SALES, ET 0.6565
## occuSKILLED AND SEMI-SKILLED 0.1209
## occuPROTECTIVE SERVICE 0.8251
## occuUNSKILLED, INCLUDING FARM AND SERVICE W 0.1263
## occuFARM OPERATORS AND MANAGERS 0.5254
## occuSTUDENT 0.4560
## occuRETIRED, TOO OLD OR UNABLE TO WORK 0.4815
## occuHOUSEWIFE 0.5544
## religCATHOLIC 0.0319 *
## religJEWISH 0.9815
## religOTHER 0.6480
## religNONE 0.6586
## raceNEGRO 0.7231
## eduHIGH SCHOOL 0.0258 *
## eduCOLLEGE 4.7e-05 ***
## age25-34 0.0544 .
## age35-44 0.0542 .
## age45-54 0.0017 **
## age55-64 0.0004 ***
## age65 AND OVER 0.0069 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 509.76 on 367 degrees of freedom
## Residual deviance: 358.22 on 340 degrees of freedom
## (294 observations deleted due to missingness)
## AIC: 414.2
##
## Number of Fisher Scoring iterations: 16
As a result, the variables “Occupation-self employed, managerial, supervisory”,“religion-Catholic”, “Education-High School, and college”, and “Age-45 and over” have statistically significant effects on the response variable “Vote for TRUMAN” at the 0.01 level of significance. However, “race” and “income” are not significant on the response variable. This reuslt exactly conforms to the output of multinomial logit regression above in 6.
confint.vote <- round(exp(cbind(Estimate = coef(logit.vote), confint(logit.vote))), 2)
confint.vote
## Estimate 2.5 % 97.5 %
## (Intercept) 0.08 0.01 9.10e-01
## income$500-$999 0.65 0.08 4.93e+00
## income$1000-1999 0.88 0.16 4.95e+00
## income$2000-2999 1.16 0.21 6.49e+00
## income$3000-3999 1.89 0.33 1.10e+01
## income$4000-4999 2.89 0.45 1.88e+01
## income$5000 AND OVER 1.61 0.26 9.93e+00
## occuSELF-EMPLOYED, MANAGERIAL, SUPERVISORY 6.23 1.60 2.68e+01
## occuOTHER WHITE-COLLAR (CLERICAL, SALES, ET 0.77 0.24 2.44e+00
## occuSKILLED AND SEMI-SKILLED 0.40 0.12 1.27e+00
## occuPROTECTIVE SERVICE 1.35 0.10 3.51e+01
## occuUNSKILLED, INCLUDING FARM AND SERVICE W 0.36 0.09 1.32e+00
## occuFARM OPERATORS AND MANAGERS 0.66 0.18 2.36e+00
## occuSTUDENT 3.16 0.17 1.03e+02
## occuRETIRED, TOO OLD OR UNABLE TO WORK 1.75 0.37 8.64e+00
## occuHOUSEWIFE 1.74 0.28 1.14e+01
## religCATHOLIC 0.51 0.27 9.40e-01
## religJEWISH 0.00 NA 2.10e+13
## religOTHER 0.69 0.14 3.53e+00
## religNONE 1.43 0.30 7.33e+00
## raceNEGRO 0.79 0.20 2.83e+00
## eduHIGH SCHOOL 2.07 1.10 3.97e+00
## eduCOLLEGE 7.70 2.97 2.14e+01
## age25-34 4.26 1.06 2.12e+01
## age35-44 4.16 1.06 2.02e+01
## age45-54 10.92 2.68 5.56e+01
## age55-64 17.71 3.93 9.80e+01
## age65 AND OVER 10.47 2.04 6.39e+01
Exponentiating the logistic regression model removes the log for the odds and changes it from a model that is additive in the log-odds scale to one that is multiplicative in the odds scale. So Compared with other occupation group, for example, “self-employed, managerial, supervisory occupation” group with all other predictors the same has odds of voting for Truman about 6.23(= e^1.829) times higher, with 95% confidence interval (1.60, 27). Other significant explantory groups are as follows.
With all other predictors the same
“College-Education” group has odds of voting for Truman about 7.70(=e^2.041) higher
“age 45-54” group has odds of voting for Truman about 10.92(=e^2.391) higher
“age 55-64” group has odds of voting for Truman about 17.71(=e^2.874) higher
“age 65 and more” group has odds of voting for Truman about 10.47(=e^2.349) higher
Next, Anova function is used to compare different logit models. The first model includes all predictors:income, occupation, race, education, age for the effects of predictors on the response variable “vote for Truman” and the second model excludes income and race. Each line of the analysis of deviance talbe gives a ‘LR Chisq’(likelihood ratio test statistic) based on the change in deviance. As revealed above with the logistic regression outcome, the predictors ‘income’ and ‘race’ are not significant on the response variable “vote for Truman”. Therefore, the second model with explanatory variables occupation, religion, education, and age explains well the relationship between the response variable “vote for Truman” and predictors..
data(vote.48)
z.mod1 <- glm(voteGroup2 ~ income+occu+relig+race+edu+age, family=binomial(link=logit), data=vote.48)
z.mod2 <- update(z.mod1, .~. -income-race)
Anova(z.mod1)
## Analysis of Deviance Table (Type II tests)
##
## Response: voteGroup2
## LR Chisq Df Pr(>Chisq)
## income 6.8 6 0.34391
## occu 40.8 9 5.4e-06 ***
## relig 34.2 4 6.7e-07 ***
## race 0.1 1 0.72122
## edu 18.7 2 8.9e-05 ***
## age 22.0 5 0.00051 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(z.mod2)
## Analysis of Deviance Table (Type II tests)
##
## Response: voteGroup2
## LR Chisq Df Pr(>Chisq)
## occu 48.5 9 2.1e-07 ***
## relig 30.8 4 3.4e-06 ***
## edu 23.2 2 9.0e-06 ***
## age 21.4 5 0.00069 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysing the American National Election Study of 1948 using the memisc package [http://cran.r-project.org/web/packages/memisc/vignettes/anes48.pdf]
Fox, John, and Harvey Sanford Weisberg. 2011. An R Companion to Applied Regression. 2nd ed. Thousand Oaks, CA: Sage Publications.