| model | An object of class bgmfit. | 
| resp | A character string (default NULL) to specify response
variable when processing posterior draws for theunivariate_byandmultivariatemodels. Seebsitar()for details onunivariate_byandmultivariatemodels | 
| ndraws | A positive integer indicating the number of posterior draws to
be used in estimation. If NULL(default), all draws are used. | 
| draw_ids | An integer indicating the specific posterior draw(s)
to be used in estimation (default NULL). | 
| newdata | An optional data frame to be used in estimation. If
NULL(default), thenewdatais retrieved from themodel. | 
| datagrid | Generate a grid of user-specified values for use in the
newdataargument in various functions of the marginaleffects
package. This is useful to define where in the predictor space we want to
evaluate the quantities of interest. Seemarginaleffects::datagrid()for
details. The default value for thedatagridisNULLimplying
that no custom grid is constructed. To set a data grid, the argument should
be a data.frame constructed by using themarginaleffects::datagrid()function, or else a named list which are internally used for setting up the
grid. For the user convenience, we also allow setting an empty listdatagrid = list()in which case essential arguments such asmodel,newdataare taken up from the respective arguments
specified elsewhere. Further, the level 1 predictor (such as age) and any
covariate included in the model fit (e.g., gender) are also automatically
inferred from themodelobject. | 
| re_formula | Option to indicate whether or not to include the
individual/group-level effects in the estimation. When NA(default),
the individual-level effects are excluded and therefore population average
growth parameters are computed. WhenNULL, individual-level effects
are included in the computation and hence the growth parameters estimates
returned are individual-specific. In both situations, (i.e,,NAorNULL), continuous and factor covariate(s) are appropriately included
in the estimation. The continuous covariates by default are set to their
means (seenumeric_cov_atfor details) whereas factor covariates are
left unaltered thereby allowing estimation of covariate specific population
average and individual-specific growth parameter. | 
| allow_new_levels | A flag indicating if new levels of group-level
effects are allowed (defaults to FALSE). Only relevant ifnewdatais provided. | 
| sample_new_levels | Indicates how to sample new levels for grouping
factors specified in re_formula. This argument is only relevant ifnewdatais provided andallow_new_levelsis set toTRUE. If"uncertainty"(default), each posterior sample for a
new level is drawn from the posterior draws of a randomly chosen existing
level. Each posterior sample for a new level may be drawn from a different
existing level such that the resulting set of new posterior draws
represents the variation across existing levels. If"gaussian",
sample new levels from the (multivariate) normal distribution implied by the
group-level standard deviations and correlations. This options may be useful
for conducting Bayesian power analysis or predicting new levels in
situations where relatively few levels where observed in the old_data. If"old_levels", directly sample new levels from the existing levels,
where a new level is assigned all of the posterior draws of the same
(randomly chosen) existing level. | 
| parameter | A single character string, or a character vector specifying
the growth parameter(s) to be estimated. Options are 'tgv'(takeoff
growth velocity),'atgv'(age at takeoff growth velocity),'pgv'(peak growth velocity),'apgv'(age at peak growth
velocity),'cgv'(cessation growth velocity), and'acgv'(age
at cessation growth velocity), and'all'. Ifparameter = NULL(default), age at peak growth velocity ('apgv') is estimated where
whenparameter = 'all', all six parameters are estimated. Note that
option'all'can not be used when argumentbyisTRUE. | 
| xrange | An integer to set the predictor range (i.e., age) when
executing the interpolation via ipts. The defaultNULLsets
the individual specific predictor range whereas codexrange = 1sets
identical range for individuals within the same higher grouping variable
(e.g., study). Codexrange  = 2sets the identical range across the
entire sample. Lastly, a paired numeric values can be supplied e.g.,xrange = c(6, 20)to set the range within those values. | 
| acg_velocity | A real number to set the percentage of peak growth growth
velocity as the cessation velocity when estimating the cgvandacgvgrowth parameters. Theacg_velocityshould be greater
than0and less than1. The defaultacg_velocity =
  0.10indicates that a 10 per cent of the peak growth velocity will be used
to get the cessation velocity and the corresponding age at the cessation
velocity. For example if peak growth velocity estimate is10
  mm/year, then cessation growth velocity is1 mm/year. | 
| digits | An integer (default 2) to set the decimal argument for
thebase::round()function. | 
| numeric_cov_at | An optional (named list) argument to specify the value
of continuous covariate(s). The default NULLoption set the
continuous covariate(s) at their mean. Alternatively, a named list can be
supplied to manually set these values. For example,numeric_cov_at =
  list(xx = 2)will set the continuous covariate varibale 'xx' at 2. The
argumentnumeric_cov_atis ignored when no continuous covariate is
included in the model. | 
| aux_variables | An optional argument to specify the variable(s) that can
be passed to the iptsargument (see below). This is useful when
fitting location scale models and measurement error models. An
indication to useaux_variablesis when post processing functions
throw an error such asvariable 'x' not found either 'data' or
 'data2' | 
| levels_id | An optional argument to specify the idsfor
hierarchical model (defaultNULL). It is used only when model is
applied to the data with 3 or more levels of hierarchy. For a two level
model, thelevels_idis automatically inferred from the model fit.
Even for 3 or higher level model, thelevels_idis inferred from the
model fit but under the assumption that hierarchy is specified from lowest
to upper most level i.e,idfollowed bystudywhereidis nested within thestudyNote that it is not guaranteed that thelevels_idis sorted correctly, and therefore it is better to set it
manually when fitting a model with three or more levels of hierarchy. | 
| avg_reffects | An optional argument (default NULL) to calculate
(marginal/average) curves and growth parameters such as APGV and PGV. If
specified, it must be a named list indicating theover(typically
level 1 predictor, such as age),feby(fixed effects, typically a
factor variable), andreby(typicallyNULLindicating that
parameters are integrated over the random effects) such asavg_reffects = list(feby = 'study', reby = NULL, over = 'age'). | 
| idata_method | A character string to indicate the interpolation method.
The number of of interpolation points is set up the iptsargument.
Options available foridata_methodare method 1 (specified as'm1') and method 2 (specified as'm2'). The
method 1 ('m1') is adapted from the the iapvbs package
and is documented here
https://rdrr.io/github/Zhiqiangcao/iapvbs/src/R/exdata.R
whereas method 2 ('m2') is based on the JMbayes
package as documented here
https://github.com/drizopoulos/JMbayes/blob/master/R/dynPred_lme.R.
The'm1'method works by internally constructing the data frame based
on the model configuration whereas the method'm2'uses the exact
data frame used in model fit and can be accessed viafit$data. Ifidata_method = NULL, default, then method'm2'is
automatically set. Note that method'm1'might fail in some cases
when model involves covariates particularly when model is fit asunivariate_by. Therefore, it is advised to switch to method'm2'in case'm1'results in error. | 
| ipts | An integer to set the length of the predictor variable to get a
smooth velocity curve. The NULLwill return original values whereas
an integer such asipts = 10(default) will interpolate the
predictor. It is important to note that these interpolations do not alter
the range of predictor when calculating population average and/or the
individual specific growth curves. | 
| seed | An integer (default 123) that is passed to the estimation
method. | 
| future | A logical (default FALSE) to specify whether or not to
perform parallel computations. If set toTRUE, thefuture.apply::future_sapply()function is used to summarize draws. | 
| future_session | A character string to set the session type when
future = TRUE. The'multisession'(default) options sets the
multisession whereas the'multicore'sets the multicore session.
Note that option'multicore'is not supported on Windows systems.
For more details, seefuture.apply::future_sapply(). | 
| cores | Number of cores to be used when running the parallel
computations (if future = TRUE). On non-Windows systems this
argument can be set globally via the mc.cores option. For the defaultNULLoption, the number of cores are set automatically by calling
thefuture::availableCores(). The number of cores used are the maximum
number of cores avaialble minus one, i.e.,future::availableCores() -
  1. | 
| fullframe | A logical to indicate whether to return fullframeobject in whichnewdatais bind to the summary estimates. Note thatfullframecan not be combined withsummary = FALSE.
Furthermore,fullframecan only be used whenidata_method =
  'm2'. A particular use case is when fittingunivariate_bymodel.
Thefullframeis mainly for internal use only. | 
| average | A logical to indicate whether to internally call the
marginaleffects::predictions()or themarginaleffects::avg_predictions()function. IfFALSE(default),marginaleffects::predictions()is called otherwisemarginaleffects::avg_predictions()whenaverage = TRUE. | 
| plot | A logical to specify whether to plot predictions by calling the
marginaleffects::plot_predictions()function (FALSE) or not
(FALSE). IfFALSE(default), thenmarginaleffects::predictions()ormarginaleffects::avg_predictions()are called to compute predictions (seeaveragefor details) | 
| showlegends | An argument to specify whether to show legends
(TRUE) or not (FALSE). IfNULL(default), thenshowlegendsis internally set toTRUEifre_formula =
  NA, andFALSEifre_formula = NULL. | 
| variables | For estimating growth parameters in the current use case,
the variablesis the level 1 predictor such asage/time. Thevariablesis a named list where value is
set via theespargument (default 1e-6). IfNULL, thevariablesis set internally by retrieving the relevant information
from themodel. Otherwise, user can define it as follows:variables = list('x' = 1e-6)where'x'is the level 1
predictor. Note thatvariables = list('age' = 1e-6)is the default
behavior for the marginaleffects because velocity is typically
calculated by differentiating the distance curve viadydxapproach,
and therefore argumentderivis automatically set as0andderiv_modelasFALSE. If user want to estimate parameters
based on the model based first derivative, then argumentderivmust
be set as1and internally argumentvariablesis defined asvariables = list('age' = 0)i.e, original level 1 predictor
variable,'x'. It is important to consider that if default behavior
is used i.e,deriv = 0andvariables = list('x' = 1e-6), then
user can not pass additional arguments to thevariablesargument. On
the other hand, alternative approach i.e,deriv = 0andvariables = list('x' = 0), additional options can be passed to themarginaleffects::comparisons()andmarginaleffects::avg_comparisons()functions. | 
| condition | Conditional predictions
 
 Character vector (max length 4): Names of the predictors to display.
 Named list (max length 4): List names correspond to predictors. List elements can be:
 
 Numeric vector
 Function which returns a numeric vector or a set of unique categorical values
 Shortcut strings for common reference values: "minmax", "quartile", "threenum"
 1: x-axis. 2: color/shape. 3: facet (wrap if no fourth variable, otherwise cols of grid). 4: facet (rows of grid).
 Numeric variables in positions 2 and 3 are summarized by Tukey's five numbers ?stats::fivenum | 
| deriv | An integer to indicate whether to estimate distance curve or its
derivative (i.e., velocity curve). The deriv = 0(default) is for
the distance curve whereasderiv = 1for the velocity curve. | 
| deriv_model | A logical to specify whether to estimate velocity curve
from the derivative function, or the differentiation of the distance curve.
The argument deriv_modelis set toTRUEfor those functions
which need velocity curve such asgrowthparameters()andplot_curves(), andNULLfor functions which explicitly use
the distance curve (i.e., fitted values) such asloo_validation()andplot_ppc(). | 
| 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 typeisNULL, the
first entry in the error message is used by default. | 
| by | Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:
 
 FALSE: return the original unit-level estimates.
 TRUE: aggregate estimates for each term.
 Character vector of column names in newdataor in the data frame produced by calling the function without thebyargument. Data frame with a bycolumn of group labels, and merging columns shared bynewdataor the data frame produced by calling the same function without thebyargument. See examples below.
 For more complex aggregations, you can use the FUNargument of thehypotheses()function. See that function's documentation and the Hypothesis Test vignettes on themarginaleffectswebsite. | 
| 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" | 
| byfun | A function such as mean()orsum()used to aggregate
estimates within the subgroups defined by thebyargument.NULLuses themean()function. Must accept a numeric vector and return a single numeric
value. This is sometimes used to take the sum or mean of predicted
probabilities across outcome or predictor
levels. See examples section. | 
| wts | string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in avg_*()or with thebyargument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to theweighted.mean()function. 
 string: column name of the weights variable in newdata. When supplying a column name towts, it is recommended to supply the original data (including the weights variable) explicitly tonewdata. numeric: vector of length equal to the number of rows in the original data or in newdata(if supplied). | 
| hypothesis | specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.
 
 Numeric:
 
 Single value: the null hypothesis used in the computation of Z and p (before applying transform). Vector: Weights to compute a linear combination of (custom contrast between) estimates. Length equal to the number of rows generated by the same function call, but without the hypothesisargument. Matrix: Each column is a vector of weights, as describe above, used to compute a distinct linear combination of (contrast between) estimates. The column names of the matrix are used as labels in the output.
 String formula to specify linear or non-linear hypothesis tests. If the termcolumn uniquely identifies rows, terms can be used in the formula. Otherwise, useb1,b2, etc. to identify the position of each parameter. Theb*wildcard can be used to test hypotheses on all estimates. Examples: 
 hp = drat
 hp + drat = 12
 b1 + b2 + b3 = 0
 b* / b1 = 1
 String:
 
 "pairwise": pairwise differences between estimates in each row.
 "reference": differences between the estimates in each row and the estimate in the first row.
 "sequential": difference between an estimate and the estimate in the next row.
 "revpairwise", "revreference", "revsequential": inverse of the corresponding hypotheses, as described above.
 See the Examples section below and the vignette: https://marginaleffects.com/vignettes/hypothesis.html
 | 
| 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. | 
| reformat | A logical (default TRUE) to reformat the  output
returned by themarginaleffectsas a data.frame with column names
re-defined as follows:conf.lowasQ2.5, andconf.highasQ97.5(assuming thatconf_int = 0.95). Also, following
columns are dropped from the data frame:term,contrast,tmp_idx,predicted_lo,predicted_hi,predicted. | 
| estimate_center | A character string (default NULL) to specify
whether to center estimate as'mean'or as'median'. Note
thatestimate_centeris used to set the global options as follows:
  options("marginaleffects_posterior_center" = "mean"), or
 options("marginaleffects_posterior_center" = "median")The pre-specified global options are restored on exit via the
 base::on.exit(). | 
| estimate_interval | A character string (default NULL) to specify
whether to compute credible intervals as equal-tailed intervals,'eti'or highest density intervals,'hdi'. Note thatestimate_intervalis used to set the global options as follows:
  options("marginaleffects_posterior_interval" = "eti"), or
  options("marginaleffects_posterior_interval" = "hdi")The pre-specified global options are restored on exit via the
 base::on.exit(). | 
| dummy_to_factor | A named list (default NULL) that is used to
convert dummy variables into a factor variable. The named elements arefactor.dummy,factor.name, andfactor.level. Thefactor.dummyis a vector of character strings that need to be
converted to a factor variable whereas thefactor.nameis a single
character string that is used to name the newly created factor variable.
Thefactor.levelis used to name the levels of newly created factor.
Whenfactor.nameisNULL, then the factor name is internally
set as'factor.var'. Iffactor.levelisNULL, then
names of factor levels are take from thefactor.dummyi.e., the
factor levels are assigned same name asfactor.dummy. Note that whenfactor.levelis notNULL, its length must be same as the
length of thefactor.dummy. | 
| verbose | An optional argument (logical, default FALSE) to
indicate whether to print information collected during setting up the
object(s). | 
| expose_function | An optional logical argument to indicate whether to
expose Stan functions (default FALSE). Note that if user has already
exposed Stan functions during model fit by settingexpose_function =
  TRUEin thebsitar(), then those exposed functions are saved and can be
used during post processing of the posterior draws and thereforeexpose_functionis by default set asFALSEin all post
processing functions exceptoptimize_model(). Foroptimize_model(), the
default setting isexpose_function = NULL. The reason is that each
optimized model has different Stan function and therefore it need to be re
exposed and saved. Theexpose_function = NULLimplies that the
setting forexpose_functionis taken from the originalmodelfit. Note thatexpose_functionmust be set toTRUEwhen
addingfit criteriaand/orbayes_R2during model
optimization. | 
| usesavedfuns | A logical (default NULL) to indicate whether to
use the already exposed and savedStanfunctions. Depending on
whether the user have exposed Stan functions within thebsitar()call viaexpose_functionsargument in thebsitar(), theusesavedfunsis automatically set toTRUE(ifexpose_functions = TRUE) orFALSE(ifexpose_functions = FALSE). Therefore, manual
setting ofusesavedfunsasTRUE/FALSEis rarely
needed. This is for internal purposes only and mainly used during the
testing of the functions and therefore should not be used by users as it
might lead to unreliable estimates. | 
| clearenvfuns | A logical to indicate whether to clear the exposed
function from the environment (TRUE) or not (FALSE). IfNULL(default), thenclearenvfunsis set asTRUEwhenusesavedfunsisTRUE, andFALSEifusesavedfunsisFALSE. | 
| envir | Environment used for function evaluation. The default is
NULLwhich will setparent.frame()as default environment.
Note that since most of post processing functions are based on brms,
the functions needed for evaluation should be in the.GlobalEnv.
Therefore, it is strongly recommended to set envir = globalenv()(orenvir = .GlobalEnv). This is particularly true for the
derivatives such as velocity curve. | 
| ... | Additional arguments passed to the brms::fitted.brmsfit()function. Please seebrms::fitted.brmsfit()for details on
various options available. |