I have a sample of data taken from regions of a country! i want to test if there are any spatial autocorrelation on my data using Moran Indice test. the null hypothesis: is that there is no spatial autocorrelation here a sample of my data:

sample data for my variable with locations coordinates

i used this steps to calculate it on r:

 channel <- odbcConnectExcel('moran.xls')
 data <- sqlFetch(channel, 'wilaya')
 inf.dists <- as.matrix(dist(cbind(lon=data$Lon, lat=data$Lat)))
 inf.dists.inv <- 1/inf.dists
 diag(inf.dists.inv) <- 0
 Moran.I(data$year2009, inf.dists.inv)

and i got these results:





the $observed ~= $expected and they are negative! does that mean there is a little dispersion! but we cannot reject the null hypothesis, so there is no spatial autocoorelation between the regions!

the problem is that i'm not sure about my interpretation ? and i want to know if the method i used for calculating the weight matrix for moran.I function is right?

  • 1
    Instead of posting a screen shot of the excel spreadsheet, you should just include it in text using the code formatting tools. Here one could reproduce your example alot easier if you took that step.
    – Andy W
    Jun 2, 2014 at 12:14
  • Yes that's a good idea, i will try to use it the next time
    – user30353
    Jun 4, 2014 at 9:07

2 Answers 2


The expected value of Moran's I is -1/(N-1), which for your sample of 38 cases equals -1/(38-1) = -0.02702703. This is what the software spit out, so that is a good start! So this means that there is really no evidence of negative auto-correlation here, as with random data you would expect it to be a negative value more often than positive.

You interpret the hypothesis test the same way you do any others. That is, you fail to reject the null hypothesis that there is no spatial auto-correlation in the values of year2009 for this sample.

Your spatial weights matrix code looks fine to me to estimate an inverse distance matrix. The biggest thing to look out for when using inverse distances are very short distances, which can make the weights explode. Spatial weights are often arbitrary though, so it is often domain knowledge that helps you choose whether to use inverse distance, or contiguity, or nearest neighbor, etc. type of a spatial weights matrix. So it appears the code to estimate the inverse distance weighted matrix is fine, but I can't say if it is the correct type of spatial weights matrix to use for your situation.

  • "negative auto-correlation" - ?!
    – Mox
    Dec 27, 2014 at 5:27
  • Spatial autocorrelation can be positive or negative or absent/neutral. See e.g. thewinnower.com/papers/… Nov 3, 2015 at 1:26
  • Thanks, this interesting and useful post. In case of a p value being 0 and the observed value bing approximately 0.08 and the expected value being approximately -0.00015 I would reject the null hypothesis, is that correct? Also, what is the formal way of reporting Moran's I?
    – Konrad
    Mar 10, 2016 at 14:55
  • 1
    It depend's on what the standard error of the test statistic is @Konrad. But yes you interpret it like any other hypothesis test. I'm not quite sure what is a "formal" way of reporting it. Stating the observed test statistic, the standard error, and the null in a sentence like you just did is fine.
    – Andy W
    Mar 10, 2016 at 20:45
  • Oh I see you said the p-value is 0 - yes in that case you would reject the null that there is no spatial auto-correlation.
    – Andy W
    Mar 10, 2016 at 21:07

Spatial analysis in general should not use lat/long when spatial weights are calculated (i.e., planar coordinates, distortion, etc.). Always use projection based coordinates. Make sure your units are in the correct datum, not WGS84, or even undefined. This will affect the distance decay function (i.e., inf.dists.inv <- 1/inf.dists). Also, use other R libraries for Morans I(if not called in Ape) for comparison, (e.g., spdep).

  • 1
    One should be looking at the simulated distribution and not interpreting a single realization of the statistic! I see no notable effect in the Wij matrix, based on geographic great circle distance, if the neighbors are contingency based. Jun 8, 2018 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.