jags.prec: Returns and/or plots relative precision of different...

Description Usage Arguments Author(s) Examples

Description

Returns and/or plots relative precision of different confidence levels from jags output.

Usage

1
2
jags.prec(jags.out, plot = T, conf = c(0.5, 0.9, 0.95), legend = T,
  return.output = F, which.param = NULL)

Arguments

jags.out

A jags output object from R2jags

plot

Whether or not to produce a plot of precision levels. Defaults to TRUE.

conf

A vector of confidence levels to report. Defaults to c(.5,.9,.95)

legend

Whether or not to produce a legend, if plot==T.

return.output

Whether or not to produce an output table. Defaults to FALSE.

which.param

A vector of the parameter indices we're interested in plotting. Calling jags.names() first can help with this.

Author(s)

Matt Tyers

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
# ------------ a sample R2jags model ----------- #

## Not run: 
library(R2jags)
N <- 1000
x <- 1:N
epsilon <- rnorm(N, 0, 1)
y <- 5 + 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.prec() ------------ #
jags.names(test.jags.out)
jags.prec(test.jags.out,plot=T,return.output=T)
jags.prec(test.jags.out,plot=T,return.output=F,conf=c(.5,.9),which.param=c(1:2,4:5))

## End(Not run)

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