predict_draws.bgmfit {bsitar} | R Documentation |
Predicted values from the posterior predictive distribution
Description
The predict_draws() function is a wrapper around the
brms::predict.brmsfit()
function, which obtains predicted values (and
their summary) from the posterior distribution. See
brms::predict.brmsfit()
for details.
Usage
## S3 method for class 'bgmfit'
predict_draws(
model,
newdata = NULL,
resp = NULL,
dpar = NULL,
ndraws = NULL,
draw_ids = NULL,
re_formula = NA,
allow_new_levels = FALSE,
sample_new_levels = "uncertainty",
incl_autocor = TRUE,
numeric_cov_at = NULL,
levels_id = NULL,
avg_reffects = NULL,
aux_variables = NULL,
ipts = 10,
deriv = 0,
deriv_model = TRUE,
summary = TRUE,
robust = FALSE,
transform = NULL,
probs = c(0.025, 0.975),
xrange = NULL,
xrange_search = NULL,
parms_eval = FALSE,
parms_method = "getPeak",
idata_method = NULL,
verbose = FALSE,
fullframe = NULL,
dummy_to_factor = NULL,
expose_function = FALSE,
usesavedfuns = NULL,
clearenvfuns = NULL,
funlist = NULL,
envir = NULL,
...
)
predict_draws(model, ...)
Arguments
model |
An object of class |
newdata |
An optional data frame for estimation. If |
resp |
A character string (default |
dpar |
Optional name of a predicted distributional parameter. If specified, expected predictions of this parameters are returned. |
ndraws |
A positive integer indicating the number of posterior draws to
use in estimation. If |
draw_ids |
An integer specifying the specific posterior draw(s) to use
in estimation (default |
re_formula |
Option to indicate whether or not to include
individual/group-level effects in the estimation. When |
allow_new_levels |
A flag indicating if new levels of group-level
effects are allowed (defaults to |
sample_new_levels |
Indicates how to sample new levels for grouping
factors specified in |
incl_autocor |
A flag indicating if correlation structures originally
specified via |
numeric_cov_at |
An optional (named list) argument to specify the value
of continuous covariate(s). The default |
levels_id |
An optional argument to specify the |
avg_reffects |
An optional argument (default |
aux_variables |
An optional argument to specify the variable(s) that can
be passed to the |
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 |
summary |
A logical value indicating whether only the estimate should be
computed ( |
robust |
A logical value to specify the summary options. If |
transform |
A function applied to individual draws from the posterior
distribution before computing summaries. The argument |
probs |
The percentiles to be computed by the |
xrange |
An integer to set the predictor range (e.g., age) when
executing the interpolation via |
xrange_search |
A vector of length two or a character string
|
parms_eval |
A logical value to specify whether or not to compute growth parameters on the fly. This is for internal use only and is mainly needed for compatibility across internal functions. |
parms_method |
A character string specifying the method used when
evaluating |
idata_method |
A character string to indicate the interpolation method.
The number of interpolation points is set by the
|
verbose |
A logical argument (default |
fullframe |
A logical value indicating whether to return a
|
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 predict_draws() function computes the fitted values
from the posterior distribution. The brms::predict.brmsfit()
function
from the brms package can be used to obtain predicted (distance)
values when the outcome (e.g., height) is untransformed. However, when the
outcome is log or square root transformed, the brms::predict.brmsfit()
function will return the fitted curve on the log or square root scale. In
contrast, the predict_draws() function returns the fitted values
on the original scale. Furthermore, predict_draws() also computes
the first derivative (velocity), again on the original scale, after making
the necessary back-transformation. Aside from these differences, both
functions (brms::predict.brmsfit()
and predict_draws()) work
similarly. In other words, the user can specify all the options available
in brms::predict.brmsfit()
.
Value
An array of predicted response values. See brms::predict.brmsfit()
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 is fit
# to the 'berkeley_exdata' and saved as an example fit ('berkeley_exfit').
# See the 'bsitar' function for details on 'berkeley_exdata' and
# berkeley_exfit'.
# Check and confirm whether the model fit object 'berkeley_exfit' exists
berkeley_exfit <- getNsObject(berkeley_exfit)
model <- berkeley_exfit
# Population average distance curve
predict_draws(model, deriv = 0, re_formula = NA)
# Individual-specific distance curves
predict_draws(model, deriv = 0, re_formula = NULL)
# Population average velocity curve
predict_draws(model, deriv = 1, re_formula = NA)
# Individual-specific velocity curves
predict_draws(model, deriv = 1, re_formula = NULL)