Hi,
I am trying to write a code for generalized linear mixed model (random effects logistic regression) with non-parametric Bayesian approach with Dirichlet prior. The problem is the result that I get, is not as I was expected. It is any problem with my code below. Can someone give me an idea how to fit that model or give me some references. My code adapted from Congdon (2001);
Model:
{
for (i in 1:765) {# define outcome
y[i] ~ dbern(p[i])
logit(p[i]) <- beta0 + beta1*verage[i] + beta2*ftb[i]+ …+ e.2[sub[i]]
}
# Prior for fix
beta0 ~ dnorm(0.0,1.0E-6)
beta1~ dnorm(0.0,1.0E-6)
# model for variances
for (i in 1:85) {e.2[i] ~ dnorm(U[g[i]],tau[g[i]])
g[i]~dcat(PI[1:J])
for (j in 1:J) {Clust[i,j] <- equals(j,g[i])}}
# chek for non-empty clusters
for (j in 1:J) { num[j] <- sum(Clust[,j]); nonempty[j] <- step(num[j]-1)}
# total non-clusters
J.star <-sum(nonempty[])
for (j in 1:J){r[j] ~ dbeta(1,alpha)
ar[j] <- log(1-r[j])
PI[j] <- pi[j]/sum(pi[1:J])}
pi[1] <- r[1]
for (j in 2:J) {pi[j] <- r[j]*exp(sum(ar[1:j-1]))}
# random effects for clusters
for (j in 1:J){d[j] ~ dgamma(1,1)
tau[j] ~ dgamma(1, 0.01)
tau.s[j] <- tau[j]/d[j]
U[j] ~ dnorm(0, tau.s[j])}
}
Md Azman Shahadan
Postgraduate student,
Center for Applied Statistics
Lancaster University.
|