Dear Crowd
Problem
I tried to calculate the spatial correlogram with the packages nfc, pgirmess, SpatialPack and spdep. However, it was difficult for me to determine the beginning and end of the distance. I'm only interested in spatial autocorrelation at smaller distances, but at smaller cells. In addition, since the raster is quite large (1.8 megapixels), I run into memory problems with these packages, but with SpatialPack.
So I tried to create my own code using the Moran function from the raster package. But I should have some error, since the result for the full data set is slightly different from the result from other packages. If there is no error in my code, this may at least help others with similar problems.
Question
I'm not sure if my focal matrix is ββwrong. Could you tell me if a central pixel is needed? Using testdata, I cannot show the differences between the methods, but there are differences on my complete dataset, as shown in the figure below. However, the bunkers are not exactly the same (50 m versus 69 m), so this may explain some of the differences. However, in the first box, this explanation seems implausible to me. Or maybe the irregular shape of my raster and different ways of processing NA cause a difference?
Comparing your own method with one of SpatialPack
Runable example
Testdata STRONG>
The code for calculating test data is taken from http://www.petrkeil.com/?p=1050#comment-416317
# packages used for the data generation library(raster) library(vegan)
Native code
library(raster) sp.Corr <- matrix(nrow = 0,ncol = 2) formerBreak <- 0
Other methods for calculating spatial correlogram
library(SpatialPack) sp.Corr <- summary(modified.ttest(z.value,z.value,coords = xy,nclass = 21)) plot(x=sp.Corr$coef[,1],y = data$coef[,4],type = "l",ylab = "Moran I",xlab="Upper bound of distance") library(ncf) ncf.cor <- correlog(x.coord, y.coord, z.value,increment=10, resamp=1) plot(ncf.cor)