Dear List, I have some problem with my simulation code. Here is output from R: > sim.sp <- function(data,CM,n,N) + { + C <- matrix(rep(NA,N),ncol=1) + for(i in 1:N) + { + j <- n + xx <- which(colSums(CM[j,])==1) + V <- names(xx) + V <- paste(V, collapse="+") + V <- paste("SBA~", V) + rd <- round(nrow(data)*(2/3)) + d <- sample(seq(1:nrow(data)),rd) + dat1 <- data[d,] + dat2 <- data[-d,] + crd <- cbind(dat1$Longitude,dat1$Latitude) + dist80 <- dnearneigh(crd,0,100,longlat=F) + dist80sw <- nb2listw(dist80, style="B") + fm <- errorsarlm(as.formula(V), data=dat1, listw=dist60sw) + pred <- predict(fm,dat2) + C[i,1] <- cor(dat2$SBA,pred) + out <- cbind(C) + } + colMeans(out) + } > > sim.sp(df2007.5k.s2,CM,1,1000) Error in nb2listw(dist80, style = "B") : Empty neighbour sets found
I guess I got error message since there are some observations without neighborhoods in the process of determining neighborhood structure randomly. Is there any way to ignore neighborhood structures with observations without neighborhoods and proceed the code? Thank you in advance!! Steve Hong [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.