Hi all, I am trying to implement the WinBUGS spatial conditional autoregression model on page 11.11 of Applied Spatial Data Analysis in R. I have about 3300 polygons with about 17,000 adjacencies in the set. I have changed the model only by removing the beta term as, for now, I don't have any variables to include - I want simply to do a spatially smoothed model with no covariates.
Anyhow the code runs fine under R - but I am constantly getting a Trap Error in Winbugs - Index out of range. My BUGs code looks like this: model { for(i in 1:N) { observed[i]~dpois(mu[i]) log(theta[i])<-alpha + u[i] + v[i] mu[i]<-expected[i]*theta[i] u[i] ~dnorm(0,precu) } v[1:N]~car.normal(adj[],weights[],num[],precv) alpha ~dflat() precu ~dgamma (0.001, 0.001) precv ~dgamma (0.001, 0.001) } and my R code like this - (I've deliberately kept the iterations low in trying to figure out the problem but I get the error even within 1000 iterations). nb<-poly2nb(EDdata2,queen=T) nb.w<-nb2listw(nb,zero.policy=T,style="B") nbBugs<-listw2WB(nb.w) BugsDir<-"C:/Program Files/WinBUGS14/" N<-length(EDdata2$nm_tt_c) d<-list(N = N, observed =EDdata2$nm_tt_c, expected = EDdata2$tot_exp, adj=nbBugs$adj, weights=nbBugs$weights, num=nbBugs$num) inits<-list(list(u=rep(0,N),v=rep(0,N),alpha=0,precu=0.001,precv=0.001)) MCMCres<-bugs(data=d,inits=inits,bugs.directory=BugsDir,parameters.to.save=c("theta","alpha"),n.chains=1,n.iter=1000,n.burnin=500,n.thin=1, model.file="ALS_spatial_CAR.txt") I don't know if WinBUGS falls under the remit here ?? But was hoping someone might have some idea whats causing my TRAP errors as I am at a loss. Many thanks all, James _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo