fitted_draws.bgmfit | R Documentation |
The fitted_draws() is a wrapper around the
brms::fitted.brmsfit()
function to obtain fitted values (and their
summary) from the posterior draws. See brms::fitted.brmsfit()
for
details.
## S3 method for class 'bgmfit'
fitted_draws(
model,
newdata = NULL,
resp = 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,
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,
envir = NULL,
...
)
fitted_draws(model, ...)
model |
An object of class |
newdata |
An optional data frame to be used in estimation. If
|
resp |
A character string (default |
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 |
re_formula |
Option to indicate whether or not to include the
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 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 |
summary |
A logical indicating whether only the estimate should be
computed ( |
robust |
A logical to specify the summarize options. If |
probs |
The percentiles to be computed by the |
xrange |
An integer to set the predictor range (i.e., age) when
executing the interpolation via |
xrange_search |
A vector of length two, or a character string
|
parms_eval |
A logical to specify whether or not to get growth parameters on the fly. This is for internal use only and mainly needed for compatibility across internal functions. |
parms_method |
A character to specify the method used to when evaluating
|
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 |
fullframe |
A logical to indicate whether to return |
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 |
The fitted_draws() computes the fitted values from the
posterior draws. The brms::fitted.brmsfit()
function from the brms
package can used to get the fitted (distance) values when outcome (e.g.,
height) is untransformed. However, when the outcome is log or square root
transformed, the brms::fitted.brmsfit()
function will return the fitted
curve on the log or square root scale whereas the fitted_draws()
function returns the fitted values on the original scale. Furthermore, the
fitted_draws() also compute the first derivative of (velocity)
that too on the original scale after making required back-transformation.
Except for these differences, both these functions (i.e.,
brms::fitted.brmsfit()
and fitted_draws()
) work in the same manner. In
other words, user can specify all the options available in the
brms::fitted.brmsfit()
.
An array of predicted mean response values. See brms::fitted.brmsfit for details.
Satpal Sandhu satpal.sandhu@bristol.ac.uk
brms::fitted.brmsfit()
# 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
fitted_draws(model, deriv = 0, re_formula = NA)
# Individual-specific distance curves
fitted_draws(model, deriv = 0, re_formula = NULL)
# Population average velocity curve
fitted_draws(model, deriv = 1, re_formula = NA)
# Individual-specific velocity curves
fitted_draws(model, deriv = 1, re_formula = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.