plot_conditional_effects.bgmfit {bsitar} | R Documentation |
Visualize conditional effects of predictor
Description
Display conditional effects of one or more numeric and/or categorical predictors including two-way interaction effects.
Usage
## S3 method for class 'bgmfit'
plot_conditional_effects(
model,
effects = NULL,
conditions = NULL,
int_conditions = NULL,
re_formula = NA,
spaghetti = FALSE,
surface = FALSE,
categorical = FALSE,
ordinal = FALSE,
method = "posterior_epred",
transform = NULL,
resolution = 100,
select_points = 0,
too_far = 0,
prob = 0.95,
robust = TRUE,
newdata = NULL,
ndraws = NULL,
dpar = NULL,
draw_ids = NULL,
levels_id = NULL,
resp = NULL,
ipts = 10,
deriv = 0,
deriv_model = NULL,
idata_method = NULL,
verbose = FALSE,
dummy_to_factor = NULL,
expose_function = FALSE,
usesavedfuns = NULL,
clearenvfuns = NULL,
funlist = NULL,
envir = NULL,
...
)
plot_conditional_effects(model, ...)
Arguments
model |
An object of class |
effects |
An optional character vector naming effects (main effects or
interactions) for which to compute conditional plots. Interactions are
specified by a |
conditions |
An optional |
int_conditions |
An optional named |
re_formula |
A formula containing group-level effects to be considered
in the conditional predictions. If |
spaghetti |
Logical. Indicates if predictions should
be visualized via spaghetti plots. Only applied for numeric
predictors. If |
surface |
Logical. Indicates if interactions or
two-dimensional smooths should be visualized as a surface.
Defaults to |
categorical |
Logical. Indicates if effects of categorical
or ordinal models should be shown in terms of probabilities
of response categories. Defaults to |
ordinal |
(Deprecated) Please use argument |
method |
Method used to obtain predictions. Can be set to
|
transform |
A function or a character string naming
a function to be applied on the predicted responses
before summary statistics are computed. Only allowed
if |
resolution |
Number of support points used to generate
the plots. Higher resolution leads to smoother plots.
Defaults to |
select_points |
Positive number.
Only relevant if |
too_far |
Positive number.
For surface plots only: Grid points that are too
far away from the actual data points can be excluded from the plot.
|
prob |
A value between 0 and 1 indicating the desired probability to be covered by the uncertainty intervals. The default is 0.95. |
robust |
If |
newdata |
An optional data frame for estimation. If |
ndraws |
A positive integer indicating the number of posterior draws to
use in estimation. If |
dpar |
Optional name of a predicted distributional parameter. If specified, expected predictions of this parameters are returned. |
draw_ids |
An integer specifying the specific posterior draw(s) to use
in estimation (default |
levels_id |
An optional argument to specify the |
resp |
A character string (default |
ipts |
An integer to set the length of the predictor variable for
generating a smooth velocity curve. If |
deriv |
An integer indicating whether to estimate the distance curve
or its derivative (velocity curve). The default |
deriv_model |
A logical value specifying whether to estimate the
velocity curve from the derivative function or by differentiating the
distance curve. Set |
idata_method |
A character string to indicate the interpolation method.
The number of interpolation points is set by the
|
verbose |
A logical argument (default |
dummy_to_factor |
A named list (default
|
expose_function |
A logical argument (default |
usesavedfuns |
A logical value (default |
clearenvfuns |
A logical value indicating whether to clear the exposed
Stan functions from the environment ( |
funlist |
A list (default |
envir |
The environment used for function evaluation. The default is
|
... |
Additional arguments passed to the |
Details
The plot_conditional_effects() is a wrapper around the
brms::conditional_effects()
. The brms::conditional_effects()
function
from the brms package can be used to plot the fitted (distance) curve
when response (e.g., height) is not transformed. However, when the outcome
is log or square root transformed, the brms::conditional_effects()
will
return the fitted curve on the log or square root scale, whereas the
plot_conditional_effects() will return the fitted curve on the
original scale. Furthermore, the plot_conditional_effects() also
plots the velocity curve on the original scale after making the required
back-transformation. Apart from these differences, both these functions
(brms::conditional_effects and plot_conditional_effects()) work
in the same manner. In other words, the user can specify all the arguments
which are available in the brms::conditional_effects()
.
Value
An object of class 'brms_conditional_effects'
, which is a
named list with one data.frame per effect containing all information
required to generate conditional effects plots. See
brms::conditional_effects()
for details.
Author(s)
Satpal Sandhu satpal.sandhu@bristol.ac.uk
See Also
Examples
# Fit Bayesian SITAR model
# To avoid mode estimation which takes time, the Bayesian SITAR model fit to
# the 'berkeley_exdata' has been saved as an example fit ('berkeley_exfit').
# See 'bsitar' function for details on 'berkeley_exdata' and 'berkeley_exfit'.
# Check and confirm whether model fit object 'berkeley_exfit' exists
berkeley_exfit <- getNsObject(berkeley_exfit)
model <- berkeley_exfit
# Population average distance curve
plot_conditional_effects(model, deriv = 0, re_formula = NA)
# Individual-specific distance curves
plot_conditional_effects(model, deriv = 0, re_formula = NULL)
# Population average velocity curve
plot_conditional_effects(model, deriv = 1, re_formula = NA)
# Individual-specific velocity curves
plot_conditional_effects(model, deriv = 1, re_formula = NULL)