Hello everyone,
I'm having a problem trying to get my binomial mixture model to update. I'm able to compile the model, but I reach a problem when I load initial values. I load the initial values for my regression parameters, the abundance estimates(N) and the detection probability(p), but OpenBUGS states that I still have uninitialized parameters so I hit the 'gen inits' button provided on the model specification tab and I get the error message 'error for node y[3,3,1] of type GraphBinomial.Node second argument invalid integer value given'.
I'm unsure of why this is happening or what to do to fix this error so any help would be greatly appreciated. I've pasted my code and the data structures below. Thank you in advance.
model {
#Priors
for (k in 1:7) {
p[k]~dunif(0,1)
}
alpha0~dunif(-10,10)
alpha1~dunif(-10,10)
#Likelihood
#Ecological model for true abundance (process model)
for (k in 1:7) { #Loop over years
for (i in 1:R) { #Loop over R sites
N[i,k]~dpois(lambda[i,k]) #Abundance
log(lambda[i,k])<-alpha0+alpha1*well[i,k]
#Observation model for replicated counts
for (j in 1:T) { #Loop over repeated counts
y[i,j,k] ~dbin(p[k],N[i,k]) #Detection
#Assess model fit using Chi-squared discrepancy
#Compute fit statistic "E" for observed data
eval[i,j,k]<-p[k]*N[i,k] #Expected values
E[i,j,k]<-pow((y[i,j,k]-eval[i,j,k]),2)/(eval[i,j,k]+0.5)
#Generate replicate data and compute fit stats for them
y.new[i,j,k]~dbin(p[k],N[i,k])
E.new[i,j,k]<-pow((y.new[i,j,k]-eval[i,j,k]),2)/(eval[i,j,k]+0.5)
}#j
}#i
}#k
#Derived and other quantities
#for(k in 1:7) {
#totalN[k]<-sum(N[,k]) #Total pop. size across all sites
#mean.abundance[k]<-exp(alpha.lam[k])
#}
fit<-sum(E[,,])
fit.new<-sum(E.new[,,])
}
#Data
list(R=669,T=3)
#inits
list(alpha0=0.92,alpha1=-0.57)
str(y)
'data.frame': 669 obs. of 21 variables:
$ y..1.1.: int 8 5 0 14 21 6 4 5 18 0 ...
$ y..1.2.: int 23 0 0 15 32 4 8 5 35 0 ...
$ y..1.3.: int 14 0 0 10 30 18 19 2 19 2 ...
$ y..1.4.: int 8 2 5 21 32 0 6 0 21 0 ...
$ y..1.5.: int 9 0 23 15 20 0 0 0 19 0 ...
$ y..1.6.: int 0 0 0 5 1 9 10 3 19 0 ...
$ y..1.7.: int 6 0 0 2 18 0 10 0 11 0 ...
$ y..2.1.: int 20 6 0 21 30 12 15 8 5 0 ...
$ y..2.2.: int 21 0 0 16 34 5 0 3 NA 0 ...
$ y..2.3.: int 14 0 0 NA 12 23 7 0 16 0 ...
$ y..2.4.: int 9 0 5 18 30 4 16 5 11 0 ...
$ y..2.5.: int 1 0 4 24 40 2 15 4 13 0 ...
$ y..2.6.: int 6 0 NA 2 10 0 12 NA 11 0 ...
$ y..2.7.: int 17 NA 0 14 18 4 22 1 5 0 ...
$ y..3.1.: int 10 5 NA 7 13 10 0 0 18 2 ...
$ y..3.2.: int 19 NA 1 9 22 2 NA NA NA 0 ...
$ y..3.3.: int 12 NA 0 NA 5 8 12 0 20 0 ...
$ y..3.4.: int 7 1 5 16 10 2 29 8 11 0 ...
$ y..3.5.: int 6 0 2 21 6 0 16 8 16 0 ...
$ y..3.6.: int 0 0 NA NA 0 12 NA NA 12 0 ...
$ y..3.7.: int 17 NA 0 12 36 8 13 0 7 0 ...
> str(wells)
'data.frame': 669 obs. of 7 variables:
$ well..1.: num 0 0 0 0 0 ...
$ well..2.: num 0 0 0 0 0 ...
$ well..3.: num 0 0 0 0 0 ...
$ well..4.: num 0 0 0 0 0 ...
$ well..5.: num 0 0 0 0 0 ...
$ well..6.: num 0 0 0 0 0 ...
$ well..7.: num 0 0 0 0 0 ...
str(initialN)
'data.frame': 669 obs. of 7 variables:
$ N..1.: int 13 5 0 14 21 9 6 4 14 1 ...
$ N..2.: int 21 0 0 13 29 4 3 3 12 0 ...
$ N..3.: int 13 0 0 3 16 16 13 1 18 1 ...
$ N..4.: int 8 1 5 18 24 2 17 4 14 0 ...
$ N..5.: int 5 0 10 20 22 1 10 4 16 0 ...
$ N..6.: int 2 0 0 2 4 7 7 1 14 0 ...
$ N..7.: int 13 0 0 9 24 4 15 0 8 0 ...
> str(initialp)
$ p..: num 0.694 0.663 0.807 0.455 0.798 ...
-------------------------------------------------------------------
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
|