Usage
autorun.jags(model=stop("No model supplied"),
monitor = stop("No monitored variables supplied"),
data=NA, n.chains=2, inits = replicate(n.chains, NA),
startburnin = 5000, startsample = 10000,
psrf.target = 1.05, normalise.mcmc = TRUE,
check.stochastic = TRUE, raftery.options = list(),
crash.retry = 1, plots = TRUE, thin.sample = TRUE,
jags = findjags(), silent.jags = FALSE,
interactive=TRUE, max.time=Inf,
adaptive=list(type="burnin", length=200), modules=c(""),
factories=c(""), thin = 1, monitor.deviance = FALSE,
monitor.pd = FALSE, monitor.pd.i = FALSE,
monitor.popt = FALSE, keep.jags.files = FALSE, tempdir=TRUE,
method=if(.Platform$OS.type=='unix' & .Platform$GUI!="AQUA" &
Sys.info()['user']!='nobody') 'interruptible' else 'simple',
batch.jags=silent.jags)Arguments
model
a character string of the model in the JAGS language. No
default.
monitor
a character vector of the names of variables to monitor.
For all models, specifying 'deviance' as a monitored variable will
calculate the model deviance, and 'dic' will calculate the Deviance
Information Criterion (implies monitor.deviance etc, and requi
data
either a named list or a character string in the R dump
format containing the data. If left as NA, the model will be run
without external data.
n.chains
the number of chains to use with the simulation. More
chains will improve the sensitivity of the convergence diagnostic, but
will cause the simulation to run more slowly. The minimum (and default)
number of chains is 2.
inits
either a character vector with length equal to the number
of chains the model will be run using, or a list of named lists
representing names and corresponding values of inits for each chain. If
a vector, each element of the vector must be a character str
startburnin
the number of initial updates to discard before
sampling. Only used on the initial run before checking convergence.
Default 5000 iterations.
startsample
the number of samples on which to assess convergence.
More samples will give a better chance of allowing the chain to
converge, but will take longer to achieve. Also controls the length of
the pilot chain used to assess the required sampling length. Th
psrf.target
the value of the point estimate for the potential
scale reduction factor of the Gelman Rubin statistic below which the
chains are deemed to have converged (must be greater than 1). Default
1.05.
normalise.mcmc
the Gelman Rubin statistic is based on the
assumption that the posterior distribution of monitored variables is
roughly normal. For very skewed posterior distributions, it may help to
log/logit transform the posterior before calculating the Gelman Rubin
check.stochastic
non-stochastic monitored variables will cause
errors when calculating the Gelman-Rubin statistic, if
check.stochastic==TRUE then all monitored variables will be checked to
ensure they are stochastic beforehand. This has a computational cost,
and can be b
raftery.options
a named list which is passed as additional
arguments to raftery.diag. Default none (default
arguments to raftery.diag are used). crash.retry
the number of times to re-attempt a simulation if the
model returns an error. Default 1 retry (simulation will be aborted
after the second crash).
plots
should traceplots and density plots be produced for each
monitored variable? If TRUE, the returned list will include elements
'trace' and 'density' which consist of a list of lattice objects. The
alternative is to use plot(results$mcmc) to look at the d
thin.sample
option to thin the final MCMC chain(s) before
calculating summary statistics and returning the chains. Thinning very
long chains allows summary statistics to be calculated more quickly. If
TRUE, the chain is thinned to as close to a minimum of startsamp
jags
the system call or path for activating JAGS. Default calls
findjags() to attempt to locate JAGS on your system.
silent.jags
should the JAGS output be suppressed? (logical) If
TRUE, no indication of the progress of individual models is supplied.
Default FALSE.
interactive
option to allow the simulation to be interactive, in
which case the user is asked if the simulation should be extended when
run length and convergence calculations are performed and the extended
simulation will take more than 1 minute. The function will
max.time
the maximum time for which the function is allowed to
extend the chains to improve convergence, as a character string
including units or as an integer in which case units are taken as
seconds. Ignored if interactive==TRUE. If the function thinks that th
adaptive
a list of advanced options controlling the length of the
adaptive mode of each simulation. Extended simulations do not require
an adaptive phase, but JAGS prints a warning if one is not performed.
Reduce the length of the adpative phase for very time co
modules
external modules to be loaded into JAGS. More than 1
module can be used. Default none.
factories
factory modules to be loaded into JAGS. More than 1
factory can be used. Entried should be in the format '""
, type()', for example: factories='"mix::TemperedMix"
off, type(sampler)'. Default none.
thin
the thinning interval to be used in JAGS. Increasing the
thinning interval may reduce autocorrelation, and therefore reduce the
number of samples required, but will increase the time required to run
the simulation. Using this option thinning is performe
monitor.deviance
option to monitor the total deviance of the
model using the DIC module in JAGS. If TRUE, an additional monitor
called 'deviance' is added to the MCMC objects returned, representing
the deviance of the model for each iteration and each chain. This
option
monitor.pd
option to monitor the total effective number of
parameters in the model using the DIC module for JAGS. If TRUE, a 'pd'
element is returned representing the total effective number of
parameters at each iteration. This option requires JAGS version 2 or
gr
monitor.pd.i
option to monitor the contribution of each parameter
towards the total effective number of parameters using the DIC module
for JAGS. If TRUE, a 'pd.i' element is returned representing the mean
value for each parameter. This option requires JAGS version
monitor.popt
option to monitor the optimism of the expected
deviance using the DIC module for JAGS. If TRUE, a 'popt' element is
returned representing the mean value for each parameter. This option
requires JAGS version 2 or greater and at least 2 chains. For more
keep.jags.files
option to keep the folder with files needed to
call JAGS, rather than deleting it. May be useful for attempting to bug
fix models. Since autorun.jags typically makes several calls to JAGS,
all folders are kept - the order in which the folders were used
tempdir
option to use the temporary directory as specified by the
system rather than creating files in the working directory. If
keep.jags.files==TRUE then the folder is copied to the working directory
after the job has finished (with a unique folder name based
method
the method with which to call JAGS; one of 'simple',
'interruptible' or 'parallel'. The former runs JAGS as a foreground
process (the default behaviour for runjags < 0.9.6), 'interruptible'
allows the JAGS process to be terminated immediately using the i
batch.jags
option to call JAGS in batch mode, rather than using
input redirection. On JAGS >= 3.0.0, this suppresses output of the status
which may be useful in some situations. Default TRUE if silent.jags is
TRUE, or FALSE otherwise.