I was fitting a random coefficient quadratic model in jags with all three regression coefficient parameters as varying. See the following extract of the JAGS/BUGS code:
for (i in 1:length(y)) {
mu[i] <- beta1[subject[i]] + beta2[subject[i]] * trial[i] +
beta3[subject[i]] * pow(trial[i], 2);
y[i] ~ dnorm(mu[i], tau.c)
}
# Random coefficients
for (i in 1:N) {
beta1[i] ~ dnorm(beta1.mu, beta1.tau);
beta2[i] ~ dnorm(beta2.mu, beta2.tau);
beta3[i] ~ dnorm(beta3.mu, beta3.tau);
}
I then ran the model
mod1 <- jags.model("model.txt", data=jagsdata, n.chains=4, n.adapt=1000)
update(mod1, 200) # burn in
# monitor
mod1.samples <- coda.samples(model=mod1,
variable.names=c('beta1.mu', 'beta1.sigma',
'beta2.mu', 'beta2.sigma',
'beta3.mu', 'beta3.sigma',
'sigma.c'),
n.iter=1000)
summary(mod1.samples) # print descriptive statistics of posterior densities for parameters
and received the warning:
Warning message:
glm.fit: algorithm did not converge
The warning is discussed here. Martyn Plummer suggests that the warning can indcate poor mixing, and that one strategy is “to do quite a long run with a large thinning interval”.
When I increased the iterations and incorporated thinning, the warning went away:
mod1.samples <- coda.samples(model=mod1,
variable.names=c('beta1.mu', 'beta1.sigma',
'beta2.mu', 'beta2.sigma',
'beta3.mu', 'beta3.sigma',
'sigma.c'),
n.iter=10000, thin=10)