
#model 1
model
{
for (i in 1:N){
y[i]~dt(mu[i],tau,2)
mu[i]<-beta[Ti[i]] +b[School[i]]
Ti[i] ~ dcat(pi[])
T1[i] <- equals(Ti[i],1)#probabiliy for -ve gain group
T2[i] <- equals(Ti[i],2)#probabiliy for no gain group
T3[i] <- equals(Ti[i],3)#probabiliy for +ve gain group
}
for (s in 1: ns){ b[s]~dnorm(0,tau.b) }
PGI[1] <- sum(equals(t,0)*T3)/nc # p_C
PGI[2] <- sum(equals(t,1)*T3)/nt # p_I
GI <-  PGI[2]-PGI[1]  #gain index # GI = p_I - p_C

#mu and probabilities
pi[1:3]~ddirch(alpha[])
beta[1]~dnorm(0.0, 1.0E-6) I(LB,-0.0001 )     #LB = min(y)
beta[2]~dnorm(0.0, 1.0E-6) I(-0.0009,0.0009)
beta[3]~dnorm(0.0, 1.0E-6) I(0.0001,UB)       #UB = max(y)

#variances
tau ~ dgamma(0.001, 0.001)
tau.b ~ dgamma(0.001, 0.001)
sigma <- pow(tau,-1)
sigma.b <- pow(tau.b,-1)
}
