Dear All:
I'm trying to implement a capture recapture model using Winbugs. My program
is given below. I use zeros trick to specify the likelihood function. It
works if there are no missing data, but give a error message called
"undefined real result" when there are missing data. Anybody can help me to
identify the error?
Thanks,
Saman
model
{
k<-500000
tau<-1/(sigma*sigma)
for(i in 1:N){
term1[i,1] <- s[i,1]*log(pow(p,c[i,1])*pow(1-p,1-c[i,1]))
term2[i,1] <- 0
term3[i,1]<- 0
t[i,1]~dlnorm(mu,tau)
z[i,1]<-pow(q,t[i,1])
s[i,1]~dbin(.9,1)
for(j in 2:a){
z[i,j]<-pow(q,t[i,j])
term1[i,j] <- s[i,j]*log(pow(p,c[i,j])*pow(1-p,1-c[i,j]))
term2[i,j] <- s[i,j-1]*log(pow(z[i,j-1],s[i,j])*pow(1-z[i,j-1],1-s[i,j]))
term3[i,j]<-
(-1*log((t[i,j]-t[i,j-1]))-log(.39*sigma)-.5*pow((log(t[i,j]-t[i,j-1])-mu)/s
igma,2))*s[i,j]
phi[i,j] <- k- term1[i,j]-term2[i,j]-term3[i,j]
-term1[i,1]-term2[i,1]-term3[i,1]
zeros[i,j]~dpois(phi[i,j])
t[i,j]~dlnorm(mu,tau)
s[i,j]~dbin(.9,1)
}
}
q~dbeta(1,1)
p~dbeta(1,2)
#sigma~dgamma(1,.001)
#mu~dgamma(1,.001)
}
list(N=5,a=5,mu=1,sigma=.1,
c=structure(.Data=c( 0, 1, 1, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 1,
1, 1, 1, 0, 0,
0, 1, 1, 1, 0),.Dim=c(5,5)),
s=structure(.Data=c(1, 1, 1, NA, NA,
NA, NA, NA, NA, NA,
1, 1, 1, 1, 1,
1, 1, 1, NA, NA,
1, 1, 1, 1, NA),.Dim=c(5,5)),
t=structure(.Data=c(NA, 4.696472, 7.557388, NA, NA,
NA,NA,NA,NA,NA,
NA, 7.122446, NA,NA, 15.084123,
1.277658, 3.461120, 5.306603, NA,NA,
NA, 5.740115, 8.968094, 11.903670, NA),.Dim=c(5,5)))
-------------------------------------------------------------------
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
|