model{ for (j in 1:N){ DD[j] ~ dnorm(thet[j], tau); thet[j] <- p[j] * xi1[j] + (1-p[j]) * xi2[j]; xi1[j] ~ ddexp(0, tau1); latent[j]~dcat(pi[1:L]) # L is the truncation point. We need to put a value for L xi2[j] <-theta[latent[j]] p[j] ~ dbern(r[j]); r[j] ~ dbeta(1, inputp) } # Sethuraman's stick-breaking construction for ( k in 1:L) { r[k]~dbeta(1,alpha) theta[k]~dnorm(theta0,tau0) #baseline distribution. # One can put other distribution also, # like double exponential } pi[1]<-r[1] for ( j in 2:(L-1)) { log(pi[j])<-log(r[j])+sum(D1[j,1:j-1]) for ( l in 1:j-1) { D1[j,l]<-log(1-r[l]) } } pi[L]<-1-sum(pi[1:(L-1)]) theta0~dnorm(0,0.1) tau0~dgamma(1,1) alpha~dunif(0.4, 5) # based on Ohlssen and tau ~ dgamma(1, inputs); tau1 ~ dgamma(at1, bt1); }