Description Usage Arguments Value Examples
Generate prediction through Monte Carlo simulation based on approximation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
m |
Single model object. |
profile |
The case profile ( |
y.label |
The label of the dependent variable (optional, character). |
at |
Values to be fixed if not specified in |
type |
If |
show.ci |
Show confidence interval (boulean). The default is |
level.ci |
The level used for confidence interval (numeric: 0-1). The default is |
vcov.est |
Variance-covariance matrix to draw coefficents.
If |
robust.type |
The type of leverage adjustment passed to |
cluster.var |
A |
iterate.num |
The number of iteration in simulation. |
iterate.seed |
The seed value for random number generator used for the draws from multivariate normal distribution. |
rawbeta |
The matrix of pre-simulated beta. Columns are variables, raws are simulated cases. Used only when |
dropbeta |
If not |
... |
Additional arguments passed to |
A list of:
predsum
Summary Predictions Table
profile
Profile Used for Predictions
predres
Raw Predictions
formula
Estimation Formula
y.label
Dependent Variable Label
family
Estimation Method Family
type
Output Type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ## Load Data
library(pscl)
data(vote92)
## Recode Variables
vote92$voteBush <- as.numeric(
factor(vote92$vote,levels=c("Clinton","Bush")))*1 - 1
vote92$bushdis <- sqrt(vote92$bushdis)
vote92$clintondis <- sqrt(vote92$clintondis)
## Estimate Logistic Regression
fm <- formula(voteBush ~ dem + rep +
clintondis + bushdis +
persfinance + natlecon)
m <- glm(fm, data = vote92,
family = binomial("logit"))
## Comparing Partisans
# Profile
prof1 <- data.frame(dem=c(1,0,0),rep=c(0,0,1))
# Prediction (Missing Variables are Fixed at Mean/Mode)
predprof1 <- simu_pred(m, prof1, y.label = "Bush Vote")
summary(predprof1)
# Additional Profile to Give Labels
addprof1 <- data.frame(pid=c("Democrat","Independent","Republican"))
addprof1$pid <- factor(addprof1$pid, levels=unique(addprof1$pid))
# Plot
plot_simu(predprof1, name.x="pid", addprof=addprof1, label.x = "Party ID")
# Change it to Point Graph
plot_simu(predprof1, name.x="pid", addprof=addprof1,
label.x = "Party ID", type.est = "point")
## Comparing Effects of Ideological Distance by Party ID
# Profile
prof2 <- data.frame(dem=rep(rep(c(1,0,0),each=50),2),
rep=rep(rep(c(0,0,1),each=50),2),
bushdis=c(rep(seq(0,4,length=50),3),
rep(0.5,150)),
clintondis=c(rep(0.5,150),
rep(seq(0,4,length=50),3)))
# Prediction (Missing Variables are Fixed at Mean/Mode)
predprof2 <- simu_pred(m, prof2, y.label = "Bush Vote")
summary(predprof2)
# Additional Profile to Give Labels
addprof2 <- data.frame(pid=rep(c("Democrat","Independent","Republican"),each=50),
dis=rep(seq(0,4,length=50),6),
labdis=rep(c("Ideological Distance from Bush",
"Ideological Distance from Clinton"),each=150))
addprof2$pid <- factor(addprof2$pid, levels=rev(unique(addprof2$pid)))
# Plot
plot_simu(predprof2, name.x="dis", addprof=addprof2,
name.facet.x = "labdis", name.linetype="pid",
label.x = NULL, label.linetype="Party ID")
# Change Color of CIs
plot_simu(predprof2, name.x="dis", addprof=addprof2,
name.facet.x = "labdis", name.linetype="pid", name.fill="pid",
label.x = NULL, label.linetype="Party ID")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.