This is a common problem with models involving log-odds. A 32-bit computer
running WinBUGS 1.4 rounds any value greater than .9999999999999999 to 1.
this creates a divide-by-zero situation in the logit transformation, thus
producing the "undefined real result."
The easiest way to solve this problem is to compensate for the imprecision
of the computer by putting limits on the estimates probabilities. For
example see the min/max approach in the code below:
model {
cutpoint[1] ~ dnorm(0, 0.001)I(,cutpoint[2])
cutpoint[2] ~ dnorm(0, 0.001)I(cutpoint[1],)
for ( i in 1:N ) {
mu[i] <- beta * x[i]
for ( j in 1:(Nclasses-1) ) {
P[i,j] <- max(.000000000000,min(.999999999999,Q[i,j]))
logit(Q[i,j]) <- cutpoint[j] - mu[i]
}
}
beta ~ dnorm(0, 0.001)
for ( i in 1:N ) {
p[i,1] <- P[i,1]
p[i,2] <- P[i,2] - P[i,1]
p[i,3] <- 1 - P[i,2]
y[i] ~ dcat(p[i,])
}
}
________________________________________________
Henry May, Ph.D.
Research Specialist and Lecturer
Consortium for Policy Research in Education
Graduate School of Education
University of Pennsylvania
(215) 573-0700 x236
[log in to unmask]
-----Original Message-----
From: (The BUGS software mailing list) [mailto:[log in to unmask]] On
Behalf Of Michael Bedward
Sent: Thursday, December 18, 2003 8:04 PM
To: [log in to unmask]
Subject: [BUGS] undefined real result trap
Dear list members
I am attempting a latent variable analysis of ordered categorical response
data. My model compiles but when running it falls into the "undefined real
result" trap every few thousand replicates. The error can be provoked by
the simplified version of my model, with a single covariate and small
contrived data set, that I have included below. If anyone can tell me what
I'm doing wrong I would be most grateful.
cheers
Michael
model {
cutpoint[1] ~ dnorm(0, 0.001)I(,cutpoint[2])
cutpoint[2] ~ dnorm(0, 0.001)I(cutpoint[1],)
for ( i in 1:N ) {
mu[i] <- beta * x[i]
for ( j in 1:(Nclasses-1) ) {
logit(P[i,j]) <- cutpoint[j] - mu[i]
}
}
beta ~ dnorm(0, 0.001)
for ( i in 1:N ) {
p[i,1] <- P[i,1]
p[i,2] <- P[i,2] - P[i,1]
p[i,3] <- 1 - P[i,2]
y[i] ~ dcat(p[i,])
}
}
#inits
list(cutpoint=c(5,8), beta=1)
#data
list(N=15, Nclasses=3)
y[] x[]
1 16
1 7
1 13
1 9
1 11
2 3
2 2
2 7
2 4
2 1
3 21
3 17
3 14
3 21
3 22
END
---
Michael Bedward
Biodiversity Research & Management
Policy and Science Division
Dept. Environment and Conservation
[log in to unmask]
ph: 61-(0)2-95856493 fax: 61-(0)2-95856606
This message is intended for the addressee named and may contain
confidential information.
If you are not the intended recipient, please delete it and notify the
sender. Views expressed in this message may be those of the individual
sender, and are not necessarily the views of the NSW Department of
Environment and Conservation.
-------------------------------------------------------------------
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
-------------------------------------------------------------------
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
|