Description Usage Arguments Value Examples
View source: R/simu_interact.R
Drawing interaction plot. This function is a wrapper for plot_simu
function.
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 | plot_interact(
interactprof,
name.var2 = NULL,
label.var2 = "name.var2",
label.y = "auto",
hline0 = TRUE,
addprof = NULL,
name.est = "Mean",
show.ci = TRUE,
name.lowerCI = "lowerCI",
name.upperCI = "upperCI",
type.est = "auto",
type.ci = "auto",
name.facet.x = NULL,
name.facet.y = NULL,
name.color = NULL,
name.linetype = NULL,
name.fill = NULL,
name.shape = NULL,
line.width = 0.7,
barpoint.gapwidth = 0.5,
point.size = 2,
errorbar.width = 0.5,
ribbon.alpha = 0.5,
label.color = "name.color",
label.linetype = "name.linetype",
label.fill = "name.fill",
label.shape = "name.shape",
titletxt = NULL
)
|
interactprof |
Conditional coefficients in either |
name.var2 |
Column name for the main variable that conditions the coeffient of target variable (plotted on x axis).
If not given, the information will be extracted from |
label.var2 |
X axis label. If |
label.y |
Y axis label. If |
hline0 |
If |
addprof |
Optional |
name.est |
Column name for mean/median conditional coefficient estiamte. |
show.ci |
If |
name.lowerCI |
Column name for the upper limit of confidence interval (applied if |
name.upperCI |
Column name for the upper limit of confidence interval (applied if |
type.est |
Plotting type of estimates. If |
type.ci |
Plotting type of confidence intervals. If |
name.facet.x |
Column name for the predictor that controls facets horizontally (optional). |
name.facet.y |
Column name for the predictor that controls facets vertically (optional). |
name.color |
Column name for the predictor that controls line colors (optional). |
name.linetype |
COlumn name for the predictor that controls line types (optional). |
name.fill |
Column name for the predictor that controls fill colors (optional). |
name.shape |
Column name for the predictor that controls point shapes (optional). |
line.width |
The width of line in line plot. |
barpoint.gapwidth |
The gap between bars/points if plot is clustered. |
point.size |
The size of points in point plot. |
errorbar.width |
The width of errorbar. |
ribbon.alpha |
The transparency of ribbon plot. |
label.color |
Optional label if |
label.linetype |
Optional label if |
label.fill |
Optional label if |
label.shape |
Optional label if |
titletxt |
Title Text. |
ggplot
object (axis and theme settings can be added later).
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.