Hello, Thank you for your replies. I have made some changes on my model but
it still does not work. I am trying to model: levels doses
10.5 35 87.5 262.5 700 1050
non efficacy (1) 2 1 1 1 0 0
low efficacy (2) 1 1 0 1 1 1
moderate efficacy (3) 1 1 1 0 1 1
high efficacy (4) 0 0 1 1 1 2
The code that I use is:
model
{
for(i in 1:N)
{
for(k in 1:(nlevel-1))
{
logit(cum[i,k])<-b[i,k]
b[i,k]~dnorm(mu[i,k],tau)
mu[i,k]<-alpha[k]+beta[k]*log(dose[i])
}
p[i,1]<-1-cum[i,1]
for (k in 2:(nlevel-1)){
p[i,k]<-cum[i,(k-1)]-cum[i,k]
}
p[i,nlevel]<-cum[i,(nlevel-1)]
level[i]~dcat(p[i,])
}
for (k in 1:(nlevel-1))
{
alpha[k]~dnorm(0.0,0.0001)
beta[k]~dnorm(0.0,0.0001)
} tau~dgamma(0.01,0.01) }
list(level=c(1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3),dose=c(10.5,10.5,35,87.5,10.5,35,87.5,262.5,700,1050,10.5,35,87.5,262.5,700,1050),N=16,nlevel=4)
list(beta=c(0.1,0.5,0.005),alpha=c(-1,-5,-11),tau=0.1)
list(beta=c(0.001,0.9,0.7),alpha=c(-10,-3,-1),tau=0.001)
And the error messages: The chain containts uninitialized variables. And if
I try to generate initial values: elements of proportion vector of
cathegorical level[1] must be between 0 and 1. I would be very greatful for
any help provided in order to resolve this problem.
Best regards,
Oscar Camacho.
MSc Student at Reading University.
Hei Oscar! There's an example of ordered logit in the WinBUGS examples:
http://www.mrc-bsu.cam.ac.uk/bugs/documentation/exampVol1/node24.html . You
could start from their code. If you look at that code, they use multiple
types of observations (indexed by j). You only have one type with 4 levels.
So get rid of the for(j in ...) statement and all the dimensions with j in
the example code. (I.e. you would have Q[i,k] instead of Q[i,j,k].) Maybe
this helps you already to point you on your way! Regarding your code below,
I think there are the following problems: 1. The way you did it, the
difference between e.g. cum[1,3] and cum[1,2] could be negative. 2. Your k
loop should go 1 to 3 because you are never using cum[i,4]. 3. There's a
typo in the line with p[i,3], it should be cum[i,3] not [1,3]. Best wishes
- . . . Christian On Tue, 03 Aug 2010 05:11:57 +0300, Oscar Camacho
<[log in to unmask]> wrote: > Hello all,>> I am trying to code
a proportional odds model with 4 levels. WinBUGS > sends the message: The
chain containts uninitialized variables. And if I > try to generate initial
values: elements of proportion vector of > cathegorical level[1] must be
between 0 and 1.>> I would be grateful if somebody could point me on the
right direction. > The code is:>> model> {> for(i in 1:N)> {> for(k in
1:4)> {> logit(cum[i,k])<-b[i,k]> b[i,k]~dnorm(mu[i,k],tau)>
mu[i,k]<-alpha[k]+beta[k]*log(dose[i])> }> p[i,4]<-1-cum[i,3]>
p[i,1]<-cum[i,1]> p[i,2]<-cum[i,2]-cum[i,1]> p[i,3]<-cum[1,3]-cum[i,2]>
level[i]~dcat(p[i,])> }> for (k in 1:4)> {> alpha[k]~dnorm(0.0,0.0001)>
beta[k]~dnorm(0.0,0.0001)> }> tau~dgamma(0.001,0.001)> }>
list(level=c(1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4),dose=c(10.5,10.5,35,87.5,10.5,35,87.5,262.5,700,1050,10.5,35,87.5,262.5,700,1050,262.5,700,1050,1050),N=20)>
list(beta=c(0.1,0.5,0.005,0.2),alpha=c(-1,-5,-11,-100),tau=0.1)>
list(beta=c(0.001,0.9,0.7,0.3),alpha=c(-10,-3,-1,-9),tau=0.001)>>> Thank
you.> Oscar.
-------------------------------------------------------------------
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
|