Mô hình hóa Bayesian với RJAGS
Alicia Johnson
Associate Professor, Macalester College


Một chuỗi Markov "tốt" trông như thế nào?
Chuỗi Markov xấp xỉ hậu nghiệm chính xác đến đâu?
Nên chạy chuỗi Markov bao nhiêu vòng lặp?


Tốt: ổn định!

Kém: bất ổn
# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 1)

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 2)

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 4)

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 4)

summary(sleep_sim)
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
m 29.10 8.968 0.2836 0.2820
s 40.07 7.887 0.2494 0.4227
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
m 11.42 23.27 28.85 34.76 46.76
s 28.31 34.65 38.93 43.91 57.56
Ước lượng trung bình hậu nghiệm của $m$ = 29.10 ms
Sai số chuẩn (ngây thơ) của ước lượng này = 0.2836 ms
SD / $\sqrt{\text{number of iterations}}$

Trung bình ước lượng = 29.10 ms
Sai số chuẩn (ngây thơ) = 0.2836 ms

Xây dựng, biên dịch, mô phỏng mô hình
Xem các chỉ báo sau:
Hoàn tất mô phỏng
sleep_jags <- jags.model(textConnection(sleep_model),
data = list(Y = sleep_study$diff_3),
inits = list(.RNG.name = "base::Wichmann-Hill",
.RNG.seed = 1989))
Mô hình hóa Bayesian với RJAGS