Description Usage Arguments Details Value References Examples
plot_model()
creates plots from regression models, either
estimates (as socalled forest or dot whisker plots) or marginal effects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  plot_model(model, type = c("est", "re", "eff", "pred", "int", "std",
"std2", "slope", "resid", "diag"), transform, terms = NULL,
sort.est = NULL, rm.terms = NULL, group.terms = NULL,
order.terms = NULL, pred.type = c("fe", "re"),
mdrt.values = c("minmax", "meansd", "zeromax", "quart", "all"),
ri.nr = NULL, title = NULL, axis.title = NULL,
axis.labels = NULL, legend.title = NULL, wrap.title = 50,
wrap.labels = 25, axis.lim = NULL, grid.breaks = NULL,
ci.lvl = NULL, se = NULL, colors = "Set1",
show.intercept = FALSE, show.values = FALSE, show.p = TRUE,
show.data = FALSE, show.legend = TRUE, show.zeroinf = TRUE,
value.offset = NULL, value.size, jitter = NULL, digits = 2,
dot.size = NULL, line.size = NULL, vline.color = NULL,
p.threshold = c(0.05, 0.01, 0.001), grid, case, auto.label = TRUE,
prefix.labels = c("none", "varname", "label"), bpe = "median",
bpe.style = "line", bpe.color = "white", ...)
get_model_data(model, type = c("est", "re", "eff", "pred", "int", "std",
"std2", "slope", "resid", "diag"), transform, terms = NULL,
sort.est = NULL, rm.terms = NULL, group.terms = NULL,
order.terms = NULL, pred.type = c("fe", "re"), ri.nr = NULL,
ci.lvl = NULL, colors = "Set1", grid, case = "parsed",
digits = 2, ...)

model 
A regression model object. Depending on the 
type 
Type of plot. There are three groups of plottypes:
Marginal Effects (related vignette)
Model diagnostics
Note: For mixed models, the diagnostic plots like linear relationship or check for Homoscedasticity, do not take the uncertainty of random effects into account, but is only based on the fixed effects part of the model. 
transform 
A character vector, naming a function that will be applied
on estimates and confidence intervals. By default, 
terms 
Character vector with the names of those terms from

sort.est 
Determines in which way estimates are sorted in the plot:

rm.terms 
Character vector with names that indicate which terms should
be removed from the plot. Counterpart to 
group.terms 
Numeric vector with group indices, to group coefficients. Each group of coefficients gets its own color (see 'Examples'). 
order.terms 
Numeric vector, indicating in which order the coefficients should be plotted. See examples in this packagevignette. 
pred.type 
Character, only applies for Marginal Effects plots
with mixed effects models. Indicates whether predicted values should be
conditioned on random effects ( 
mdrt.values 
Indicates which values of the moderator variable should be
used when plotting interaction terms (i.e.

ri.nr 
Numeric vector. If 
title 
Character vector, used as plot title. By default,

axis.title 
Character vector of length one or two (depending on the
plot function and type), used as title(s) for the x and y axis. If not
specified, a default labelling is chosen. Note: Some plot types
may not support this argument sufficiently. In such cases, use the returned
ggplotobject and add axis titles manually with

axis.labels 
Character vector with labels for the model terms, used as
axis labels. By default, 
legend.title 
Character vector, used as legend title for plots that have a legend. 
wrap.title 
Numeric, determines how many chars of the plot title are displayed in one line and when a line break is inserted. 
wrap.labels 
Numeric, determines how many chars of the value, variable or axis labels are displayed in one line and when a line break is inserted. 
axis.lim 
Numeric vector of length 2, defining the range of the plot
axis. Depending on plottype, may effect either x or yaxis. For
Marginal Effects plots, 
grid.breaks 
Numeric value or vector; if 
ci.lvl 
Numeric, the level of the confidence intervals (error bars).
Use 
se 
Either a logical, and if 
colors 
May be a character vector of color values in hexformat, valid
color value names (see

show.intercept 
Logical, if 
show.values 
Logical, whether values should be plotted or not. 
show.p 
Logical, adds asterisks that indicate the significance level of estimates to the value labels. 
show.data 
Logical, for Marginal Effects plots, also plots the raw data points. 
show.legend 
For Marginal Effects plots, shows or hides the legend. 
show.zeroinf 
Logical, if 
value.offset 
Numeric, offset for text labels to adjust their position relative to the dots or lines. 
value.size 
Numeric, indicates the size of value labels. Can be used
for all plot types where the argument 
jitter 
Numeric, between 0 and 1. If 
digits 
Numeric, amount of digits after decimal point when rounding estimates or values. 
dot.size 
Numeric, size of the dots that indicate the point estimates. 
line.size 
Numeric, size of the lines that indicate the error bars. 
vline.color 
Color of the vertical "zero effect" line. Default color is inherited from the current theme. 
p.threshold 
Numeric vector of length 3, indicating the treshold for
annotating pvalues with asterisks. Only applies if

grid 
Logical, if 
case 
Desired target case. Labels will automatically converted into the
specified character case. See 
auto.label 
Logical, if 
prefix.labels 
Indicates whether the value labels of categorical variables
should be prefixed, e.g. with the variable name or variable label. See
argument 
bpe 
For Stanmodels (fitted with the rstanarm or
brmspackage), the Bayesian point estimate is, by default, the median
of the posterior distribution. Use 
bpe.style 
For Stanmodels (fitted with the rstanarm or
brmspackage), the Bayesian point estimate is indicated as a small,
vertical line by default. Use 
bpe.color 
Character vector, indicating the color of the Bayesian
point estimate. Setting 
... 
Other arguments, passed down to various functions. Here is a list of supported arguments and their description in detail.

get_model_data()
simply calls plot_model()
and returns
the data from the ggplotobject. Hence, it is rather inefficient and should
be used as alternative to brooms tidy()
function only in
specific situations.
Some notes on the different plottypes:
type = "std2"
Plots standardized beta values, however, standardization follows Gelman's (2008) suggestion, rescaling the estimates by dividing them by two standard deviations instead of just one. Resulting coefficients are then directly comparable for untransformed binary predictors.
type = "pred"
Plots marginal effects. Simply wraps
ggpredict
.
type = "eff"
Plots marginal effects. Simply wraps
ggeffect
.
type = "int"
A shortcut for marginal effects plots, where
interaction terms are automatically detected and used as
terms
argument. Furthermore, if the moderator variable (the second
 and third  term in an interaction) is continuous, type = "int"
automatically chooses useful values based on the mdrt.values
argument,
which are passed to terms
. Then, ggpredict
is called. type = "int"
plots the interaction term that appears
first in the formula along the xaxis, while the second (and possibly
third) variable in an interaction is used as grouping factor(s)
(moderating variable). Use type = "pred"
or type = "eff"
and specify a certain order in the terms
argument to indicate
which variable(s) should be used as moderator.
Depending on the plottype, plot_model()
returns a
ggplot
object or a list of such objects. get_model_data
returns the associated data with the plotobject as tidy data frame, or
(depending on the plottype) a list of such data frames.
Gelman A (2008) "Scaling regression inputs by dividing by two
standard deviations." Statistics in Medicine 27: 2865–2873.
http://www.stat.columbia.edu/~gelman/research/published/standardizing7.pdf
Aiken and West (1991). Multiple Regression: Testing and Interpreting 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 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  # prepare data
library(sjmisc)
data(efc)
efc < to_factor(efc, c161sex, e42dep, c172code)
m < lm(neg_c_7 ~ pos_v_4 + c12hour + e42dep + c172code, data = efc)
# simple forest plot
plot_model(m)
# grouped coefficients
plot_model(m, group.terms = c(1, 2, 3, 3, 3, 4, 4))
# keep only selected terms in the model: pos_v_4, the
# levels 3 and 4 of factor e42dep and levels 2 and 3 for c172code
plot_model(m, terms = c("pos_v_4", "e42dep [3,4]", "c172code [2,3]"))
# multiple plots, as returned from "diagnostic"plot type,
# can be arranged with 'plot_grid()'
## Not run:
p < plot_model(m, type = "diag")
plot_grid(p)
## End(Not run)
# plot random effects
library(lme4)
m < lmer(Reaction ~ Days + (Days  Subject), sleepstudy)
plot_model(m, type = "re")
# plot marginal effects
plot_model(m, type = "pred", terms = "Days")
# plot interactions
## Not run:
m < glm(
tot_sc_e ~ c161sex + c172code * neg_c_7,
data = efc,
family = poisson()
)
# type = "int" automatically selects groups for continuous moderator
# variables  see argument 'mdrt.values'. The following function call is
# identical to:
# plot_model(m, type = "pred", terms = c("c172code", "neg_c_7 [7,28]"))
plot_model(m, type = "int")
# switch moderator
plot_model(m, type = "pred", terms = c("neg_c_7", "c172code"))
# same as
# ggeffects::ggpredict(m, terms = c("neg_c_7", "c172code"))
## End(Not run)
# plot Stanmodel
## Not run:
if (require("rstanarm")) {
data(mtcars)
m < stan_glm(mpg ~ wt + am + cyl + gear, data = mtcars, chains = 1)
plot_model(m, bpe.style = "dot")
}
## End(Not run)

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