jags.samples: Generate posterior samples

View source: R/jags.R

jags.samplesR Documentation

Generate posterior samples

Description

Function to extract random samples from the posterior distribution of the parameters of a jags model.

Usage

jags.samples(model, variable.names, n.iter, thin = 1,
             type="trace", force.list=FALSE, ...)

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

type

type of monitor (can be vectorised)

force.list

option to consistently return a named list of monitor types even if a single monitor type is requested

...

optional arguments passed to the update method for jags model objects

Details

The jags.samples function creates monitors for the given variables, runs the model for n.iter iterations and returns the monitored samples.

Value

A list of mcarray objects, with one element for each element of the variable.names argument. If more than one type of monitor is requested (or if force.list is TRUE) then the return value will be a (named) list of lists of mcarray objects, with one element for each monitor type.

Author(s)

Martyn Plummer

See Also

jags.model, coda.samples

Examples

  data(LINE)
  LINE$recompile()
  LINE.samples <- jags.samples(LINE, c("alpha","beta","sigma"),
  n.iter=1000)
  LINE.samples
  LINE.samples <- jags.samples(LINE, c("alpha","beta","sigma"),
  force.list=TRUE, n.iter=1000)
  LINE.samples
  LINE.samples <- jags.samples(LINE, c("alpha","alpha"),
  n.iter=1000, type=c("trace","mean"))
  LINE.samples$trace
  LINE.samples$mean

rjags documentation built on April 24, 2023, 1:09 a.m.