Dear List,

I have a question about simulation code. Here are the code and error
message.

> 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 it means that there are some observations without neighborhoods from
random selection process. Is there any way to proceed simulation like using
only ones with neighborhood sets?

Any suggestion will be appreciated!!

Thank you!

Steve Hong

	[[alternative HTML version deleted]]

