Hi, all, I am trying to implement Samejima's graded response model in WinBUGS to analyze student responses to a set of polytomous items in a test. The code was compiled okay; however, when I asked it to generalize initials, it gives the error that "the elements of proportion vector of X must be between zero and one". Here X is student response as shown in the following code. I think the problem is that in graded response model, it requires that prob(x>=k) - prob(x>=k+1) is nonnegative (k is response category), while this is not controlled in my code. My question is how to control for this condition? Does Bugs have some "if then" statement so that I can discard the sampled values when this expression is negative? And any suggestions about graded response model in Bugs would be appreciated. My code is as the following: # N-Number of subjects # T-Number of items #ncat-Number of response categories of each item #x[i,j] is student i's response to item j. for (i in 1:N) { theta[i]~dnorm(0,tautheta) for (j in 1:T) { for (k in 1:ncat[j]-1){ Q[i,j,k] <- exp(a[j,k]*(theta[i]-b[j,k]))/(1+exp(a[j,k]*(theta[i]-b[j,k]))); } p[i,j,1]<-1-Q[i,j,1] for (k in 2:ncat[j]-1){ p[i,j,k]<-Q[i,j,k-1]-Q[i,j,k] } p[i,j,ncat[j]]<-Q[i,j,ncat[j]-1] x[i,j]~dcat(p[i,j,1:ncat[j]]) } } Thanks a lot, Celia Ye --------------------------------- Get your email and more, right on the new Yahoo.com ------------------------------------------------------------------- This list is for discussion of modelling issues and the BUGS software. For help with crashes and error messages, first mail [log in to unmask] To mail the BUGS list, mail to [log in to unmask] Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html Please do not mail attachments to the list. To leave the BUGS list, send LEAVE BUGS to [log in to unmask] If this fails, mail [log in to unmask], NOT the whole list