plot.ci {Zelig} | R Documentation |
The plot.ci
command generates vertical
confidence intervals for linear or generalized linear univariate
response models.
plot.ci(x, CI = 95, qi = "ev", main = "", ylab = NULL, xlab = NULL, xlim = NULL, ylim = NULL, col = c("red", "blue"), ...)
x |
stored output from |
CI |
the selected confidence interval. Defaults to 95 percent. |
qi |
the selected quantity of interest. Defaults to expected values. |
main |
a title for the plot. |
ylab |
label for the y-axis. |
xlab |
label for the x-axis. |
xlim |
limits on the x-axis. |
ylim |
limits on the y-axis. |
col |
a vector of at most two colors for plotting the
expected value given by |
... |
Additional parameters passed to |
For all univariate response models, plot.ci()
returns vertical
confidence intervals over a specified range of one explanatory
variable. You may save this plot using the commands described in the
Zelig manual (http://gking.harvard.edu/zelig).
Kosuke Imai <kimai@princeton.edu>; Gary King <king@harvard.edu>; Olivia Lau <olau@fas.harvard.edu>
The full Zelig manual is available at
http://gking.harvard.edu/zelig, and users may also wish to see
plot
, lines
.
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))