Search code examples
listsyntax-errorwinbugs14

"Expected collection operator c" error at WinBugs


I'm working on a differantial item functioning model using WinBUGS package. I've successfully built simpler models, but I've also gotten the error "expected collection operator c". I'd be very pleased if you could help.

# Model
Model
{

for (j in 1:40){
for (k in 1:5){
y[j,k] ~ dbern(p[j,k])
logit(p[j,k])<- u2[j] - beta[k] + gamma[k]*grp[j]
}
}
# Random effect prior
for (j in 1:40){
u2[j] ~ dnorm(0,tau.u2)
}
# Fixed effect prior
for (k in 1:5){
beta[k] ~ dnorm(0, .0001)
gamma[k] ~ dnorm(0,.0001)
}

tau.u2 <- pow(sigma.u2, -2)
sigma.u2 ~ dunif (0, 100)
}

# Data
list(y=structure(
  .Data=c(1, 1, 1, 1, 1, 
            1, 0, 1, 0, 1, 
            0, 1, 1, 1, 1, 
            1, 0, 0, 1, 1, 
            1, 0, 0, 0, 1, 
            0, 1, 1, 1, 0, 
            0, 1, 1, 1, 1, 
            1, 0, 0, 0, 1, 
            1, 0, 1, 1, 1, 
            0, 1, 0, 0, 0, 
            1, 1, 1, 0, 1, 
            0, 1, 1, 0, 1, 
            1, 1, 1, 1, 1, 
            0, 1, 0, 1, 0, 
            1, 1, 1, 1, 1, 
            0, 0, 1, 1, 1, 
            0, 0, 0, 1, 0, 
            1, 1, 1, 0, 0, 
            1, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 
            0, 1, 0, 0, 0, 
            0, 1, 0, 0, 0, 
            0, 0, 0, 0, 1,
            0, 0, 0, 0, 0, 
            0, 1, 0, 0, 0, 
            0, 0, 0, 0, 0, 
            1, 0, 0, 1, 0, 
            1, 1, 1, 1, 0, 
            1, 1, 0, 0, 1, 
            0, 1, 1, 1, 1, 
            1, 1, 0, 0, 0, 
            0, 0, 0, 1, 0,
            0, 1, 1, 1, 0, 
            1, 0, 1, 1, 0, 
            1, 0, 1, 0, 0, 
            0, 0, 1, 1, 0, 
            0, 0, 1, 1, 0, 
            0, 1, 0, 1, 0, 
            1, 1, 1, 1, 0, 
            0, 0, 0, 1, 1), 
        .Dim=c(40,5)), grp=c(1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1,      1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0))

#Initital values
list(beta=c(0, 0, 0, 0, 0), gamma=c(0, 0, 0, 0, 0), sigma.u2=1, u2=0))

Solution

  • In your model, u2 is a vector of 40 values, while you have only provided one number for its initial value. The error should have placed the cursor after the u2 initial value, which tells you where the error is. The "expected collection operator c" meant that it was expecting to see u2=c(0,0,0,... i.e. a vector of initial values.

    Though since you have provided an initial value for sigma.u2, it's probably safe to let WinBUGS auto-generate the initial values for u2.