Thanks for the various options. I have tried using the CARBayes package however several of the functions (for example the .bymGAR function) were giving me this error:
Error in chol2inv(chol(Q.current)) : error in evaluating the argument 'x' in selecting a method for function 'chol2inv': Error in chol.default(Q.current) : the leading minor of order 8 is not positive definite Thanks for the other options I will look into them. James ________________________________________ From: Roger Bivand [roger.biv...@nhh.no] Sent: 10 July 2013 10:25 To: James Rooney; r-sig-geo@r-project.org Subject: SV: R2WinBugs - getting TRAP errors in Winbugs It is possible that N is large for this approach, but you have options using the CARBayes package and the BayesX interface in R, and INLA at www.r-inla.org. Code samples in ch. 10 in the 2nd edition of the book you refer to, ch. 10, on www.asdar-book.org. If there are spatially patterned omitted covariates, going through Bayesian inference may be serious overkill, unless you really need the N marginals on the spatially structured random effects rather than just the point smooth values in your Poisson regession; does glm() or some GLMM get you there with less trouble? Might the hglm package help? Hope this helps, Roger -- Roger Bivand NHH Norwegian School of Economics Helleveien 30, 5045 Bergen, Norway roger.biv...@nhh.no ________________________________________ Fra: r-sig-geo-boun...@r-project.org [r-sig-geo-boun...@r-project.org] på vegne av James Rooney [roone...@tcd.ie] Sendt: 9. juli 2013 11:46 Til: r-sig-geo@r-project.org Emne: [R-sig-Geo] R2WinBugs - getting TRAP errors in Winbugs 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 _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo