View source: R/marginal_comparison.R
marginal_comparison.bgmfit | R Documentation |
The marginal_comparison() function estimates and
compare growth curves such as distance and velocity. This function is a wrapper around the
marginaleffects::comparisons()
and marginaleffects::avg_comparisons()
.
The marginaleffects::comparisons()
computes unit-level (conditional)
estimates whereas marginaleffects::avg_comparisons()
return average
(marginal) estimates. A detailed explanation is available
here.
## S3 method for class 'bgmfit'
marginal_comparison(
model,
resp = NULL,
ndraws = NULL,
draw_ids = NULL,
newdata = NULL,
datagrid = NULL,
re_formula = NA,
allow_new_levels = FALSE,
sample_new_levels = "gaussian",
xrange = 1,
digits = 2,
numeric_cov_at = NULL,
aux_variables = NULL,
levels_id = NULL,
avg_reffects = NULL,
idata_method = NULL,
ipts = NULL,
seed = 123,
future = FALSE,
future_session = "multisession",
cores = NULL,
average = FALSE,
plot = FALSE,
showlegends = NULL,
variables = NULL,
deriv = NULL,
deriv_model = NULL,
comparison = "difference",
type = NULL,
by = FALSE,
conf_level = 0.95,
transform = NULL,
cross = FALSE,
wts = NULL,
hypothesis = NULL,
equivalence = NULL,
eps = NULL,
reformat = NULL,
estimate_center = NULL,
estimate_interval = NULL,
dummy_to_factor = NULL,
verbose = FALSE,
expose_function = FALSE,
usesavedfuns = NULL,
clearenvfuns = NULL,
envir = NULL,
...
)
marginal_comparison(model, ...)
model |
An object of class |
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 |
newdata |
An optional data frame to be used in estimation. If
|
datagrid |
Generate a grid of user-specified values for use in the
|
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 |
xrange |
An integer to set the predictor range (i.e., age) when
executing the interpolation via |
digits |
An integer (default |
numeric_cov_at |
An optional (named list) argument to specify the value
of continuous covariate(s). The default |
aux_variables |
An optional argument to specify the variable(s) that can
be passed to the |
levels_id |
An optional argument to specify the |
avg_reffects |
An optional argument (default |
idata_method |
A character string to indicate the interpolation method.
The number of of interpolation points is set up the |
ipts |
An integer to set the length of the predictor variable to get a
smooth velocity curve. The |
seed |
An integer (default |
future |
A logical (default |
future_session |
A character string to set the session type when
|
cores |
Number of cores to be used when running the parallel
computations (if |
average |
A logical to indicate whether to internally call the
|
plot |
A logical to specify whether to plot comparisons by calling the
|
showlegends |
An argument to specify whether to show legends
( |
variables |
For estimating growth parameters in the current use case,
the |
deriv |
A numeric to specify whether to estimate parameters based on the
differentiation of the distance curve or the model based first derivative.
Please see argument |
deriv_model |
A logical to specify whether to estimate velocity curve
from the derivative function, or the differentiation of the distance curve.
The argument |
comparison |
For estimating growth parameters in the current use case,
options allowed for the |
type |
string indicates the type (scale) of the predictions used to
compute contrasts or slopes. This can differ based on the model
type, but will typically be a string such as: "response", "link", "probs",
or "zero". When an unsupported string is entered, the model-specific list of
acceptable values is returned in an error message. When |
by |
Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:
|
conf_level |
numeric value between 0 and 1. Confidence level to use to build a confidence interval. |
transform |
string or function. Transformation applied to unit-level estimates and confidence intervals just before the function returns results. Functions must accept a vector and return a vector of the same length. Support string shortcuts: "exp", "ln" |
cross |
|
wts |
string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in
|
hypothesis |
specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.
|
equivalence |
Numeric vector of length 2: bounds used for the two-one-sided test (TOST) of equivalence, and for the non-inferiority and non-superiority tests. See Details section below. |
eps |
NULL or numeric value which determines the step size to use when
calculating numerical derivatives: (f(x+eps)-f(x))/eps. When |
reformat |
A logical (default |
estimate_center |
A character string (default |
estimate_interval |
A character string (default |
dummy_to_factor |
A named list (default |
verbose |
An optional argument (logical, 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
|
... |
Further arguments passed to |
A data frame objects with estimates and CIs for computed parameter(s)
Satpal Sandhu satpal.sandhu@bristol.ac.uk
marginaleffects::comparisons()
marginaleffects::avg_comparisons()
marginaleffects::plot_comparisons()
# 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
marginal_comparison(model, parameter = 'apgv', draw_ids = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.