jagsplot-package: Plots for R2jags output

Description Details Author(s) Examples

Description

Diagnostic and inferential plots for R2jags output. Possibly works with rjags output, but I don't know yet.

Details

Package: jagsplot
Type: Package
Version: 0.1
Date: 2015-06-03
License: GPL-2

Run a JAGS model using jags() in R2jags, and pass in the output. Highlights are jags.trace(), jags.dens(), and jags.hist(). All use the same basic syntax, with argument which.param coming from a run of jags.names().

Author(s)

Matt Tyers

Maintainer: Matt Tyers <matt.tyers@alaska.gov>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# ------------- example model ------------ #
library(R2jags)
N <- 1000
x <- 1:N
epsilon <- rnorm(N, 0, 1)
y <- x + epsilon

cat('model {
  for (i in 1:N){
    y[i] ~ dnorm(y.hat[i], tau)
  	y.hat[i] <- a + b * x[i]
	}
	a ~ dnorm(0, .0001)
	b ~ dnorm(0, .0001)
	tau <- pow(sigma, -2)
	sigma ~ dunif(0, 100)
}', file="test.jags")

test.data <- list(x=x,y=y,N=N)
test.jags.out <- jags(model.file="test.jags", data=test.data, 
      parameters.to.save=c("a","b","tau","sigma"), n.chains=3, n.iter=1000)

# ------------- calling jags.trace() ------------ #
par(mfrow=c(3,2))
jags.trace(test.jags.out)

# say we're only interested in parameters a and b
jags.names(test.jags.out)
par(mfrow=c(2,1))
jags.trace(test.jags.out,which.param=1:2)

# -------- jags.dens() and jags.hist() ----------- #
par(mfrow=c(3,2))
jags.dens(test.jags.out)
jags.hist(test.jags.out)

mbtyers/jagsplot documentation built on May 22, 2019, 12:58 p.m.