jagsbasic: Simplified function to call JAGS from R

Description Usage Arguments Details Value Author(s)

Description

The jags.basic function is a simplified version of the jags function which returns only the mcmc.list-class output from rjags rather than a more complex summary (it will also optionally return the model, in which case the output object will be class jagsUIbasic). This minimal function may be useful when the input dataset or output parameter set are very large and memory intensive.

Usage

1
2
3
4
jags.basic(data, inits, parameters.to.save, model.file,
  n.chains, n.adapt=NULL, n.iter, n.burnin=0, n.thin=1,
  modules=c('glm'), factories=NULL, parallel=FALSE, n.cores=NULL, DIC=TRUE,
  seed=NULL, save.model=FALSE, verbose=TRUE)

Arguments

data

A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model. Use of a character vector will be deprecated in the next version - switch to using named lists.

inits

A list with n.chains elements; each element of the list is itself a list of starting values for the BUGS model, or a function creating (possibly random) initial values. If inits is NULL, JAGS will generate initial values for parameters.

parameters.to.save

Character vector of the names of the parameters in the model which should be monitored.

model.file

Path to file containing the model written in BUGS code

n.chains

Number of Markov chains to run.

n.adapt

Number of iterations to run in the JAGS adaptive phase. The default is NULL, which will result in the function running groups of 100 adaptation iterations (to a max of 10,000) until JAGS reports adaptation is sufficient. If you set n.adapt manually, 1000 is the recommended minimum value.

n.iter

Total number of iterations per chain (including burn-in).

n.burnin

Number of iterations at the beginning of the chain to discard (i.e., the burn-in). Does not include the adaptive phase iterations.

n.thin

Thinning rate. Must be a positive integer.

modules

List of JAGS modules to load before analysis. By default only module 'glm' is loaded (in addition to 'basemod' and 'bugs'). To force no additional modules to load, set modules=NULL.

factories

Optional character vector of factories to enable or disable, in the format <factory> <type> <setting>. For example, to turn TemperedMix on you would provide 'mix::TemperedMix sampler TRUE' (note spaces between parts). Make sure you have the corresponding modules loaded as well.

parallel

If TRUE, run MCMC chains in parallel on multiple CPU cores

n.cores

If parallel=TRUE, specify the number of CPU cores used. Defaults to total available cores or the number of chains, whichever is smaller.

DIC

Option to report deviance values. Defaults to TRUE.

seed

Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer. This argument will be deprecated in the next version, but you can always set the outside the function yourself.

save.model

Returns the JAGS model as part of the output object to allow updating the model later. If TRUE, the output object will instead be a list of class jagsUIbasic. Default is false.

verbose

If set to FALSE, all text output in the console will be suppressed as the function runs (including most warnings).

Details

See documentation for jags function for analysis details. The update method will only work if save.model=TRUE.

Value

An object of class mcmc.list, if save.model=FALSE; if save.model=TRUE, a 2-element list of class jagsUIbasic containing the mcmc samples and the model.

Author(s)

Ken Kellner contact@kenkellner.com.


kenkellner/jagsUI documentation built on Oct. 10, 2020, 12:20 p.m.