library(Zelig)
library(DescTools)
library(stargazer)
library(dplyr)
library(scatterplot3d)
library(tidyr)
library(memisc)
library(pander)
library(gmodels)
library(Hmisc)
library(car)
library(foreign)
options(digits=3)
nes1948.por <- UnZip("anes/NES1948.ZIP","NES1948.POR", package="memisc")
nes1948 <- spss.portable.file(nes1948.por)
nes1948<-read.spss(nes1948.por)
class(nes1948)
## [1] "list"
vote.48<-data.frame(nes1948)
vote.48<- select(vote.48,
V480018,
V480029,
V480030,
V480045,
V480046,
V480047,
V480048,
V480049,
V480050)
vote.48<-rename(vote.48, V480018="vote", V480029="occupation", V490030= "unionized", V480045="gender", V480046="race", V480047="age", V480048="education", V480049="income", V480050="religion")
Logit Models
vote.mod<-lm(vote ~ gender, data = vote.48)
vote.z<-zelig(vote ~ gender, data= vote.48, model = "logit")
stargazer(vote.mod, vote.z, type= "html")
|
|
|
|
Dependent variable:
|
|
|
|
|
|
vote
|
|
|
OLS
|
logistic
|
|
|
(1)
|
(2)
|
|
|
|
genderFEMALE
|
0.441
|
0.317*
|
|
|
|
(0.168)
|
|
|
|
|
|
genderNA
|
1.650
|
0.107
|
|
|
|
(1.230)
|
|
|
|
|
|
Constant
|
3.010
|
0.586***
|
|
|
|
(0.120)
|
|
|
|
|
|
|
|
Observations
|
662
|
662
|
|
Log Likelihood
|
|
-413.000
|
|
Akaike Inf. Crit.
|
|
833.000
|
|
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
With Interactions
vote.mod1<- zelig(vote~gender, data=vote.48, model = "logit", x=TRUE)
vote.mod2 <- zelig(vote ~ gender+ race, model = "logit", data=vote.48, x=TRUE)
vote.mod3 <- zelig(vote ~ gender + race + gender:race , model = "logit", data=vote.48, x=TRUE)
stargazer(vote.mod1, vote.mod2, vote.mod3, type="html")
|
|
|
|
Dependent variable:
|
|
|
|
|
|
vote
|
|
|
(1)
|
(2)
|
(3)
|
|
|
|
genderFEMALE
|
0.317*
|
0.307*
|
0.304*
|
|
|
(0.168)
|
(0.168)
|
(0.177)
|
|
|
|
|
|
|
genderNA
|
0.107
|
0.363
|
-0.552
|
|
|
(1.230)
|
(1.250)
|
(1.420)
|
|
|
|
|
|
|
raceNEGRO
|
|
0.769**
|
1.060*
|
|
|
|
(0.346)
|
(0.562)
|
|
|
|
|
|
|
raceNA
|
|
-0.613
|
-1.470*
|
|
|
|
(0.500)
|
(0.846)
|
|
|
|
|
|
|
genderFEMALE:raceNEGRO
|
|
|
-0.492
|
|
|
|
|
(0.713)
|
|
|
|
|
|
|
genderNA:raceNEGRO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
genderFEMALE:raceNA
|
|
|
1.300
|
|
|
|
|
(1.110)
|
|
|
|
|
|
|
genderNA:raceNA
|
|
|
15.000
|
|
|
|
|
(535.000)
|
|
|
|
|
|
|
Constant
|
0.586***
|
0.547***
|
0.552***
|
|
|
(0.120)
|
(0.123)
|
(0.126)
|
|
|
|
|
|
|
|
|
Observations
|
662
|
662
|
662
|
|
Log Likelihood
|
-413.000
|
-410.000
|
-408.000
|
|
Akaike Inf. Crit.
|
833.000
|
829.000
|
832.000
|
|
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
vote.z3 <-zelig(vote ~ income, data=vote.48, model ="logit")
How to cite this model in Zelig: Kosuke Imai, Gary King, and Olivia Lau. 2015. “logit: Logistic Regression for Dichotomous Dependent Variables” in Kosuke Imai, Gary King, and Olivia Lau, “Zelig: Everyone’s Statistical Software,” http://gking.harvard.edu/zelig
vote.z4<-zelig(vote ~ income + education, data= vote.48, model="logit")
How to cite this model in Zelig: Kosuke Imai, Gary King, and Olivia Lau. 2015. “logit: Logistic Regression for Dichotomous Dependent Variables” in Kosuke Imai, Gary King, and Olivia Lau, “Zelig: Everyone’s Statistical Software,” http://gking.harvard.edu/zelig
stargazer(vote.z3, vote.z4, data=vote.48, type="html")
|
|
|
|
Dependent variable:
|
|
|
|
|
|
vote
|
|
|
(1)
|
(2)
|
|
|
|
999
|
-0.182
|
-0.141
|
|
|
(0.672)
|
(0.673)
|
|
|
|
|
|
1000-1999
|
-1.020*
|
-1.020*
|
|
|
(0.581)
|
(0.583)
|
|
|
|
|
|
2000-2999
|
-1.140**
|
-1.210**
|
|
|
(0.566)
|
(0.570)
|
|
|
|
|
|
3000-3999
|
-0.986*
|
-1.200**
|
|
|
(0.574)
|
(0.582)
|
|
|
|
|
|
4000-4999
|
-0.965
|
-1.200*
|
|
|
(0.605)
|
(0.616)
|
|
|
|
|
|
5000 AND OVER
|
-0.560
|
-0.955
|
|
|
(0.601)
|
(0.617)
|
|
|
|
|
|
incomeNA
|
-0.742
|
-0.570
|
|
|
(0.999)
|
(1.070)
|
|
|
|
|
|
educationHIGH SCHOOL
|
|
0.199
|
|
|
|
(0.192)
|
|
|
|
|
|
educationCOLLEGE
|
|
1.090***
|
|
|
|
(0.318)
|
|
|
|
|
|
educationNA
|
|
-1.720
|
|
|
|
(1.200)
|
|
|
|
|
|
Constant
|
1.660***
|
1.580***
|
|
|
(0.546)
|
(0.548)
|
|
|
|
|
|
|
|
Observations
|
662
|
662
|
|
Log Likelihood
|
-409.000
|
-401.000
|
|
Akaike Inf. Crit.
|
834.000
|
823.000
|
|
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
|
|
|
Statistic
|
N
|
Mean
|
St. Dev.
|
Min
|
Max
|
|
|
z.out<-zelig(vote ~ income + education, model="logit", data=vote.48)
##
##
## How to cite this model in Zelig:
## Kosuke Imai, Gary King, and Olivia Lau. 2015.
## "logit: Logistic Regression for Dichotomous Dependent Variables"
## in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software,"
## http://gking.harvard.edu/zelig
##
x.out<-setx(z.out)
s.out<-sim(z.out, x = x.out)
summary(s.out)
##
## Model: logit
## Number of simulations: 1000
##
## Values of X
## (Intercept) income$500-$999 income$1000-1999 income$2000-2999
## 1 1 0 0 1
## income$3000-3999 income$4000-4999 income$5000 AND OVER incomeNA
## 1 0 0 0 0
## educationHIGH SCHOOL educationCOLLEGE educationNA
## 1 0 0 0
## attr(,"assign")
## [1] 0 1 1 1 1 1 1 1 2 2 2
## attr(,"contrasts")
## attr(,"contrasts")$income
## [1] "contr.treatment"
##
## attr(,"contrasts")$education
## [1] "contr.treatment"
##
##
## Expected Values: E(Y|X)
## mean sd 50% 2.5% 97.5%
## 0.593 0.043 0.594 0.506 0.677
##
## Predicted Values: Y|X
## 0 1
## 0.378 0.622
plot.ci(s.out)
## Warning in plot.ci(s.out): Must specify the `var` parameter when plotting
## the confidence interval of an unvarying model. Plotting nothing.