Description Usage Arguments Details Value Author(s) See Also Examples
effect_plot()
plots regression paths. The plotting is done with
ggplot2
rather than base graphics, which some similar functions use.
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  effect_plot(
model,
pred,
pred.values = NULL,
centered = "all",
plot.points = FALSE,
interval = FALSE,
data = NULL,
at = NULL,
int.type = c("confidence", "prediction"),
int.width = 0.95,
outcome.scale = "response",
robust = FALSE,
cluster = NULL,
vcov = NULL,
set.offset = 1,
x.label = NULL,
y.label = NULL,
pred.labels = NULL,
main.title = NULL,
colors = "black",
line.thickness = 1.1,
point.size = 1.5,
point.alpha = 0.6,
point.color = "black",
jitter = 0,
rug = FALSE,
rug.sides = "lb",
force.cat = FALSE,
cat.geom = c("point", "line", "bar"),
cat.interval.geom = c("errorbar", "linerange"),
cat.pred.point.size = 3.5,
partial.residuals = FALSE,
color.class = colors,
...
)

model 
A regression model. The function is tested with 
pred 
The name of the predictor variable involved
in the interaction. This can be a bare name or string. Note that it
is evaluated using 
pred.values 
Values of 
centered 
A vector of quoted variable names that are to be
meancentered. If 
plot.points 
Logical. If 
interval 
Logical. If 
data 
Optional, default is NULL. You may provide the data used to
fit the model. This can be a better way to get mean values for centering
and can be crucial for models with variable transformations in the formula
(e.g., 
at 
If you want to manually set the values of other variables in the model, do so by providing a named list where the names are the variables and the list values are vectors of the values. This can be useful especially when you are exploring interactions or other conditional predictions. 
int.type 
Type of interval to plot. Options are "confidence" or "prediction". Default is confidence interval. 
int.width 
How large should the interval be, relative to the standard error? The default, .95, corresponds to roughly 1.96 standard errors and a .05 alpha level for values outside the range. In other words, for a confidence interval, .95 is analogous to a 95% confidence interval. 
outcome.scale 
For nonlinear models (i.e., GLMs), should the outcome
variable be plotted on the link scale (e.g., log odds for logit models) or
the original scale (e.g., predicted probabilities for logit models)? The
default is 
robust 
Should robust standard errors be used to find confidence
intervals for supported models? Default is FALSE, but you should specify
the type of sandwich standard errors if you'd like to use them (i.e.,

cluster 
For clustered standard errors, provide the column name of the cluster variable in the input data frame (as a string). Alternately, provide a vector of clusters. 
vcov 
Optional. You may supply the variancecovariance matrix of the coefficients yourself. This is useful if you are using some method for robust standard error calculation not supported by the sandwich package. 
set.offset 
For models with an offset (e.g., Poisson models), sets an offset for the predicted values. All predicted values will have the same offset. By default, this is set to 1, which makes the predicted values a proportion. See details for more about offset support. 
x.label 
A character object specifying the desired xaxis label. If

y.label 
A character object specifying the desired xaxis label. If

pred.labels 
A character vector of labels for categorical predictors.
If 
main.title 
A character object that will be used as an overall title
for the plot. If 
colors 
See jtools_colors for details on the types of arguments accepted. Default is "black". 
line.thickness 
How thick should the plotted lines be? Default is 1.1; ggplot's default is 1. 
point.size 
What size should be used for observed data when

point.alpha 
What should the 
point.color 
What should the 
jitter 
How much should 
rug 
Show a rug plot in the margins? This uses 
rug.sides 
On which sides should rug plots appear? Default is "lb", meaning both left and bottom. "t" and/or "b" show the distribution of the predictor while "l" and/or "r" show the distribution of the response. 
force.cat 
Force the continuous 
cat.geom 
If

cat.interval.geom 
For categorical by categorical interactions.
One of "errorbar" or "linerange". If the former,

cat.pred.point.size 
(for categorical 
partial.residuals 
Instead of plotting the observed data, you may plot
the partial residuals (controlling for the effects of variables besides

color.class 
Deprecated. Now known as 
... 
extra arguments passed to 
This function provides a means for plotting effects for the
purpose of exploring regression estimates. You must have the
package ggplot2
installed to benefit from these plotting functions.
By default, all numeric predictors other than the one specified in the
pred
argument are meancentered, which usually produces more
intuitive plots. This only affects the yaxis in linear models, but
may be especially important/influential in nonlinear/generalized linear
models.
This function supports nonlinear and generalized linear models and by
default will plot them on
their original scale (outcome.scale = "response"
).
While mixed effects models from lme4
are supported, only the fixed
effects are plotted. lme4
does not provide confidence intervals,
so they are not supported with this function either.
Note: to use transformed predictors, e.g., log(x)
, or polynomials,
e.g., poly(x, 2)
, provide the raw variable name (x
) to the pred =
argument. You will need to input the data frame used to fit the model with
the data =
argument.
The functions returns a ggplot
object, which can be treated
like
a usercreated plot and expanded upon as such.
Jacob Long <long.1377@osu.edu>
interact_plot
from the interactions
package plots interaction
effects,
producing plots like this function but with separate lines for different
levels of a moderator. cat_plot
from interactions
does the same
for categorical by categorical interactions.
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  # Using a fitted lm model
states < as.data.frame(state.x77)
states$HSGrad < states$`HS Grad`
fit < lm(Income ~ HSGrad + Murder,
data = states)
effect_plot(model = fit, pred = Murder)
# Using polynomial predictor, plus intervals
fit < lm(accel ~ poly(mag,3) + dist, data = attenu)
effect_plot(fit, pred = mag, interval = TRUE,
int.type = "confidence", int.width = .8, data = attenu) # note data arg.
# With svyglm
if (requireNamespace("survey")) {
library(survey)
data(api)
dstrat < svydesign(id = ~1, strata = ~stype, weights = ~pw,
data = apistrat, fpc = ~fpc)
regmodel < svyglm(api00 ~ ell + meals, design = dstrat)
effect_plot(regmodel, pred = ell, interval = TRUE)
}
# With lme4
## Not run:
library(lme4)
data(VerbAgg)
mv < glmer(r2 ~ Anger + mode + (1  item), data = VerbAgg,
family = binomial,
control = glmerControl("bobyqa"))
effect_plot(mv, pred = Anger)
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.