jags.model | R Documentation |
jags.model
is used to create an object representing a
Bayesian graphical model, specified with a BUGS-language description
of the prior distribution, and a set of data.
jags.model(file, data, inits,
n.chains = 1, n.adapt=1000, quiet=FALSE)
file |
the name of the file containing a description of the model in the JAGS dialect of the BUGS language. Alternatively, |
data |
a list or environment containing the data. Any numeric
objects in |
inits |
optional specification of initial values in the form of a
list or a function (see |
n.chains |
the number of parallel chains for the model |
n.adapt |
the number of iterations for adaptation. See
|
quiet |
if |
jags.model
returns an object inheriting from class jags
which can be used to generate dependent samples from the posterior
distribution of the parameters
An object of class jags
is a list of functions that share a
common environment. This environment encapsulates the state of the
model, and the functions can be used to query or modify the model
state.
ptr() |
Returns an external pointer to an object created by the JAGS library |
data() |
Returns a list containing the data that define the observed nodes in the model |
model() |
Returns a character vector containing the BUGS-language representation of the model |
state(internal=FALSE) |
Returns a list of length equal to the
number of parallel chains in the model. Each element of the list is
itself a list containing the current parameter values in that chain.
if |
update(n.iter) |
Updates the model by |
There are various ways to specify initial values for a JAGS model. If no initial values are supplied, then they will be generated automatically by JAGS. See the JAGS User Manual for details. Otherwise, the options are as follows:
A list of numeric values. Initial values for a single chain may supplied as a named list of numeric values. If there are multiple parallel chains then the same list is re-used for each chain.
A list of lists. Distinct initial values for each chain may be given as a list of lists. In this case, the list should have the same length as the number of chains in the model.
A function. A function may be supplied that returns a list of
initial values. The function is called repeatedly to generate initial
values for each chain. Normally this function should call some random
number generating functions so that it returns different values every
time it is called. The function should either have no arguments, or
have a single argument named chain
. In the latter case, the
supplied function is called with the chain number as argument. In this
way, initial values may be generated that depend systematically on
the chain number.
Each chain in a model has its own random number generator (RNG). RNGs and their initial seed values are assigned automatically when the model is created. The automatic seeds are calculated from the current time.
If you wish to make the output from the model reproducible, you may
specify the RNGs to be used for each chain, and their starting seeds
as part of the inits
argument (see Initialization
above). This is done by supplementing the list of initial parameter
values for a given chain with two additional elements named
“.RNG.name”, and “.RNG.seed”:
.RNG.name
a character vector of length 1. The names of the RNGs supplied in the base module are:
“base::Wichmann-Hill”
“base::Marsaglia-Multicarry”
“base::Super-Duper”
“base::Mersenne-Twister”
If the lecuyer module is loaded, it provides “lecuyer::RngStream”
.RNG.seed
a numeric vector of length 1 containing an integer value.
Note that it is also possible to specify “.RNG.state” rather than
“.RNG.seed” - see for example the output of parallel.seeds
Martyn Plummer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.