Description Usage Arguments Value Examples
View source: R/simu_interact.R
Compute interaction effects through Monte-Carlo Simulation. Wrapper function of simu_pred
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
m |
Single model object. |
var1 |
Variable of coeffcients to be simulated. |
var1.label |
Text label for |
moveprof |
Data.frame object that specifies moving values for variables included in interaction terms other than |
var2 |
Character for the second variable name in interaction term. Must be given is |
steps |
Maximum number of values to be simulated. (Applied if |
y.label |
The label of the dependent variable (optional, character). |
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 |
... |
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
moveprof
Profile of Moving Values
var1.label
The Label of Target variable
var2
Primary condition variable
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 | ## 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 with Interaction
fm <- formula(voteBush ~ dem*clintondis +
rep + bushdis +
persfinance + natlecon)
m <- glm(fm, data = vote92,
family = binomial("logit"))
# Moving Values
moveprof <- data.frame(clintondis = seq(0,4,length=50))
# Simulation
interactprof <- simu_interact(m, "dem", moveprof=moveprof,
var1.label = "Being Democrat",
y.label = "Bush Vote")
# Plot
plot_interact(interactprof,
label.var2="Ideological Distance from Clinton")
# Alternative Way
interactprof <- simu_interact(m, "dem", var2 = "clintondis",
var1.label = "Being Democrat",
y.label = "Bush Vote")
plot_interact(interactprof,
label.var2="Ideological Distance from Clinton")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.