I am running a spatial temporal models in OpenBUGS and I am getting an error "Invalid use of range construct"
When I run the same model in winBUGS I get the following error "NIL dereference (read)"
I have tried to correct the error without success.
I would greatly appreciate your assistance to solve this error.
model{
#Likelihood
for(i in 1:N){
Pf[i]~dbin(p[i],Ex[i])
Ex[i] ~ dcat (p2[])
mu[i]<-alpha+V[time[i]]+W[site[i] ] #logit link
logit(p[i])<- mu[i]
prop[i]<-exp(mu[i])/(1+exp(mu[i])) #predictive distribution on proportion scale
}
# discrete prior on 10 to 60
for (j in 1 :9) { p2[j] <-0 }
for (j in 10:60) { p2[j] <- 1/51}
for(i in 1:NSITES){muW[i]<-0.0} #spatial effects
W[1:NSITES]~spatial.exp(muW[],Long[],Lat[],spat.prec,phi,1)
phi~dunif(0,10)
for(i in 1:NTime){muV[i]<-0.0} # temporal effects
V[1:NTime]~spatial.exp(muV[],Long.t[],Lat.t[],temporal.prec,phi.t,1)
phi.t~dunif(0,10)
spat.prec~dgamma(0.01,0.01) #prior distribution for spatial effects
sigmasq<-1/spat.prec #spatial effects variance
temporal.prec~dgamma(0.01,0.01) #prior distribution for temporal effects
sigmasq.temp<-1/temporal.prec # temporal effects variance
alpha~dnorm(0.0,1.0E-06) # prior distribution for alpha
#pop.mean<-exp(mu)/(1+exp(mu)) #predictive distribution on proportion scale
#Making independent predictions at unobserved locations
for(j in 1:M){
muW0[j]<-0
muV0[j]<-0
W0[j]~spatial.unipred(muW0[],Long0[],Lat0[],W[])
V0[j]~spatial.unipred(muV0[],Long.t0[],Lat.t0[],V[])
r0[j]<-alpha+W0[j]+V0[j]
pred.prop[j]<-exp(r0[j])/(1+exp(r0[j]))
}
}
#intial values
#Initial values for site and Time
list(alpha=0,phi=1,phi.t=1,spat.prec=1,temporal.prec=1,W=c(0,0,0,0,0,0,0,0,0,0),
V=c(0,0,0,0,0,0,0,0,0,0))
#Initial values of predictions
list(W0=c(0,0,0,0,0,0,0,0,0,0),V0=c(0,0,0,0,0,0,0,0,0,0) )
#Data
list(N=10,NSITES=10,NTime=10,M=10,Long=c(1.211,1.212,1.213,1.214,1.215,1.216,1.217,1.218,1.219,1.22),
Lat=c(-1.314,-1.31,-1.306,-1.302,-1.298,-1.294,-1.29,-1.286,-1.282,-1.278),
Long.t=c(1,1,1,2,3,2,3,4,3,4),
Lat.t=c(0,0,0,0,0,0,0,0,0,0),
Pf=c(24,NA,12,6,NA,4,10,NA,NA,16),
Ex=c(60,NA,10,56,NA,16,18,NA,NA,32),
site=c(1,2,3,4,5,6,7,8,9,10),
time=c(1,1,1,2,3,2,3,4,3,4),
Long0=c(1.101,1.102,1.103,1.104,1.105,1.106,1.107,1.108,1.109,1.11),
Lat0=c(-1.304,-1.3,-1.296,-1.292,-1.288,-1.284,-1.28,-1.276,-1.272,-1.268),
Long.t0=c(1,1,1,1,1,1,1,1,1,1),
Lat.t0=c(0,0,0,0,0,0,0,0,0,0))
-------------------------------------------------------------------
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
|