View the code
library(rjags)
jags_data <- list(
NS = 4,
NT = 3,
r = matrix(c(25, 50, 30, 45, 20, 60, 40, 55), nrow = 4, byrow = TRUE),
n = matrix(c(100, 100, 100, 100, 100, 100, 100, 100), nrow = 4, byrow = TRUE),
t = matrix(c(1, 2, 1, 2, 1, 3, 2, 3), nrow = 4, byrow = TRUE),
na = rep(2, 4),
cov1 = c(22, 18, 24, 20),
cov2 = c(0.20, 0.10, 0.40, 0.25),
mean_cov1 = 21,
mean_cov2 = 0.2375
)
jags_model <- jags.model(
file = "RE_NMR_model.txt",
data = jags_data,
n.chains = 3,
quiet = TRUE
)
samples <- coda.samples(
jags_model,
variable.names = c("d", "beta1", "beta2", "tau"),
n.iter = 10000,
progress.bar = "none"
)
summary(samples)
Iterations = 1001:11000
Thinning interval = 1
Number of chains = 3
Sample size per chain = 10000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
beta1 0.2617 1.419 0.008195 0.38283
beta2 -9.1127 45.495 0.262664 17.89867
d[1] 0.0000 0.000 0.000000 0.00000
d[2] 0.6012 2.480 0.014319 0.33051
d[3] 2.0360 2.717 0.015685 0.24324
tau 2.1816 1.444 0.008339 0.09669
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
beta1 -2.0077 -0.6683 0.068121 0.920 3.703
beta2 -126.9550 -21.4861 0.009174 20.404 54.639
d[1] 0.0000 0.0000 0.000000 0.000 0.000
d[2] -5.7075 -0.3014 0.919227 1.888 5.044
d[3] -2.8987 0.6857 1.715151 2.972 8.994
tau 0.0614 0.9397 1.990541 3.381 4.843