jags.model {rjags} | 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=sys.frame(sys.parent()), inits, nchain = 1, n.adapt=1000)
file |
a file containing a description of the model in the JAGS dialect of the BUGS language |
data |
a list or environment containing the data. Any numeric
objects in data corresponding to node arrays used in
file are taken to represent the values of observed nodes
in the model |
inits |
optional specification of initial values in the form of a
list or a function (see Initialization below). If omitted,
initial values will be generated automatically. It is an error to
supply an initial value for an observed node. |
nchain |
the number of parallel chains for the model |
n.adapt |
the number of iterations for adaptation. When a model
is first created, some of the samplers may have an adaptive mode. In
this case, the samplers are run for n.adapt iterations and then
the adaptive mode is switched off |
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 function 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 defines 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 internal=TRUE then the returned lists also include the RNG
names (.RNG.name ) and states (.RNG.state ). This is
not the user-level interface: use the coef.jags method
instead. |
update(niter, by = niter/50, adapt=FALSE) |
Updates the model by
niter iterations. By default a progress bar is printed to the
screen, with an update every by iterations. To suppress the
update bar, use by=0 . The adapt argument is used for
adaptive mode. This is not the user-level interface: use the
update.jags method instead. |
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:
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 seeds are calculated from the current time, so
that two models created by identical calls to jags.model
will
not, by default, produce the same output.
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
.
Further RNGs may be available if other JAGS modules are loaded.
Martyn Plummer