There is a typo in the code for moran.test. It should read: a <- moran.test(NMmap$att.data$y,NMlistw,randomisation=FALSE,zero.policy=TRUE, alternative="two.sided",rank=FALSE)