runjags-class. The model is automatically assessed for convergence and adequate sample size before being returned.autorun.jags(model, monitor = NA, data = NA, n.chains = NA, inits = NA,
startburnin = 4000, startsample = 10000, adapt = 1000, datalist = NA,
initlist = NA, jags = runjags.getOption("jagspath"),
silent.jags = runjags.getOption("silent.jags"),
modules = runjags.getOption("modules"),
factories = runjags.getOption("factories"), summarise = TRUE,
mutate = NA, thin = 1, thin.sample = FALSE, raftery.options = list(),
crash.retry = 1, interactive = FALSE, max.time = Inf,
tempdir = runjags.getOption("tempdir"), jags.refresh = 0.1,
batch.jags = silent.jags, method = runjags.getOption("method"),
method.options = list(), ...)autoextend.jags(runjags.object, add.monitor = character(0),
drop.monitor = character(0), drop.chain = numeric(0),
combine = length(c(add.monitor, drop.monitor, drop.chain)) == 0,
startburnin = 0, startsample = 10000, adapt = 1000, jags = NA,
silent.jags = NA, summarise = TRUE, thin = NA, thin.sample = FALSE,
raftery.options = list(), crash.retry = 1, interactive = FALSE,
max.time = Inf, tempdir = runjags.getOption("tempdir"),
jags.refresh = NA, batch.jags = NA, method = NA, method.options = NA,
...)
dump.format), or a function (with no arguments) returning one of these types. If the model text contains inline #data# runjags.options.runjags.options.raftery.diag, or the logical FALSE to deactivate automatic run length calculation. Default none (default arguments to raftery.diag are used)add.summary, and/or additional options to control some methods including n.sims for parallel methods, cl for rjparallel and snow methods, remote.jags for snow, and by runjags-class for available methods).runjags-class object and extends the simulation as required. Chain convergence over the first run of the simulation is assessed using Gelman and Rubin's convergence diagnostic. If necessary, the simulation is extended to improve chain convergence (up to a user-specified maximum time limit), before the required sample size of the Markov chain is calculated using Raftery and Lewis's diagnostic. The simulation is extended to the required sample size dependant on autocorrelation and the number of chains. Note that automated convergence diagnostics are not perfect, and should not be considered as a replacement for manually assessing convergence and Monte Carlo error using the results returned. For more complex models, the use of run.jags directly with manual assessment of necessary run length may be preferable.For autoextend.jags, any arguments with a default of NA are taken from the runjags object passed to the function.
run.jags for fixed run length models, read.winbugs for details of model specification options, read.jagsfile and summary.runjags for details on available methods for the returned models, and run.jags.study for examples of simulation studies using automated model control provided by autorun.jags# Run a model to calculate the intercept and slope of the expression
# y = m x + c, assuming normal observation errors for y:
# Simulate the data
N <- 100
X <- 1:N
Y <- rnorm(N, 2*X + 10, 1)
# Model in the JAGS format
model <- "model {
for(i in 1 : N){
Y[i] ~ dnorm(true.y[i], precision)
true.y[i] <- m * X[i] + c
}
m ~ dunif(-1000,1000)
c ~ dunif(-1000,1000)
precision ~ dexp(1)
#data# N, X, Y
#inits# m, c, precision
}"
# Initial values to be used:
m <- list(-10, 10)
c <- list(-10, 10)
precision <- list(0.1, 10)
# Run the model using rjags with a 5 minute timeout:
results <- autorun.jags(model=model, max.time="5m",
monitor=c("m", "c", "precision"), n.chains=2,
method="rjags")
# Analyse standard plots of the results to assess convergence:
plot(results)
# Summary of the monitored variables:
results
# For more details about possible methods see:
vignette('userguide', package='runjags')Run the code above in your browser using DataLab