View source: R/optimize_model.R
optimize_model.bgmfit | R Documentation |
Select the best fitting SITAR model that involves choosing the
optimum degrees of freedom (df
) for the natural cubic-spline curve
and the appropriate transformations of the predictor x
and response
y
variables.
## S3 method for class 'bgmfit'
optimize_model(
model,
newdata = NULL,
optimize_df = NULL,
optimize_x = list(NULL, log, sqrt),
optimize_y = list(NULL, log, sqrt),
transform_prior_class = c("beta", "sd", "rsd", "sigma", "dpar"),
transform_beta_coef = c("b", "c", "d"),
transform_sd_coef = c("b", "c", "d"),
exclude_default_funs = TRUE,
add_fit_criteria = NULL,
add_bayes_R = NULL,
byresp = FALSE,
digits = 2,
cores = 1,
verbose = FALSE,
expose_function = NULL,
usesavedfuns = FALSE,
clearenvfuns = NULL,
envir = NULL,
...
)
optimize_model(model, ...)
model |
An object of class |
newdata |
An optional data frame to be used in estimation. If
|
optimize_df |
A list of integers specifying the degree of freedom
( |
optimize_x |
A vector specifying the transformations for the predictor
variable (i.e., |
optimize_y |
A vector specifying the transformations of the the response
variable (i.e., |
transform_prior_class |
A character vector (default |
transform_beta_coef |
A character vector (default |
transform_sd_coef |
A character vector (default |
exclude_default_funs |
A logical to indicate whether transformations for
( |
add_fit_criteria |
An optional argument (default |
add_bayes_R |
An optional argument (default |
byresp |
A logical (default |
digits |
An integer (default |
cores |
The number of cores to used in parallel processing (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
|
... |
Other arguments passed to |
A list containing the optimized models of class bgmfit
, and
the the summary statistics if add_fit_criteria
and/or
add_bayes_R
are specified.
Satpal Sandhu satpal.sandhu@bristol.ac.uk
brms::add_criterion()
# 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
# Below example shows dummy call to optimization to save time.
# Note that in case degree of freedom and both optimize_x and optimize_y are
# NULL (i.e., nothing to optimize), the original model object is returned.
# To explicitly get this information whether model is being optimized or not,
# user can set verbose = TRUE. The verbose = TRUE also useful in getting the
# information regarding what all arguments have been changed as compared to
# the original model.
model2 <- optimize_model(model,
optimize_df = NULL,
optimize_x = NULL,
optimize_y = NULL,
verbose = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.