# Undefined real result error at WinBUGS

I am currently working on my thesis and interested in estimating a multilevel differential item functioning model and I using at WinBUGS. Until I had done model check-up, there are no errors. However, when I tried to "update" the sample, suddenly the trap message said "undefined real result" popped up. What am I doing wrong? Also, I have tried different prior and initial values but I could not solve the problem!

   # Model
Model
{
for (l in 1:10){
y[l] ~ dbern(p[l])
logit(p[l])<- u2[stu[l]] - beta[x[l]] + gamma[tea[l], x[l]]*grp[l] + alpha1[x[l]] *geo[l] +
alpha2[x[l]]*conf[l] + alpha3[x[l]]*ses[l]
}
for (t in 1:5){
for (i in 1:5){
gamma[t,i] ~ dnorm(gamma.hat[t,i], tau.gamma[i])
gamma.hat[t,i]<-pi1[i] + pi2[i]*inq[t]
}
}
# fixed effect prior
for (i in 1:5){
beta[i] ~ dnorm(0, .0001)
alpha1[i] ~ dnorm(0, .0001)
alpha2[i] ~ dnorm(0, .0001)
alpha3[i] ~ dnorm(0, .0001)
pi1[i] ~ dnorm(0, .0001)
pi2[i] ~ dnorm(0, .0001)
}
# Random effect prior
for (s in 1:10){
u2[s] ~ dnorm(0,tau.u2)
}
tau.u2 <- pow(sigma.u2, -2)
sigma.u2 ~ dunif (0, 100)
for (i in 1:5){
tau.gamma[i] <- pow(sigma.gamma[i],-2)
sigma.gamma[i] ~ dunif(0, 100)
}
}

# Data
list(y=c(0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0,  1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0), ses=c(2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1), conf=c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1,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, 1, 1, 1), u2=c(0, 0, 0, 0, 0), pi1=c(0, 0, 0, 0, 0), pi2=c(0, 0, 0, 0, 0), sigma.u2=1, gamma=structure(
.Data=c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim=c(5, 5)))

• @gung BUGS (and WinBUGS) differ from other coding platforms in that (a) they are dedicated to running statistical models (and cannot run general-purpose code) and (b) frequently errors result from mis-specifying or misunderstanding those models, rather than from errors of syntax or organization of code. Chris Jackson's answer provides an example of what kind of help might be useful. It suggests to me that this question should be considered on topic here.
– whuber
Oct 22, 2014 at 23:15
• @whuber, fair enough. I have retracted my close vote. Oct 22, 2014 at 23:37

There's a lot of unknown parameters with very weak priors, and only 10 observations. Did you mean to only use the first 10 out of the 50 y's? Even with 50 observations it still looks like a complicated model to try to identify. It's probably failed numerically because the initial values are implausible given the data, or the priors are too diffuse for the data to give any information. I'd suggest simplifying it until you have some idea what the parameter values should be, and then building it up step by step.

• Thank you for your interest and your answer. In fact, I am working with about 500 people and I have nine variables. For the completion of calculations in a short time, I'm running on a small sample. If I am not encountering an error, I will do with the real practice data. I get the reference in a dissertation that he studied in multilevel differential item functioning, initial values of fixed effect parameters and μ and u2 are all set to “0”. For the standard deviation parameters, “1” is used as the initial value. I continue to read from different sources about the subject. Oct 22, 2014 at 21:21