# RJAGS bayesian approach of mixed effects model

Why my posterior result always shows that the sigma and sigma.c estimates to be around 50? It should not be that large as I know from another approach of analysis and also summary of the data. Is it because I have only one observation for each year-country combination?

write("
model {
for(i in 1:n) {
life[i] ~ dnorm(a[Country[i]]+ b[Year[i]]+b7*fertrate[i], sigma^(-2))
}
b[1]~dnorm(0,0.0001)
b[2]~dnorm(0,0.0001)
b7~dnorm(0,0.0001)
sigma ~ dunif(0, 100)

for(j in 1:J) {
a[j] ~ dnorm(0 , sigma.c^(-2))
}
sigma.c ~ dunif(0, 100)

}
", "life3.jags")
mm3.jags = jags.model("life3.jags", data=list(J=194, n=376, Country=suit1213d$Country, Year=suit1213d$Year,fertrate=suit1213d$fertrate),n.adapt=100,n.chains=3) mm3.vars = c("b","b7", "sigma", "sigma.c") mm3.sim = coda.samples(mm3.jags, mm3.vars, n.iter = 50000,thin=100) summary(mm3.sim) Iterations = 5100:55000 Thinning interval = 100 Number of chains = 3 Sample size per chain = 500 1. Empirical mean and standard deviation for each variable, plus standard error of the mean: Mean SD Naive SE Time-series SE b[1] -1.020 96.35 2.4877 2.5759 b[2] -1.447 102.76 2.6533 2.3972 b7 2.383 98.23 2.5362 2.5360 sigma 50.231 28.45 0.7346 0.7204 sigma.c 50.836 28.82 0.7440 0.7432  ## 1 Answer The mean estimates are around 50, but the SD indicates that the true value could be anywhere between roughly 0-100. This is identical to the prior - and it is the same for the other parameters as well - because there doesn't seem to be a likelihood in your model (i.e. nothing specified on the left hand side of a ~ is included in the data). At a guess, you meant to include something like: life = suit1213d$life


... inside the data argument to jags.model.

Just to be thorough, it is also worth pointing out that the priors for sigma and sigma.c are quite informative towards higher values of standard deviation - it would be worth comparing your results to something with different priors (possibly gamma or even better something like Half Cauchy or DuMouchel which are both implemented in the runjags package). Finally, there is no way to assess convergence from what you have shown us but that is also important.