lme_imp_adaptive: Run a joint model with adaptively increasing the number of...

View source: R/lme_imp_adaptive.R

lme_imp_adaptiveR Documentation

Run a joint model with adaptively increasing the number of iterations

Description

Run a joint model with adaptively increasing the number of iterations

Usage

lme_imp_adaptive(
  fixed,
  data,
  random,
  n.chains = 3,
  n.adapt = 100,
  n.iter = 0,
  thin = 1,
  monitor_params = c(analysis_main = TRUE),
  auxvars = NULL,
  refcats = NULL,
  models = NULL,
  no_model = NULL,
  trunc = NULL,
  shrinkage = FALSE,
  ppc = TRUE,
  seed = NULL,
  inits = NULL,
  scale_vars = NULL,
  hyperpars = NULL,
  modelname = NULL,
  modeldir = NULL,
  keep_model = FALSE,
  overwrite = NULL,
  quiet = TRUE,
  progress.bar = "text",
  warn = TRUE,
  mess = TRUE,
  keep_scaled_mcmc = FALSE,
  extra_iter = NULL,
  minsize = 500L,
  step = 200L,
  subset = NULL,
  cutoff = 1.2,
  prop = 0.8,
  gr_max = 1.5,
  max_try = 5L,
  ...
)

Arguments

fixed

a two sided formula describing the fixed-effects part of the model (see formula)

data

a data.frame containing the original data (more details below)

random

only for multi-level models: a one-sided formula of the form ~x1 + ... + xn | g, where x1 + ... + xn specifies the model for the random effects and g the grouping variable

n.chains

number of MCMC chains

n.adapt

number of iterations for adaptation of the MCMC samplers (see adapt)

n.iter

number of iterations of the MCMC chain (after adaptation; see coda.samples)

thin

thinning interval (integer; see window.mcmc). For example, thin = 1 (default) will keep the MCMC samples from all iterations; thin = 5 would only keep every 5th iteration.

monitor_params

named list or vector specifying which parameters should be monitored (more details below)

auxvars

optional; one-sided formula of variables that should be used as predictors in the imputation procedure (and will be imputed if necessary) but are not part of the analysis model(s). For more details with regards to the behaviour with non-linear effects see the vignette on Model Specification

refcats

optional; either one of "first", "last", "largest" (which sets the category for all categorical variables) or a named list specifying which category should be used as reference category per categorical variable. Options are the category label, the category number, or one of "first" (the first category), "last" (the last category) or "largest" (chooses the category with the most observations). Default is "first". If reference categories are specified for a subset of the categorical variables the default will be used for the remaining variables. (See also set_refcat)

models

optional; named vector specifying the types of models for (incomplete) covariates. This arguments replaces the argument meth used in earlier versions. If NULL (default) models will be determined automatically based on the class of the respective columns of data.

no_model

optional; vector of names of variables for which no model should be specified. Note that this is only possible for completely observed variables and implies the assumptions of independence between the excluded variable and the incomplete variables.

shrinkage

optional; either a character string naming the shrinkage method to be used for regression coefficients in all models or a named vector specifying the type of shrinkage to be used in the models given as names.

ppc

logical: should monitors for posterior predictive checks be set? (not yet used)

seed

optional; seed value (for reproducibility)

inits

optional; specification of initial values in the form of a list or a function (see jags.model). If omitted, starting values for the random number generator are created by JointAI, initial values are then generated by JAGS. It is an error to supply an initial value for an observed node.

warn

logical; should warnings be given? Default is TRUE.

mess

logical; should messages be given? Default is TRUE.

extra_iter

number of iterations that should be added to the model if the Gelman-Rubin criterion is too large

minsize

the minimum number of iterations to be considered

step

the step size in which iterations are omitted as burn-in

subset

subset of parameters on which the Gelman-Rubin criterion should be evaluated. Follows the logic used in JointAI

cutoff

the cut-off used for the Gelman Rubin criterion

prop

proportion of parameters that need to be below the cutoff

gr_max

maximum allowed value for the Gelman-Rubin criterion

max_try

maximum number of runs of JointAI::add_samples()

...

additional, optional arguments

trunc

named list specifying limits of truncation for the distribution of the named incomplete variables (see the vignette ModelSpecification)

hyperpars

list of hyper-parameters, as obtained by default_hyperpars()

scale_vars

named vector of (continuous) variables that will be centred and scaled (such that mean = 0 and sd = 1) when they enter a linear predictor to improve convergence of the MCMC sampling. Default is that all numeric variables and integer variables with >20 different values will be scaled. If set to FALSE no scaling will be done.

custom

named list of JAGS model chunks (character strings) that replace the model for the given variable.

append_data_list

list that will be appended to the list containing the data that is passed to rjags (data_list). This may be necessary if additional data / variables are needed for custom (covariate) models.

progress.bar

character string specifying the type of progress bar. Possible values are "text" (default), "gui", and "none" (see update). Note: when sampling is performed in parallel it is not possible to display a progress bar.

quiet

logical; if TRUE then messages generated by rjags during compilation as well as the progress bar for the adaptive phase will be suppressed, (see jags.model)

keep_scaled_mcmc

should the "original" MCMC sample (i.e., the scaled version returned by coda.samples()) be kept? (The MCMC sample that is re-scaled to the scale of the data is always kept.)

modelname

character string specifying the name of the model file (including the ending, either .R or .txt). If unspecified a random name will be generated.

modeldir

directory containing the model file or directory in which the model file should be written. If unspecified a temporary directory will be created.

overwrite

logical; whether an existing model file with the specified <modeldir>/<modelname> should be overwritten. If set to FALSE and a model already exists, that model will be used. If unspecified (NULL) and a file exists, the user is asked for input on how to proceed.

keep_model

logical; whether the created JAGS model file should be saved or removed from (FALSE; default) when the sampling has finished.


NErler/simvalidator documentation built on May 17, 2022, 7:54 a.m.