Learn R Programming

rjags (version 4-16)

coda.samples: Generate posterior samples in mcmc.list format

Description

This is a wrapper function for jags.samples which sets a trace monitor for all requested nodes, updates the model, and coerces the output to a single mcmc.list object.

Usage

coda.samples(model, variable.names, n.iter, thin = 1, na.rm=TRUE, ...)

Value

An mcmc.list object.

Arguments

model

a jags model object

variable.names

a character vector giving the names of variables to be monitored

n.iter

number of iterations to monitor

thin

thinning interval for monitors

na.rm

logical flag that indicates whether variables containing missing values should be omitted. See details.

...

optional arguments that are passed to the update method for jags model objects

Author

Martyn Plummer

Details

If na.rm=TRUE (the default) then elements of a variable that are missing (NA) for any iteration in at least one chain will be dropped.

This argument was added to handle incompletely defined variables. From JAGS version 4.0.0, users may monitor variables that are not completely defined in the BUGS language description of the model, e.g. if y[i] is defined in a for loop starting from i=3 then y[1], y[2] are not defined. The user may still monitor variable y and the monitored values corresponding to y[1], y[2] will have value NA for all iterations in all chains. Most of the functions in the coda package cannot handle missing values so these variables are dropped by default.

See Also

jags.samples

Examples

Run this code
data(LINE)
LINE$recompile()
LINE.out <- coda.samples(LINE, c("alpha","beta","sigma"), n.iter=1000)
summary(LINE.out)

Run the code above in your browser using DataLab