WINBUGS: Array index is greater than array upper bound for thd2

Viewed 22

I'm fairly new to coding in WINbugs, but nothing on google seems to point me in the right direction. The model appears syntactically correct, data loads, but when compiling program reports "Array index is greater than upper bound for thd2". Any ideas on why this might be? Thd2's dimensions seem to be correct. I don't understand what array it's referring to.

model{
    for(i in 1:N){
        #measurement equation model
        for(j in 1:3){
            y[i,j]~dnorm(mu[i,j],psi[j])I(thd[j,z[i,j]],thd[j,z[i,j]+1])
            ephat[i,j]<-y[i,j]-mu[i,j]
        }
        for(j in 4:5){
            y[i,j]~dnorm(mu[i,j],psi[j])I(thd2[j,z[i,j]],thd2[j,z[i,j]+1])
            ephat[i,j]<-y[i,j]-mu[i,j]
        }
        
        mu[i,1]<-eta[i]             #Salud Fisica F.1.1
        mu[i,2] <- lam[1]*eta[i]     #Salud mental F.2.1
        mu[i,3] <- lam[2]*eta[i]    #Salud fisica y mental F.3.1
        
        mu[i,4]<-xi[i]                #Uso de alcohol N.6.1
        mu[i,5]<-lam[3]*xi[i]       #Uso de tabaco N.6.2
        
                                                        
        #structural equation model
        xi[i]~dnorm(0,1)
        nu[i]<-gam*xi[i]
        eta[i]~dnorm(nu[i],psd)
        dthat[i]<-eta[i]-nu[i]
    }# end of i
    
    #priors on loadings and coefficients
    var.lam[1]<-4.0*psi[2]     var.lam[2]<-4.0*psi[3]       var.lam[3]<-4.0*psi[5]      
    for(i in 1:3){lam[i]~dnorm(0.8,var.lam[i])} 

    var.gam<-4.0*psd
    gam~dnorm(0.6,var.gam)    
    
    #priors on precisions
    for(j in 1:P){
        psi[j]~dgamma(10,8)
        sgm[j]<-1/psi[j]
    }
    psd~dgamma(10,8)
    sgd<-1/psd
    
} #end of model

Data Set
list(N=272,  P=5,
    thd=structure(
          .Data=c(-200.000,-0.993,-0.82, -0.553, -0.232, 200.000,
-200.000,-0.962,-0.833,-0.645,-0.311,200.000,
-200.000,-0.945,-0.847,-0.695,-0.472,200.000),
          .Dim=c(3,6)),
    thd2=structure(
          .Data=c(-200.000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