
                model{
                for(i in 1:N){
                post[i] ~ dnorm(mu[i],tau)
                mu[i] <- beta[1]+beta[2]*Prettest[i]+beta[3]*Intervention21[i]+beta[4]*Intervention22[i]+b1[School[i]]+b2[School[i],tt[i]] 
                }

                for(j in 1:M){
                b1[j]~dnorm(0.0,tau.b1)
                #b2[j]~dnorm(0.0,tau.b2)
                for(k in 1:round(NPost.T)){ b2[j,k]~dnorm(0.0,tau.b2) }
                for(k in 2:round(NPost.T)){ b2diff[j,k ] <- b2[j,k] - b2[j,1] }
                }

                tau~dgamma(0.001,0.0001)
                tau.b1~dgamma(0.001,0.0001)
                tau.b2~dgamma(0.001,0.0001)
                sigma<-1/tau
                sigma.b1<-1/tau.b1
                sigma.b2<-1/tau.b2

                for(k in 1:p){beta[k]~dnorm(0.0,1.0E-06)}

                # ICC and TOTAL VARIANCE
                sigma.Total <-sigma + sigma.b1 + sigma.b2
                COND.icc <- (sigma.b1+sigma.b2) * pow(sigma.Total ,-1)
                UNC.ICC <- UNC.icc

                #sigmas
                COND.sigma.Total <- sigma.Total
                COND.sigma.Within <- sigma.b1
                COND.sigma.between <- sigma.b2
                COND.Trt.schl <-sigma.b2
                UNC.sigma.Total <- UNC.sigma.tt
                UNC.sigma.Within <- UNC.sigma


                # EFFECT SIZE
                for(pp  in round(Post.T)){
                COND.d.Within[pp] <- beta[pp]/sqrt(COND.sigma.Within)#conditional
                COND.d.Total[pp]  <- beta[pp]/sqrt(COND.sigma.Total)#conditional
                UNC.d.Within[pp]  <- beta[pp]/sqrt(UNC.sigma.Within)#unconditional
                UNC.d.Total[pp]  <- beta[pp]/sqrt(UNC.sigma.Total)#unconditional

                #hedges g ES
                COND.ES.Within[pp]<- COND.d.Within[pp]* (1- (3/(4*(N-2)-1)))#conditional
                COND.ES.Total[pp] <-  COND.d.Total[pp]* (1- (3/(4*(N-2)-1)))#conditional
                UNC.ES.Within[pp]<- UNC.d.Within[pp]* (1- (3/(4*(N-2)-1)))#unconditional
                UNC.ES.Total[pp] <-  UNC.d.Total[pp]* (1- (3/(4*(N-2)-1)))#unconditional

                #Posterior probabilities
                for(thd  in round(threshold1)){
                COND.ProbES.Within[pp, thd]<- step(COND.d.Within[pp] - threshold[thd] )#conditional
                COND.ProbES.Total[pp, thd] <-  step(COND.d.Total[pp] - threshold[thd] )#conditional
                UNC.ProbES.Within[pp, thd]<- step(UNC.d.Within[pp] - threshold[thd] )#unconditional
                UNC.Prob.Total[pp, thd] <-  step(UNC.d.Total[pp] - threshold[thd] )#unconditional
                }
                }
                }
                