OpenBUGS error messages:Expected the collection operator c

1k views Asked by At

I could not get the code below to work. it is a hierarchical one way ANOVA model, but when I click data load the error message that appears is expected the collection operator c. What does that mean? Can anyone please help me work the code below please? My data set is bigger, but to simplify the question I am only working here with season=4 (number of groups) and n=5 (number of subjects in each group).

model{
for(i in 1:n){
    Length[i] ~ dnorm(mu.l[i], tau[1]) 
    mu.l[i] <- alpha[j[i]]
}
for (p in 1:J){
    alpha[p]~dnorm(mu, tau[2])
}
mu~dnorm(0,0.0001)
for(k in 1:2){
    tau[k]<-pow(sigma[k],-2)
    sigma[k]~dunif( 0, 10)
}
}

#initials    
list( ort=1.0, alpha=c(NA, 0,0,0), tau=c(1 ,1))  

#Data
list(n=5, j=4)  
j[] length[]  
1   17.00
1   17.50
1   17.50
1   16.20
1   18.00
2   13.70
2   17.4
2   17.70
2   16.40
2   17.70
3   16.4
3   15.00
3   19.60
3   14.70
3   18.00
4   18.20
4   13.60
4   17.30
4   17.3
4   14.5  
1

There are 1 answers

2
guyabel On BEST ANSWER

A few problems in your code.

  1. In your model you have J and Length. In your data you have j (twice) and length, i.e. no Length or J.

  2. In your initial values you have ort which is not a parameter used anywhere in the model and tau which is not stochastic (perhaps you mean sigma?).

Your model above should work with the following (whether it is the model you want or not is for you to decide):

#Initials
list( alpha=c(NA, 0,0,0))  

#Data
list(n=5, J=4, j=c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4), Length=c(17,17.5,17.5,16.2,18,13.7,17.4,17.7,16.4,17.7,16.4,15,19.6,14.7,18,18.2,13.6,17.3,17.3,14.5))