I'm trying to run a spatial autocorrelation (SAC) on light values across a sampling area. I did some searching, and I've found that Moran's I (in the ape package) is a common tool used in R to do SAC. However, I ran the code and I'm not entirely sure if R is doing what I want. The code doesn't break, but I've input my variable (transformed light values) using the Moran.I function:
Moran.I (ovenbird$ARCSINE.SQRT.TRAN, ld.dist.mat)
My distance matrix (ld.dist.mat) is a matrix of distances between all points (A-O) on my grid. It looks like this:
A B C D E F G H I J K L M N O
A 0.00 5.00 10.00 2.50 5.59 10.31 5.00 7.07 11.18 7.50 9.01 12.50 10.00 11.18 14.14
B 5.00 0.00 5.00 5.59 2.50 5.59 11.18 5.00 11.18 9.01 7.50 9.01 11.18 10.00 11.18
C 10.00 5.00 0.00 10.31 5.59 2.50 11.18 7.07 5.00 12.50 9.01 7.50 14.14 11.18 10.00
D 2.50 5.59 10.31 0.00 5.00 10.00 2.50 5.59 10.31 5.00 7.07 11.18 7.50 9.01 12.50
E 5.59 2.50 5.59 5.00 0.00 5.00 5.59 2.50 5.59 11.18 5.00 11.18 9.01 7.50 9.01
F 10.31 5.59 2.50 10.00 5.00 0.00 10.31 5.59 2.50 11.18 7.07 5.00 12.50 11.18 7.50
G 5.00 11.18 11.18 2.50 5.59 10.31 0.00 5.00 10.00 2.50 5.59 10.31 5.00 7.07 11.18
H 7.07 5.00 7.07 5.59 2.50 5.59 5.00 0.00 5.00 5.59 2.50 5.59 11.18 5.00 11.18
I 11.18 11.18 5.00 10.31 5.59 2.50 10.00 5.00 0.00 10.31 5.59 2.50 11.18 7.07 5.00
J 7.50 9.01 12.50 5.00 11.18 11.18 2.50 5.59 10.31 0.00 5.00 10.00 2.50 5.59 10.31
K 9.01 7.50 9.01 7.07 5.00 7.07 5.59 2.50 5.59 5.00 0.00 5.00 5.59 2.50 5.59
L 12.50 9.01 7.50 11.18 11.18 5.00 10.31 5.59 2.50 10.00 5.00 0.00 10.31 5.59 2.50
M 10.00 11.18 14.14 7.50 9.01 12.50 5.00 11.18 11.18 2.50 5.59 10.31 0.00 5.00 10.00
N 11.18 10.00 11.18 9.01 7.50 11.18 7.07 5.00 7.07 5.59 2.50 5.59 5.00 0.00 5.00
O 14.14 11.18 10.00 12.50 9.01 7.50 11.18 11.18 5.00 10.31 5.59 2.50 10.00 5.00 0.00
My question is how does R know which points on my grid are associated with each light value? I have tried print(Moran.I) to figure this out, but I have only been programming since fall of last year (2012) and I am not well versed enough in R to know how to interpret the function. Also, if R isn't identifying my light values in the right way, how do I fix that?
Any help would be greatly appreciated.
You can do the following to get the global and local measures of spatial autocorrelation using Moran's measure using the code below:
library(raster)
r <- raster(nrows=10, ncols=10)
r[] <- 1:ncell(r)
Moran(r) #this is the global index of autocorrelation
x1 <- MoranLocal(r) #local measure of autocorr as a raster object that can be plotted
plot(x1) #this will plot the autocorrelation raster results
For Geary's autocorr measure:
Geary(r) #this is the global index of autocorrelation
x1 <- GearyLocal(r) #local measure
plot(x1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With