rjags coda. , :
library(rjags)
x <- rnorm(100)
model.str <- 'model {for (i in 1:100) {
x[i] ~ dnorm(mu, sd)}
mu ~ dnorm(0, .0001)
sd ~ dgamma(0.1, 0.1)}'
jags <- jags.model(textConnection(model.str), data = list(x = x),n.chains=2)
smpls <- coda.samples(model=jags,n.iter=2,variable.names=c("mu","sd"))
smpls
( )
do.call(rbind, smpls)
# mu sd
# [1,] -0.09152588 0.9009973
# [2,] 0.05586651 1.0482184
# [3,] 0.06893182 0.7317955
# [4,] 0.13599206 0.8517304
mcmc, mcmc:
mcmc(do.call(rbind, smpls))
, start, end thin . , thin:
mcmc(do.call(rbind, smpls), thin=thin(smpls))
(, )