jags_analysis: Perform a JAGS analysis

Description Usage Arguments Details Value References See Also Examples

Description

Performs a JAGS analysis by fitting a jags_model or list of jags_models to a data frame using JAGS (Plummer 2012). The resultant jags_analysis object can then be passed to other functions to to get the convergence of particular parameters, parameter coefficients with credible intervals and predict derived parameter estimates.

Usage

1
2
jags_analysis(model, data, niters = 10^3, default_model_id = model_id(model,
  reference = TRUE)[1], mode = "current")

Arguments

model

a jags_model specifying the JAGS model(s).

data

the data.frame or list of data to analyse.

niters

an integer element of the number of iterations to run per MCMC chain.

default_model_id

a string or number defining the default model id to use in predictions etc

mode

a character element indicating the mode for the analysis.

Details

The jags_analysis function performs a Bayesian analysis of a data frame for a jags_model or list of jags_models.

If mode = "current" (the default) then the analysis options are as currently globally defined by opts_jagr() otherwise the mode argument specifies the analysis mode for that particular analysis.

The niters argument specifies the total number of iterations including adaptive and burn in periods for each chain. The only exceptions are when the analysis is in debug mode in which case niters is set to be 100 or if niters is less than nsamples * 2 / nchain (where nsamples is set by the mode) in which case niters is set to be nsamples * 2 / nchain so that nsamples can be drawn from the second halves of the chains.

Value

a jags_analysis object

References

Plummer M (2012) JAGS Version 3.3.0 User Manual http://sourceforge.net/projects/mcmc-jags/files/Manuals/

See Also

jags_model and jaggernaut

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
model <- jags_model("
model { 
 bLambda ~ dlnorm(0,10^-2) # $\\bLambda$
 for (i in 1:length(x)) { 
   x[i]~dpois(bLambda) 
 } 
}")

data <- data.frame(x = rpois(100,1))

analysis <- jags_analysis (model, data, mode = "demo")
print(analysis)

analysis <- update(analysis, mode = "demo")

auto_corr(analysis)
cross_corr(analysis)
nchains(analysis)
nsamples(analysis)
convergence(analysis)

poissonconsulting/jaggernaut documentation built on Feb. 18, 2021, 11:10 p.m.