data(turnout)
z.out <- zelig(vote ~ race + educate + age + I(age^2) + income,
model = "logit", data = turnout)
age.range <- 18:95
x.low <- setx(z.out, educate = 12, age = age.range)
x.high <- setx(z.out, educate = 16, age = age.range)
s.out <- sim(z.out, x = x.low, x1 = x.high)
plot.ci(s.out, xlab = "Age in Years",
ylab = "Predicted Probability of Voting",
main = "Effect of Education and Age on Voting Behavior")
legend(45, 0.52, legend = c("College Education (16 years)",
"High School Education (12 years)"), col = c("blue","red"),
lty = c("solid"))
## adding lines connecting point estimates
lines(age.range, apply(s.out$qi$ev, 2, mean))
lines(age.range, apply(s.out$qi$fd+s.out$qi$ev, 2, mean))
Run the code above in your browser using DataLab