bsitar {bsitar} | R Documentation |
Fit Bayesian SITAR growth curve model
Description
The bsitar() is the main function that fits the Bayesian version of the super imposition by translation and rotation (SITAR) model. The SITAR model is a nonlinear mixed effects model that has been used extensively to summarize growth processes (such as height and weight) from early childhood through the adulthood. The frequentist version of the SITAR model can be fit by using an already available R package, sitar (Cole 2022). Besides Bayesian implementation, the bsitar package greatly enhances the modelling capabilities of the SITAR. For example, in addition to the univariate analysis (i.e, modelling a single outcome), the bsitar allows univariate-by-subgroup and multivariate model fitting. In univariate-by-subgroup analysis, a single outcome is simultaneously analysed for subgroups defined by a factor variable such as gender. An advantage of univariate-by-subgroup analysis is that posterior draws for each sub group are part of a single model object that makes it possible to compare coefficients across groups and also test various hypotheses. The multivariate analysis involves simultaneous joint modelling of two or more outcomes.
Usage
bsitar(
x,
y,
id,
data,
df = 4,
knots = NA,
fixed = a + b + c,
random = a + b + c,
xoffset = mean,
bstart = xoffset,
cstart = 0,
xfun = NULL,
yfun = NULL,
bound = 0.04,
terms_rhs = NULL,
a_formula = ~1,
b_formula = ~1,
c_formula = ~1,
d_formula = ~1,
s_formula = ~1,
a_formula_gr = ~1,
b_formula_gr = ~1,
c_formula_gr = ~1,
d_formula_gr = ~1,
a_formula_gr_str = NULL,
b_formula_gr_str = NULL,
c_formula_gr_str = NULL,
d_formula_gr_str = NULL,
d_adjusted = FALSE,
sigma_formula = NULL,
sigma_formula_gr = NULL,
sigma_formula_gr_str = NULL,
dpar_formula = NULL,
autocor_formula = NULL,
family = gaussian(),
custom_family = NULL,
custom_stanvars = NULL,
group_arg = list(groupvar = NULL, by = NULL, cor = un, cov = NULL, dist = gaussian),
sigma_group_arg = list(groupvar = NULL, by = NULL, cor = un, cov = NULL, dist =
gaussian),
univariate_by = list(by = NA, cor = un, terms = subset),
multivariate = list(mvar = FALSE, cor = un, rescor = TRUE),
a_prior_beta = student_t(3, ymean, ysd, autoscale = TRUE),
b_prior_beta = student_t(3, 0, 3.5, autoscale = FALSE),
c_prior_beta = student_t(3, 0, 1.5, autoscale = FALSE),
d_prior_beta = student_t(3, 0, 1, autoscale = TRUE),
s_prior_beta = student_t(3, 0, lm, autoscale = TRUE),
a_cov_prior_beta = student_t(3, 0, 5, autoscale = FALSE),
b_cov_prior_beta = student_t(3, 0, 1, autoscale = FALSE),
c_cov_prior_beta = student_t(3, 0, 0.1, autoscale = FALSE),
d_cov_prior_beta = student_t(3, 0, 1, autoscale = FALSE),
s_cov_prior_beta = student_t(3, 0, 10, autoscale = FALSE),
a_prior_sd = student_t(3, 0, ysd, autoscale = TRUE),
b_prior_sd = student_t(3, 0, 2, autoscale = FALSE),
c_prior_sd = student_t(3, 0, 1.25, autoscale = FALSE),
d_prior_sd = student_t(3, 0, 1, autoscale = TRUE),
a_cov_prior_sd = student_t(3, 0, 5, autoscale = FALSE),
b_cov_prior_sd = student_t(3, 0, 1, autoscale = FALSE),
c_cov_prior_sd = student_t(3, 0, 0.1, autoscale = FALSE),
d_cov_prior_sd = student_t(3, 0, 1, autoscale = FALSE),
a_prior_sd_str = NULL,
b_prior_sd_str = NULL,
c_prior_sd_str = NULL,
d_prior_sd_str = NULL,
a_cov_prior_sd_str = NULL,
b_cov_prior_sd_str = NULL,
c_cov_prior_sd_str = NULL,
d_cov_prior_sd_str = NULL,
sigma_prior_beta = student_t(3, 0, 1, autoscale = FALSE),
sigma_cov_prior_beta = student_t(3, 0, 0.5, autoscale = FALSE),
sigma_prior_sd = student_t(3, 0, 0.25, autoscale = FALSE),
sigma_cov_prior_sd = student_t(3, 0, 0.15, autoscale = FALSE),
sigma_prior_sd_str = NULL,
sigma_cov_prior_sd_str = NULL,
rsd_prior_sigma = exponential(ysd, autoscale = TRUE),
dpar_prior_sigma = student_t(3, 0, ysd, autoscale = TRUE),
dpar_cov_prior_sigma = student_t(3, 0, 1, autoscale = FALSE),
autocor_prior_acor = uniform(-1, 1, autoscale = FALSE),
autocor_prior_unstr_acor = lkj(1),
gr_prior_cor = lkj(1),
gr_prior_cor_str = lkj(1),
sigma_prior_cor = lkj(1),
sigma_prior_cor_str = lkj(1),
mvr_prior_rescor = lkj(1),
init = NULL,
init_r = NULL,
a_init_beta = lm,
b_init_beta = 0,
c_init_beta = 0,
d_init_beta = 0,
s_init_beta = lm,
a_cov_init_beta = 0,
b_cov_init_beta = 0,
c_cov_init_beta = 0,
d_cov_init_beta = 0,
s_cov_init_beta = lm,
a_init_sd = random,
b_init_sd = random,
c_init_sd = random,
d_init_sd = random,
a_cov_init_sd = random,
b_cov_init_sd = random,
c_cov_init_sd = random,
d_cov_init_sd = random,
sigma_init_beta = random,
sigma_cov_init_beta = random,
sigma_init_sd = random,
sigma_cov_init_sd = random,
gr_init_cor = random,
sigma_init_cor = random,
rsd_init_sigma = random,
dpar_init_sigma = random,
dpar_cov_init_sigma = random,
autocor_init_acor = random,
autocor_init_unstr_acor = random,
mvr_init_rescor = random,
r_init_z = random,
vcov_init_0 = TRUE,
jitter_init_beta = NULL,
jitter_init_sd = NULL,
jitter_init_cor = NULL,
prior_data = NULL,
init_data = NULL,
init_custom = NULL,
verbose = FALSE,
expose_function = FALSE,
get_stancode = FALSE,
get_standata = FALSE,
get_formula = FALSE,
get_stanvars = FALSE,
get_priors = FALSE,
get_priors_eval = FALSE,
get_init_eval = FALSE,
validate_priors = FALSE,
set_self_priors = NULL,
set_replace_priors = NULL,
set_same_priors_hierarchy = FALSE,
outliers = NULL,
unused = NULL,
chains = 4,
iter = 2000,
warmup = floor(iter/2),
thin = 1,
cores = getOption("mc.cores", "optimize"),
backend = getOption("brms.backend", "rstan"),
threads = getOption("brms.threads", "optimize"),
opencl = getOption("brms.opencl", NULL),
normalize = getOption("brms.normalize", TRUE),
algorithm = getOption("brms.algorithm", "sampling"),
control = list(adapt_delta = 0.8, max_treedepth = 15),
sample_prior = "no",
save_pars = NULL,
drop_unused_levels = TRUE,
stan_model_args = list(),
refresh = NULL,
silent = 1,
seed = 123,
save_model = NULL,
fit = NA,
file = NULL,
file_compress = TRUE,
file_refit = getOption("brms.file_refit", "never"),
future = getOption("future", FALSE),
parameterization = "ncp",
...
)
Arguments
x |
Predictor variable (typically age in years). For |
y |
Response variable (e.g., repeated height measurements). For
|
id |
A factor variable uniquely identifying the groups (e.g.,
individuals) in the data frame. For |
data |
Data frame containing variables such as |
df |
Degrees of freedom for the natural cubic spline design matrix
(default |
knots |
A numeric vector vector specifying the knots for the natural
cubic spline design matrix (default |
fixed |
A character string specifying the fixed effects structure
(default |
random |
A character string specifying the random effects structure
(default |
xoffset |
An optional character string, or a numeric value to set up the
origin of the predictor variable, |
bstart |
An optional character string, or a numeric value to set up the
origin of the fixed effect parameter |
cstart |
An optional character string, or a numeric value to set up the
origin of the fixed effect parameter |
xfun |
An optional character string to specify the transformation of the
predictor variable, The default is |
yfun |
An optional character string to specify the transformation of the
response variable, The default is |
bound |
An optional real number to extend the span of the predictor
variable |
terms_rhs |
An optional character string (default |
a_formula |
Formula for the fixed effect parameter, |
b_formula |
Formula for the fixed effect parameter, |
c_formula |
Formula for the fixed effect parameter, |
d_formula |
Formula for the fixed effect parameter, |
s_formula |
Formula for the fixed effect parameter, |
a_formula_gr |
Formula for the random effect parameter, |
b_formula_gr |
Formula for the random effect parameter, |
c_formula_gr |
Formula for the random effect parameter, |
d_formula_gr |
Formula for the random effect parameter, |
a_formula_gr_str |
Formula for the random effect parameter, |
b_formula_gr_str |
Formula for the random effect parameter, |
c_formula_gr_str |
Formula for the random effect parameter, |
d_formula_gr_str |
Formula for the random effect parameter, |
d_adjusted |
A logical indicator to set up the scale of predictor
variable |
sigma_formula |
Formula for the fixed effect distributional parameter,
|
sigma_formula_gr |
Formula for the random effect parameter, |
sigma_formula_gr_str |
Formula for the random effect parameter,
|
dpar_formula |
Formula for the distributional fixed effect parameter,
|
autocor_formula |
Formula to set up the autocorrelation structure of
residuals (default
See |
family |
Family distribution (default |
custom_family |
Specify custom families (i.e. response distribution).
Default |
custom_stanvars |
Prepare and pass user-defined variables that need to be
added to the Stan's program blocks (default |
group_arg |
Specify arguments for group-level random effects. The
Note that user need not to define all or any of these options (i.e.,
|
sigma_group_arg |
Specify arguments for modelling distributional level
random effects, |
univariate_by |
Set up the univariate-by-subgroup model fitting (default
|
multivariate |
Set up the multivariate model fitting (default
|
a_prior_beta |
Specify priors for the fixed effect parameter,
The location parameter for the location-scale based distributions can be
specified as mean (by specifying |
b_prior_beta |
Specify priors for the fixed effect parameter, |
c_prior_beta |
Specify priors for the fixed effect parameter, |
d_prior_beta |
Specify priors for the fixed effect parameter, |
s_prior_beta |
Specify priors for the fixed effect parameter,
It is observed that location scale based prior distributions (e.g,
|
a_cov_prior_beta |
Specify priors for the covariate(s) included in the
fixed effect parameter, |
b_cov_prior_beta |
Specify priors for the covariate(s) included in the
fixed effect parameter, |
c_cov_prior_beta |
Specify priors for the covariate(s) included in the
fixed effect parameter, |
d_cov_prior_beta |
Specify priors for the covariate(s) included in the
fixed effect parameter, |
s_cov_prior_beta |
Specify priors for the covariate(s) included in the
fixed effect parameter, |
a_prior_sd |
Specify priors for the random effect parameter, |
b_prior_sd |
Specify priors for the random effect parameter, |
c_prior_sd |
Specify priors for the random effect parameter, |
d_prior_sd |
Specify priors for the random effect parameter,
|
a_cov_prior_sd |
Specify priors for the covariate(s) included in the
random effect parameter, |
b_cov_prior_sd |
Specify priors for the covariate(s) included in the
random effect parameter, |
c_cov_prior_sd |
Specify priors for the covariate(s) included in the
random effect parameter, |
d_cov_prior_sd |
Specify priors for the covariate(s) included in the
random effect parameter, |
a_prior_sd_str |
Specify priors for the random effect parameter, |
b_prior_sd_str |
Specify priors for the random effect parameter, |
c_prior_sd_str |
Specify priors for the random effect parameter, |
d_prior_sd_str |
Specify priors for the random effect parameter, |
a_cov_prior_sd_str |
Specify priors for the covariate(s) included in the
random effect parameter, |
b_cov_prior_sd_str |
Specify priors for the covariate(s) included in the
random effect parameter, |
c_cov_prior_sd_str |
Specify priors for the covariate(s) included in the
random effect parameter, |
d_cov_prior_sd_str |
Specify priors for the covariate(s) included in the
random effect parameter, |
sigma_prior_beta |
Specify priors for the fixed effect distributional
parameter, |
sigma_cov_prior_beta |
Specify priors for the covariate(s) included in
the fixed effect distributional parameter, |
sigma_prior_sd |
Specify priors for the random effect distributional
parameter, |
sigma_cov_prior_sd |
Specify priors for the covariate(s) included in the
random effect distributional parameter, |
sigma_prior_sd_str |
Specify priors for the the random effect
distributional parameter, |
sigma_cov_prior_sd_str |
Specify priors for the covariate(s) included in
the random effect distributional parameter, |
rsd_prior_sigma |
Specify priors for the residual standard deviation
parameter |
dpar_prior_sigma |
Specify priors for the fixed effect distributional
parameter |
dpar_cov_prior_sigma |
Specify priors for the covariate(s) included in
the fixed effect distributional parameter |
autocor_prior_acor |
Specify priors for the autocorrelation parameters
when fitting a model with the |
autocor_prior_unstr_acor |
Specify priors for the autocorrelation
parameters when fitting a model with the unstructured ( |
gr_prior_cor |
Specify priors for the correlation parameter(s) of
group-level random effects (default |
gr_prior_cor_str |
Specify priors for the correlation parameter(s) of
group-level random effects when fitting a hierarchical model with three or
more levels of hierarchy (default |
sigma_prior_cor |
Specify priors for the correlation parameter(s) of
distributional random effects |
sigma_prior_cor_str |
Specify priors for the correlation parameter(s) of
distributional random effects |
mvr_prior_rescor |
Specify priors for the residual correlation parameter
when fitting a multivariate model (default |
init |
Initial values for the sampler. If |
init_r |
A positive real value to set range for the random generation of
initial values (default |
a_init_beta |
Initial values for the fixed effect parameter, |
b_init_beta |
Initial values for the fixed effect parameter, |
c_init_beta |
Initial values for the fixed effect parameter, |
d_init_beta |
Initial values for the fixed effect parameter, |
s_init_beta |
Initial values for the fixed effect parameter, |
a_cov_init_beta |
Initial values for the covariate(s) included in the
fixed effect parameter, |
b_cov_init_beta |
Initial values for covariate(s) included in the fixed
effect parameter, |
c_cov_init_beta |
Initial values for covariate(s) included in the fixed
effect parameter, |
d_cov_init_beta |
Initial values for covariate(s) included in the fixed
effect parameter, |
s_cov_init_beta |
Initial values for covariate(s) included in the fixed
effect parameter, |
a_init_sd |
Initial value for the standard deviation of group level
random effect parameter,
Note that these option described above ( |
b_init_sd |
Initial value for the standard deviation of group level
random effect parameter, |
c_init_sd |
Initial values for the group level random effect parameter,
|
d_init_sd |
Initial value for the standard deviation of group level
random effect parameter, |
a_cov_init_sd |
Initial values for the covariate(s) included in the
random effect parameter, |
b_cov_init_sd |
Initial values for the covariate(s) included in the
random effect parameter, |
c_cov_init_sd |
Initial values for the covariate(s) included in the
random effect parameter, |
d_cov_init_sd |
Initial values for the covariate(s) included in the
random effect parameter, |
sigma_init_beta |
Initial values for the fixed effect distributional
parameter, |
sigma_cov_init_beta |
Initial values for the covariate(s)
included in the fixed effect distributional parameter, |
sigma_init_sd |
Initial value for the standard deviation of
distributional random effect parameter, |
sigma_cov_init_sd |
Initial values for the covariate(s) included in the
distributional random effect parameter, |
gr_init_cor |
Initial values for the correlation parameters of
group-level random effects parameters (default 'random'). Allowed options
are |
sigma_init_cor |
Initial values for the correlation parameters of
distributional random effects parameter |
rsd_init_sigma |
Initial values for the residual standard deviation
parameter, |
dpar_init_sigma |
Initial values for the distributional parameter
|
dpar_cov_init_sigma |
Initial values for the covariate(s) included in the
distributional parameter, |
autocor_init_acor |
Initial values for autocorrelation parameter (see
|
autocor_init_unstr_acor |
Initial values for unstructured residual
autocorrelation parameters (default 'random'). Allowed options are
|
mvr_init_rescor |
Initial values for the residual correlation parameter
when fitting a |
r_init_z |
Initial values for the standardized group level random effect
parameters (default 'random'). These parameters are part of the Non-Centered
Parameterization (NCP) approach used in the |
vcov_init_0 |
A logical (default |
jitter_init_beta |
A value as proportion (between 0 and 1) to perturb the
initial values for fixed effect parameters. The default is |
jitter_init_sd |
A value as proportion (between 0 and 1) to perturb
the initials for standard deviation of random effect parameters. The default
is |
jitter_init_cor |
A value as proportion (between 0 and 1) to perturb the
initials for correlation parameters of random effects. The default is
|
prior_data |
An optional argument (a named list, default
|
init_data |
An optional argument (a named list, default |
init_custom |
Specify a custom initials object (a named list). The named
list is directly passed to the |
verbose |
An optional argument (logical, default |
expose_function |
An optional argument (logical, default |
get_stancode |
An optional argument (logical, default |
get_standata |
An optional argument (logical, default |
get_formula |
An optional argument (logical, default |
get_stanvars |
An optional argument (logical, default |
get_priors |
An optional argument (logical, default |
get_priors_eval |
An optional argument (logical, default |
get_init_eval |
An optional argument (logical, default |
validate_priors |
An optional argument (logical, default |
set_self_priors |
An optional argument (default |
set_replace_priors |
An optional argument (default |
set_same_priors_hierarchy |
An optional argument (default |
outliers |
An optional argument (default |
unused |
An optional formula that defines variables that are unused in the model but should still be stored in the model's data frame. This can be useful when variables are required during the post-processing. |
chains |
Number of Markov chains (default 4). |
iter |
Number of total iterations per chain, including warmup (default 2000) |
warmup |
A positive integer specifying the number of warmup (aka burnin)
iterations. This also specifies the number of iterations used for stepsize
adaptation, so warmup draws should not be used for inference. The number of
warmup should not be larger than |
thin |
A positive integer. Set |
cores |
Number of cores to be used when executing the chains in parallel.
See |
backend |
A character string naming the package to be used when executing
the the Stan model. Options are |
threads |
Number of threads to be used in within-chain parallelization.
Note that unlike the |
opencl |
The platform and device IDs of the OpenCL device to use for
fitting using GPU support. If you don't know the IDs of your OpenCL device,
|
normalize |
Indicates whether normalization constants should be included
in the Stan code (default |
algorithm |
Character string naming the estimation approach to use.
Options are |
control |
A named |
sample_prior |
Indicates whether to draw sample from priors in addition
to the posterior draws. Options are |
save_pars |
An object generated by |
drop_unused_levels |
Should unused factors levels in the data be dropped?
Defaults to |
stan_model_args |
A |
refresh |
An integer to set the printing of every nth iteration. Default
|
silent |
Verbosity level between |
seed |
The seed for random number generation to make results
reproducible. If |
save_model |
A character string or |
fit |
An instance of S3 class |
file |
Either |
file_compress |
Logical or a character string, specifying one of the
compression algorithms supported by |
file_refit |
Modifies when the fit stored via the |
future |
Logical; If |
parameterization |
A character string to specify Non-centered
parameterization, NCP ( |
... |
Further arguments passed to |
Details
The SITAR is a shape-invariant nonlinear mixed effect growth
curve model that fits a population average (i.e., mean average) curve to
the data, and aligns each individual's growth trajectory to the underlying
population average curve via a set of (typically) three random effects: the
size
, timing
and intensity
. Additionally, a slope
parameter can be included as a random effect to estimate the variability in
adult growth rate (See sitar::sitar()
for details). The concept of shape
invariant model (SIM) was first described by
Lindstrom (1995) and later used by
Beath (2007) to model infant growth data (birth
to 2 years). The current version of the SITAR model is developed by
Cole et al. (2010) and has been used extensively for
modelling growth data
(see Nembidzane et al. 2020 and Sandhu 2020).
The frequentist version of the SITAR model can be fit by using an
already available R package, the sitar (Cole 2022).
The framework of Bayesian implementation of the SITAR model in
bsitar package is same as the sitar package with the exception
that unlike the sitar package which uses B spline basis for the
natural cubic spline design matrix (by calling the splines::ns()
), the
bsitar package uses the truncated power basis approach (see
Harrell and others (2001), and
Harrell Jr. (2022) for details) to construct the spline
design matrix. Note that bsitar package builds the spline design
matrix on the fly which is then included in the functions
block of
the Stan program and hence compiled (via the c++) during the model fit.
Like sitar package (Cole et al. 2010), the bsitar
package fits SITAR model with (usually) up to three random effects:
the size (parameter defined as a
), the timing (parameter defined as
b
) and the intensity (parameter defined as c
). In addition,
there is a slope parameter (defined as d
) that models the variability
in the adult slope of the growth curve (See sitar::sitar()
for details).
Please note that author of the sitar package
(Cole et al. 2010) enforces the inclusion of parameter
d
as a random effects only and therefore excludes it from the
fixed fixed structure of the model. However, the bsitar package allows
inclusion of parameter d
in fixed and/or in the random effects
structures of the SITAR model. For the three parameter version of the
SITAR model (default), the fixed effects structure (i.e., population
average trajectory) is specified as fixed = 'a+b+c'
, and the
random effects structure that captures the deviation of individual
trajectories from the population average curve is specified as random
= 'a+b+c'
. Note that user need not to include all the three parameters in
the fixed or the random effect structure. For example, a fixed effect
version of the SITAR model can be fit by setting randoms as an empty
string i.e., random = ''
. Furthermore, the fixed effect structure may
include only a sub set of the parameters e.g., size and timing parameters
(fixed = 'a+b'
) or the size and the intensity parameters
(fixed = 'a+c'
). The four parameters version of the SITAR
model is fit by including parameter d
in the fixed
and/or the
random
arguments. Similar to the three parameter SITAR model,
user can fit model with a sub set of the fixed and/or the random effects.
The sitar package internally depends on the brms
package (see Bürkner 2022; Bürkner 2021). The brms can
fit a wide range of hierarchical linear and nonlinear regression models
including multivariate models. The brms itself depends on the Stan
software program full Bayesian inference
(see Stan Development Team 2023; Gelman et al. 2015). Like
brms, the bsitar package allows a wide range of prior
specifications that encourage the users to specify priors that
actually reflect their prior knowledge about the human growth processes,
(such as timing and intensity of the growth spurt). For prior
specification, we follow the carefully crafted approaches used in the
brms and rstanarm packages. For example, we follow the
brms package in using the student_t
distribution for the
regression coefficients as well as the standard deviation for group
level random effects, but set exponential
distribution for the
residual standard deviation as used in the rstanarm package.
Like brms and rstanarm packages, the bsitar package allows
for auto scaling of the scale parameter for the location-scale based
distributions such as normal
and student_t
. While
rstanarm earlier used to set autosclae
as 2.5
(recently
authors changed this behavior to FALSE
), the brms package sets
it as 1.0
or 2.5
depending on the standard deviation of the
response variable (See brms::prior()
). The bsitar package, on the
other hand, offers full flexibility in choosing the scale factor as any real
number (e.g., autosclae = 5.0
). When autosclae = TRUE
, the
2.5
is the default scaling factor. We strongly recommend to go
through the well documented details on prior specifications used in
brms and rstanarm packages.
Like brms package, the bsitar package offers a range of tools to
evaluate the model fit that include posterior predictive check (see
brms::pp_check()
) and the leave one out (loo
) cross validation (see
brms::loo()
). Furthermore, while the excellent post-processing support
offered by the brms package is directly available to the users, the
bsitar package includes many customized functions that allow for
estimation and visualization of population average and individual specific
distance (increase in size) and velocity (change in rate of growth), as well
as computation of population average and individual specific growth
parameters such as age at peak growth velocity (APGV) and the peak growth
velocity (PGV).
Finally, the bsitar package allows three different types of model
specifications: 'univariate'
, 'univariate_by'
and
'multivariate'
. A 'univariate'
fitting involves a single model
applied to an outcome whereas both 'univariate_by'
and
'multivariate'
specifications comprise two or more sub models. The
'univariate_by'
fits two or more sub models to an outcome variable
defined by a factor variable (e.g, sex). The data are typically stacked and
the factor variable is used to set-up the sub models via the 'subset'
option available in the brms::brm()
. The 'multivariate'
model allows
simultaneous modelling of two or more outcomes with joint a distribution of
the random effects. For both 'univariate_by'
and 'multivariate'
models, the bsitar package allows full flexibility in specifying
separate arguments such as predictor variables (x
), degree of freedom
(df
) for design matrix as well as the priors and the initial values.
Furthermore, to enhance the ease of specifying different options and to make
it user-friendly, there is no need to enclose the character option(s) in
single or double quotes. For example to specify the 'univariate_by'
for sex, the univariate_by = sex
is same as univariate_by =
'sex'
or univariate_by = "sex"
. The same applies for all character
string options.
Value
An object of class brmsfit, bsiatr
, that contains the posterior
draws and other useful information about the model.
Note
The package is under continuous development and new models and post-processing features will be added soon.
Author(s)
Satpal Sandhu satpal.sandhu@bristol.ac.uk
References
Beath KJ (2007).
“Infant growth modelling using a shape invariant model with random effects.”
Statistics in Medicine, 26(12), 2547–2564.
doi:10.1002/sim.2718, Type: Journal article.
Bürkner P (2021).
“Bayesian Item Response Modeling in R with brms and Stan.”
Journal of Statistical Software, 100(5), 1–54.
doi:10.18637/jss.v100.i05.
Bürkner P (2022).
brms: Bayesian Regression Models using Stan.
R package version 2.18.0, https://CRAN.R-project.org/package=brms.
Cole T (2022).
sitar: Super Imposition by Translation and Rotation Growth Curve Analysis.
R package version 1.3.0, https://CRAN.R-project.org/package=sitar.
Cole TJ, Donaldson MDC, Ben-Shlomo Y (2010).
“SITAR—a useful instrument for growth curve analysis.”
International Journal of Epidemiology, 39(6), 1558–1566.
ISSN 0300-5771, doi:10.1093/ije/dyq115, tex.eprint: https://academic.oup.com/ije/article-pdf/39/6/1558/18480886/dyq115.pdf.
Gelman A, Lee D, Guo J (2015).
“Stan: A Probabilistic Programming Language for Bayesian Inference and Optimization.”
Journal of Educational and Behavioral Statistics, 40(5), 530-543.
doi:10.3102/1076998615606113.
Harrell FE, others (2001).
Regression modeling strategies: with applications to linear models, logistic regression, and survival analysis, volume 608.
Springer.
Harrell Jr. FE (2022).
Hmisc: Harrell Miscellaneous.
R package version 4.7-2, https://hbiostat.org/R/Hmisc/.
Lindstrom MJ (1995).
“Self-modelling with random shift and scale parameters and a free-knot spline shape function.”
Statistics in Medicine, 14(18), 2009-2021.
doi:10.1002/sim.4780141807, https://pubmed.ncbi.nlm.nih.gov/8677401/.
Nembidzane C, Lesaoana M, Monyeki KD, Boateng A, Makgae PJ (2020).
“Using the SITAR Method to Estimate Age at Peak Height Velocity of Children in Rural South Africa: Ellisras Longitudinal Study.”
Children, 7(3), 17.
ISSN 2227-9067, doi:10.3390/children7030017, https://www.mdpi.com/2227-9067/7/3/17.
Sandhu SS (2020).
Analysis of longitudinal jaw growth data to study sex differences in timing and intensity of the adolescent growth spurt for normal growth and skeletal discrepancies.
Thesis, University of Bristol.
Stan Development Team (2023).
Stan Reference Manual version 2.31.
https://mc-stan.org/docs/reference-manual/.
See Also
brms::brm()
brms::brmsformula()
brms::prior()
Examples
# Examples below fits SITAR model to the 'berkeley_exdata' which is a subset
# of the Berkley height data. The same subset of the Berkley height data
# has been used as an example data in the vignette for the 'sitar' package.
#
# The Berkley height data comprise of repeated growth measurements made on
# 66 boys and 70 girls (birth to 21 years).
#
# The subset of the Berkley height data analysed here include growth
# measurements for 70 girls (8 to 18 years).
#
# See 'sitar' package documentation for details on Berkley height data
# (help file ?sitar::berkeley ). The details on subset data for 70 girls is
# provided in the vignette('Fitting_models_with_SITAR', package = 'sitar').
# Fit frequentist SITAR model with df = 5 by using the sitar package
# Get 'berkeley_exdata' data that has been already saved
berkeley_exdata <- getNsObject(berkeley_exdata)
model_ml <- sitar::sitar(x = age, y = height, id = id,
df = 5,
data = berkeley_exdata,
xoffset = 'mean',
fixed = 'a+b+c',
random = 'a+b+c',
a.formula = ~1,
b.formula = ~1,
c.formula = ~1
)
# 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').
# The model is fit using 2 chain (2000 iterations per) with thin set as 4 to
# save time and memory.
# Check and confirm whether model fit object 'berkeley_exfit' exists
# berkeley_exfit <- bsitar:::berkeley_exfit
berkeley_exfit <- getNsObject(berkeley_exfit)
print(berkeley_exfit)
if(exists('berkeley_exfit')) {
model <- berkeley_exfit
} else {
# Fit model with default priors
# See documentation for prior on each parameter
model <- bsitar(x = age, y = height, id = id,
df = 3,
data = berkeley_exdata,
xoffset = 'mean',
fixed = 'a+b+c',
random = 'a+b+c',
a_formula = ~1,
b_formula = ~1,
c_formula = ~1,
threads = brms::threading(NULL),
chains = 2, cores = 2, iter = 6000, thin = 15)
# Note that we can test for the sensitivity to the priors by re fitting the
# above model with flat (i.e., uniform) priors on the regression coefficients
# for parameters a, b and c.
model <- bsitar(x = age, y = height, id = id,
df = 3,
data = berkeley_exdata,
xoffset = 'mean',
fixed = 'a+b+c',
random = 'a+b+c',
a_formula = ~1,
b_formula = ~1,
c_formula = ~1,
a_prior_beta = flat,
b_prior_beta = flat,
c_prior_beta = flat,
threads = brms::threading(NULL),
chains = 2, cores = 2, iter = 6000, thin = 15)
}
# Generate model summary
summary(model)
# Compare model summary with the maximum likelihood SITAR model
print(model_ml)
# Check model fit via posterior predictive checks. The plot_ppc is a based
# on the pp_check function from the brms package.
plot_ppc(model, ndraws = 100)
# Plot distance and velocity curves using plot_conditional_effects() function.
# This function works exactly same as as conditional_effects() from the brms
# package with the exception that plot_conditional_effects allows for
# plotting velocity curve also.
# Distance
plot_conditional_effects(model, deriv = 0)
# Velocity
plot_conditional_effects(model, deriv = 1)
# Plot distance and velocity curve along with the parameter estimates using
# the plot_curves() function. This function works exactly the same way as
# plot.sitar from the sitar package
plot_curves(model, apv = TRUE)
# Compare plot with the maximum likelihood SITAR model
plot(model_ml)