Hi,
I'm running an Zero-inflated Poisson abundance model through R2WinBUGS and I have an error that I can't solve.
Here's an exemple of the dataset I have and my model.
c1<-c(0,2,0,3,0,4,4,2,5,0,0,0,2)
c2<-c(0,2,0,3,5,4,0,2,5,0,0,0,2)
c3<-c(1,3,0,3,0,0,4,2,5,0,2,0,2)
c4<-c(0,2,0,3,0,4,3,2,5,0,0,0,0)
C<-cbind(c1,c2,c3,c4)
n.site<-13
cov<-sort(runif(n=n.site,min=0,max=1))
R<-n.site
S<-4
#Define the Zero-inflated Poisson model
sink("boat.txt")
cat("
model {
#Priors
alpha~dunif(-20,20) #Intercept
beta~dunif(-20,20) #Slope
omega~dunif(0,1) #Parameter for the suitability of the site
#ZIPoisson likelihood
#Ecological model of the true abundance
for (i in 1:R) { #Starts loop over R sites
for (j in 1:S) { #Starts loop over the S surveys
z[i,j]~dbern(omega)
C[i,j]~dpois(lambda.eff[i,j])
lambda.eff[i,j]<-z[i,j]*lambda[i,j]
lambda[i,j]<-exp(alpha+beta*cov[i])
}
}
}
",fill=TRUE)
sink()
#WinBUGS analysis
library(R2WinBUGS)
#Bundle data
win.data<-list(C=C,cov=cov,R=dim(C)[1],S=dim(C)[2])
#Inits function
zst<-apply(C,1,max)
inits<-function() { list(z=zst,alpha=runif(R,-10,10),beta=runif(R,-10,10),omega=runif(R,0,1))}
#Parameters to estimate
parameters<-c("alpha","beta","omega")
#MCMC settings
ni<-12000
nb<-2000
nt<-3
nc<-3
#Start Gibbs sampling
out<-bugs(win.data,inits,parameters,"boat.txt",n.thin=nt,n.chains=nc,n.burnin=nb,n.iter=ni,debug=TRUE)
And I tried a several things to fix this model but I always come with this type of error:
display(log)
check(C:/DOCUME~1/SARAH~1.BAU/LOCALS~1/Temp/RtmpZlOQFY/boat.txt)
model is syntactically correct
data(C:/DOCUME~1/SARAH~1.BAU/LOCALS~1/Temp/RtmpZlOQFY/data.txt)
data loaded
compile(3)
model compiled
inits(1,C:/DOCUME~1/SARAH~1.BAU/LOCALS~1/Temp/RtmpZlOQFY/inits1.txt)
expected key word structure
inits(2,C:/DOCUME~1/SARAH~1.BAU/LOCALS~1/Temp/RtmpZlOQFY/inits2.txt)
inits(3,C:/DOCUME~1/SARAH~1.BAU/LOCALS~1/Temp/RtmpZlOQFY/inits3.txt)
gen.inits()
value of bernoulli z[1,3] must be an integer
thin.updater(3)
update(667)
command #Bugs:update cannot be executed (is greyed out)
...
Does someone can help me ?
Thanks
-------------------------------------------------------------------
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
|