Usage
"marginal_effects"(x, effects = NULL, conditions = NULL, re_formula = NA, robust = TRUE, probs = c(0.025, 0.975), method = c("fitted", "predict"), surface = FALSE, resolution = 100, too_far = 0, ...)
marginal_effects(x, ...)
"plot"(x, ncol = NULL, points = FALSE, rug = FALSE, stype = c("contour", "raster"), theme = bayesplot::theme_default(), ask = TRUE, plot = TRUE, ...)
Arguments
x
An object usually of class brmsfit
.
effects
An optional character vector naming effects
(main effects or interactions) for which to compute marginal plots.
Interactions are specified by a :
between variable names.
If NULL
(the default), plots are generated for all main effects
and two-way interactions estimated in the model. When specifying
effects
manually, all two-way interactions may be plotted
even if not orginally modeled.
conditions
An optional data.frame
containing variable values
to condition on. Each effect defined in effects
will
be plotted separately for each row of data
.
The row names of data
will be treated as titles of the subplots.
It is recommended to only define a few rows in order to keep the plots clear.
If NULL
(the default), numeric variables will be marginalized
by using their means and factors will get their reference level assigned.
re_formula
A formula containing random effects to be considered
in the marginal predictions. If NULL
, include all random effects;
if NA
(default), include no random effects.
robust
If TRUE
(the default) the median is used as the
measure of central tendency. If FALSE
the mean is used instead.
probs
The quantiles to be used in the computation of credible
intervals (defaults to 2.5 and 97.5 percent quantiles)
method
Either "fitted"
or "predict"
.
If "fitted"
, plot marginal predictions of the regression curve.
If "predict"
, plot marginal predictions of the responses.
surface
Logical; Indicates whether interactions or
two-dimensional smooths should be visualized as a surface.
Defaults to FALSE
. The surface type can be controlled
via argument stype
of the related plotting method.
resolution
Number of support points used to generate
the plots. Higher resolution leads to smoother plots.
Defaults to 100
. If contour
is TRUE
,
this implies 10000
support points for interaction terms,
so it might be necessary to reduce resolution
when only few RAM is available.
too_far
For contour plots only: Grid points that are too
far away from the actual data points can be excluded from the plot.
too_far
determines what is too far. The grid is scaled into
the unit square and then grid points more than too_far
from the predictor variables are excluded. By default, all
grid points are used. Ignored for non-contour plots.
ncol
Number of plots to display per column for each effect.
If NULL
(default), ncol
is computed internally based
on the number of rows of data
.
points
Logical; indicating whether the original data points
should be added via geom_point
.
Default is FALSE
. Note that only those data points will be added
that match the specified conditions defined in conditions
. rug
Logical; indicating whether a rug representation of predictor
values should be added via geom_rug
.
Default is FALSE
. stype
Indicates how surface plots should be displayed.
Either "contour"
or "raster"
.
ask
logical; indicates if the user is prompted
before a new page is plotted.
Only used if plot
is TRUE
.
plot
logical; indicates if plots should be
plotted directly in the active graphic device.
Defaults to TRUE
.