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,
transform = NULL,
resolution = 100,
select_points = 0,
too_far = 0,
prob = 0.95,
robust = TRUE,
newdata = NULL,
ndraws = 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,
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 |
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 to be used in estimation. If
|
ndraws |
A positive integer indicating the number of posterior draws to
be used in estimation. If |
draw_ids |
An integer indicating the specific posterior draw(s)
to be used 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 to get a
smooth velocity curve. The |
deriv |
An integer to indicate whether to estimate distance curve or its
derivative (i.e., velocity curve). The |
deriv_model |
A logical to specify whether to estimate velocity curve
from the derivative function, or the differentiation of the distance curve.
The argument |
idata_method |
A character string to indicate the interpolation method.
The number of of interpolation points is set up the |
verbose |
An optional argument (logical, default |
dummy_to_factor |
A named list (default |
expose_function |
An optional logical argument to indicate whether to
expose Stan functions (default |
usesavedfuns |
A logical (default |
clearenvfuns |
A logical to indicate whether to clear the exposed
function from the environment ( |
envir |
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 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 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, 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)