jagsRun: Run JAGS

Description Usage Arguments Notes

Description

Run JAGS in parallel and output output of interest. Number of cores used equals number of chains specified. Be sure that your machine has an adequate number of (virtual) cores available to run the model. Function creates a directory with jagsID name, saves .rds file with model output, and produces output summary in text file format.

Usage

1
2
3
4
5
6
jagsRun(jagsData, jagsModel, jagsInits, params, jagsID, jagsDsc, db_hash,
  n_chain = 3, n_adapt = 5000, n_burn, n_draw, n_thin = 1,
  DEBUG = FALSE, EXTRA = FALSE, RANDOM = FALSE, Rhat_max = 1.05,
  n_rburn = 0, n_max = NULL, params_extra = params,
  params_report = params, ppc = NULL, obj_out = FALSE,
  save_data = FALSE, report = TRUE)

Arguments

jagsData

List containing data to feed to JAGS

jagsModel

JAGS model file

jagsInits

Initial values for JAGS model. Should be a list of lists (number of embedded lists should equal the number of chains being run in the model). NOTE: each chain should specify a different starting value for a particular parameter and/or use a different seed/RNG to avoid identical chains.

params

Character string or vector of character strings specifying which parameters to track

jagsID

OPTIONAL. Character string with name of jags run (e.g., 'Run_1')

jagsDsc

OPTIONAL. Character string with description of the jags run (e.g., 'First model run')

db_hash

OPTIONAL. Character string with description of data version which will be printed in the output file. Could be latest git commit hash.

n_chain

Numeric specifying number of chains to be run

n_adapt

Numeric specifying how many iterations to use for adaptation

n_burn

Numeric specifying how any iterations to use for burn-in

n_draw

Numeric specifying how many iterations to use for draw (iterations to be kept beyond adaptation and burn-in)

n_thin

Numeric specifying thinning rate

DEBUG

Logical used to specify whether DEBUG mode should be used. If TRUE, jags.model is called which begins adaptation with adapt = 2. This ensures that the likelihood can be calclated and the model run (priors and inits are appropriate).

EXTRA

Logical used to specify whether extra iterations should be run if convergence is not met. If TRUE, another set of iterations (n_draw) is drawn (up to n_max) until convergence is reached (specified by Rhat_max)

RANDOM

Logical specifying whether to use script to generate random inits. If TRUE, jagsInits should be a function that generates random initial values.

Rhat_max

Numeric specifying the maximum Rhat value allowed when EXTRA = TRUE

n_rburn

Numeric specifying how many samples to use for burn in if EXTRA = TRUE and convergence (defined by Rhat_max) has not been reached.

n_max

Numeric specifying the maximum number of samples to be drawn when EXTRA = TRUE. The total number of iterations will not exceed this value (n_burn, n_draw, and n_rburn values are included in this total). If left blank, n_max is set to n_burn + (n_rburn + n_draw)*2.

params_extra

Character string or vector of character strings specifying which parameters to evaluate convergence for when EXTRA = TRUE. Must be a subset of params.

params_report

Character string or vector of character strings specifying which parameters to report. Must be a subset of params.

ppc

Character string or vector of character strings specifying the name of elements used for the posteriod predictive check (PPC). If specified, the summary information for these elements will be output in the report.

obj_out

Logical specifying whether MCMC.list object should be output

save_data

Logical specifying whether input data to function should be saved as a .rds object

report

Logical specifying whether to generate directory with report and .rds object - if FALSE, MCMC.list object is output

Notes

jagsData should be formatted as such: XXXXX. jagsInits should be formatted as such: XXXXX. Jags params should be formatted as such: XXXXX.


caseyyoungflesh/jagsRun documentation built on May 16, 2019, 7:24 a.m.