Datos:
library(Zelig)
data(turnout)
Modelos:
m1 <- glm(vote ~ age + I(age^2) + educate + income + race, data=turnout)
m2 <- glm(vote ~ age + I(age^2) + educate + income + race, family=binomial(link="probit"), data=turnout)
Predicciones (variando la edad y manteniendo las demás variables independientes en las medias muestrales):
sim <- data.frame(age=17:95,
educate=mean(turnout$educate),
income=mean(turnout$income),
race="white")
Gráfico: logit (y apariencia general)
plot(17:95, predict(m1, sim, type="response"),
type="l",
ylim=c(0, 1),
ylab="Probabilidad de votar",
xlab="Edad")
Gráfico: añadir la predicción del modelo probit
lines(17:95, predict(m2, sim, type="response"), lty="dotted")
Gráfico: leyenda
legend(x="bottomright",
bty="n",
legend=c("logit", "probit"),
lty=c("solid", "dotted"),
cex=.9)
