The jags function takes data and starting values as input. It automatically writes a jags script, calls the model, and saves the simulations for easy access in R. Check the R2jags::jags2 for details about the argument.
Arguments
- data
(1) a vector or list of the names of the data objects used by the model, (2) a (named) list of the data objects themselves, or (3) the name of a "dump" format file containing the data objects, which must end in ".txt", see example below for details.
- inits
a list with
n.chainselements; each element of the list is itself a list of starting values for theBUGSmodel, or a function creating (possibly random) initial values. If inits isNULL,JAGSwill generate initial values for parameters.- parameters.to.save
character vector of the names of the parameters to save which should be monitored.
- model.file
file containing the model written in
BUGScode. Alternatively, as in R2WinBUGS,model.filecan be an R function that contains aBUGSmodel that is written to a temporary model file (seetempfile) usingwrite.model- n.chains
number of Markov chains (default: 3)
- n.iter
number of total iterations per chain (including burn in; default: 2000)
- n.burnin
length of burn in, i.e. number of iterations to discard at the beginning. Default is
n.iter/2, that is, discarding the first half of the simulations. If n.burnin is 0,jags()will run 100 iterations for adaption.- n.thin
thinning rate. Must be a positive integer. Set
n.thin> 1 to save memory and computation time ifn.iteris large. Default ismax(1, floor(n.chains * (n.iter-n.burnin) / 1000))which will only thin if there are at least 2000 simulations.- DIC
logical; if
TRUE(default), compute deviance, pD, and DIC. The rulepD=var(deviance) / 2is used.- jags.path
directory that contains the
JAGSexecutable. The default is “”.- working.directory
sets working directory during execution of this function; This should be the directory where model file is.
- clearWD
indicating whether the files
data.txt,inits[1:n.chains].txt,codaIndex.txt,jagsscript.txt, andCODAchain[1:nchains].txtshould be removed afterjagshas finished, default=TRUE.- refresh
refresh frequency for progress bar, default is
n.iter/50
Value
Same as R2jags::jags()