Menu
  • HOME
  • TAGS

WinBUGS message error: Expected key word structure

Tag: winbugs

I am new to WinBUGS and I could not get the code below to work. The model is syntactically correct (it is a hierarchical logit model with random effects), but when I click load data the error message that appears is expected key word structure. 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 n=2 (number of groups) and k=5 (number of subjects in each group).

model{
for(i in 1:n){
  for(j in 1:k){
    yij[i,j] ~ dbern(p[i,j]) 
    logit(p[i,j]) <- alpha + beta*xij[i,j] + ui[i]
  }
  ui[i] ~ dnorm(0,tau)
}
alpha ~ dnorm(0,0.001)
beta ~ dnorm(0,0.001)
tau ~ dunif(0,100) 
}

with data:

list(n=2, k=5, yij=structure(.Data=c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0), .Dim=c(2,5)),
xij = c(0.0494063719, -0.078101264, 0.2748560749, 0.1245743393, -2.531242809, .6849338859, 0.5302062384, 0.7828560148, -0.012341452, 0.5128471157), 
ui = c(0.5031197054, 0.5031197054, 0.5031197054, 0.5031197054, 0.5031197054, -2.13785637, -2.13785637, 2.13785637, -2.13785637, -2.13785637))

Best How To :

xij looks to be matrix in the BUGS model, but you have at as a vector in the data. This should work:

list(n=2, k=5, yij=structure(.Data=c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0), .Dim=c(2,5)),
xij = structure(.Data=c(0.0494063719, -0.078101264, 0.2748560749, 0.1245743393, -2.531242809, .6849338859, 0.5302062384, 0.7828560148, -0.012341452, 0.5128471157), .Dim=c(2,5)),
ui = c(0.5031197054, 0.5031197054, 0.5031197054, 0.5031197054, 0.5031197054, -2.13785637, -2.13785637, 2.13785637, -2.13785637, -2.13785637))

OpenBUGS error messages:Expected the collection operator c

bayesian,winbugs,winbugs14

A few problems in your code. In your model you have J and Length. In your data you have j (twice) and length, i.e. no Length or J. In your initial values you have ort which is not a parameter used anywhere in the model and tau which is not...

WinBUGS message error: Expected key word structure

winbugs

xij looks to be matrix in the BUGS model, but you have at as a vector in the data. This should work: list(n=2, k=5, yij=structure(.Data=c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0), .Dim=c(2,5)), xij = structure(.Data=c(0.0494063719, -0.078101264, 0.2748560749, 0.1245743393, -2.531242809, .6849338859, 0.5302062384, 0.7828560148, -0.012341452, 0.5128471157), .Dim=c(2,5)), ui =...