Why Diagnose Spatial Autocorrelation?
Observations attached to nearby places may be more alike than observations attached to distant places. A map of unusually high and low outcomes can therefore contain structure that is not summarized by the overall mean or variance. Global Moran’s I is a measure of whether values at locations connected by a specified spatial weights matrix tend to be similar or dissimilar.
The statistic is a diagnostic, not a model of how spatial dependence arises. Its value depends on the weights matrix: changing which locations count as neighbors, or how their connections are scaled, can change the result. A useful analysis therefore states the matrix and its normalization, reports the statistic and reference distribution, and interprets the result as evidence about spatial pattern under that particular specification.
Definition and Interpretation
Suppose there are \(n\) spatial units, with observed values \(y_1,\ldots,y_n\), and let \(W=(w_{ij})\) be a specified \(n\times n\) spatial weights matrix. The weights describe which pairs of units contribute to the spatial comparison and how much each pair contributes. Assume the diagonal is zero, so a unit is not treated as its own neighbor. Define the centered values \(z_i=y_i-\bar{y}\), the total weight \(S_0=\sum_i\sum_j w_{ij}\), and \(Q=\sum_i z_i^2\).
The numerator is a weighted sum of products for connected pairs. A product \(z_i z_j\) is positive when both values are above their mean or both are below it; it is negative when one is above and the other below. Thus, with nonnegative weights, a relatively large positive \(I\) indicates that connected units tend to have values on the same side of the mean. A relatively small, negative \(I\) indicates a tendency toward neighboring dissimilarity. The statistic is not generally restricted to the interval \([-1,1]\), and the sign alone is not a significance test.
The scale of the weights matters through \(S_0\), and the pattern of weights matters through \(z'Wz\). Multiplying every weight by the same positive constant leaves \(I\) unchanged, because both \(z'Wz\) and \(S_0\) are multiplied by that constant. Changing the relative weights or neighbor pattern need not leave it unchanged. In particular, results computed with different normalization conventions should not be treated as if they used the same spatial comparison.
Worked Example: Calculating Moran’s I on a Four-Unit Line
Consider four hypothetical locations arranged in a line, with unit 1 adjacent to 2, unit 2 adjacent to 1 and 3, unit 3 adjacent to 2 and 4, and unit 4 adjacent to 3. Use binary, symmetric weights: \(w_{ij}=1\) for adjacent locations and 0 otherwise. Suppose the values are \(y=(1,2,4,3)\).
The mean is \(\bar{y}=(1+2+4+3)/4=2.5\), so \(z=(-1.5,-0.5,1.5,0.5)\). The sum of squared centered values is \(Q=(-1.5)^2+(-0.5)^2+(1.5)^2+(0.5)^2=5\). There are six directed nonzero weights, so \(S_0=6\). Because the matrix is symmetric, each of the three adjacent-pair products appears twice in \(z'Wz\):
Therefore,
For this line-shaped weights matrix, the weighted products sum to a positive value. This describes a positive pattern in the observed values relative to their mean; by itself, \(I=0.200\) does not establish that the pattern is unusual under a specified null distribution.
Randomization Expectation
A common reference null keeps the observed values fixed but assigns them to spatial units at random. The weights matrix remains fixed. This is a randomization null: conditional on the observed values, each assignment of those values to locations is treated as equally likely. It is distinct from a claim that the values were generated by a particular spatial model.
Under this null, for two distinct locations \(i\ne j\), the expected product of the randomly assigned centered values is \(-Q/[n(n-1)]\). To see this, each ordered pair of distinct locations receives a uniformly selected ordered pair of distinct values. Summing the products over all such ordered value pairs gives \(\sum_{a\ne b}z_a z_b=(\sum_a z_a)^2-\sum_a z_a^2=-Q\), since the centered values sum to zero. There are \(n(n-1)\) such pairs, giving the stated expectation. The condition \(w_{ii}=0\) ensures that only distinct locations enter the weighted sum.
Indeed, linearity of expectation gives \(E[z'Wz]=-\frac{Q}{n(n-1)}S_0\). In Moran’s I, \(Q\), \(S_0\), and \(n\) are fixed across these assignments. Substituting the expected numerator therefore yields
The requirement \(Q>0\) is essential: when all observations are equal, the denominator is zero and Moran’s I does not exist. The expectation is a benchmark, not a universal cutoff. For example, with \(n=4\), the randomization expectation is \(-1/3\), not zero. To decide whether an observed value is unusual, use the reference distribution, not just a comparison with zero or with the expectation.
Permutation Reference Distributions
A permutation reference distribution is formed by repeatedly reallocating the observed values across the fixed locations, recalculating \(I\) after each reallocation, and comparing the observed statistic with the resulting distribution. If all \(n!\) assignments are enumerated, this gives the exact randomization distribution under the stated null. For larger problems, a Monte Carlo sample of \(B\) random assignments approximates it.
For a positive-association alternative, a one-sided permutation p-value counts assignments with Moran’s I at least as large as the observed value. For a two-sided assessment, a clear convention is to count values at least as far from the randomization expectation as the observed value. With \(B\) simulated assignments, the plus-one estimate for this two-sided p-value is
Here \(I_b\) is the statistic for permutation \(b\), and \(\mathbf{1}\{\cdot\}\) equals 1 when its condition holds and 0 otherwise. The plus-one convention includes the observed arrangement in the Monte Carlo comparison and avoids reporting a zero p-value merely because no sampled permutation was as extreme. The p-value measures extremeness under this randomization reference; it is not the probability that the null is true.
Worked Example: Interpreting a Permutation Result
Return to the hypothetical four-location line, for which \(n=4\), \(E[I]=-1/3\), and \(I_{\mathrm{obs}}=0.200\). Suppose a Monte Carlo reference calculation uses \(B=999\) random assignments of the four observed values and finds that 107 simulated statistics are at least as far from \(-1/3\) as \(0.200\) is.
The observed distance from the randomization expectation is \(|0.200-(-1/3)|=0.5333\). Applying the stated two-sided convention gives
At a 5% significance level, this Monte Carlo result does not provide sufficient evidence against the randomization null using this two-sided criterion. It does not show that the values are spatially independent in every sense; it says that the observed statistic is not especially extreme relative to the specified permutation reference distribution at that threshold. The calculation is conditional on the four observed values and the chosen line weights matrix.
Moran’s I as a Residual Diagnostic
Moran’s I can be applied to residuals from a fitted regression to check whether unexplained variation displays spatial pattern. Begin with the regression specification, for example \(y=X\beta+u\), and fit it to the spatial units. Let \(\hat{e}_i\) denote the fitted residual for unit \(i\). Compute Moran’s I using these residuals in place of \(y_i\), centering them as required. When the fitted regression includes an intercept, the OLS residuals sum to zero, so their mean is zero; the denominator must still be positive for the statistic to be defined.
A residual statistic indicating spatial pattern can flag that the fitted model leaves geographically structured variation unexplained. It does not identify the source of that pattern, prove that a particular spatial mechanism is operating, or establish that the regression coefficients are biased. Interpretation depends on the regression specification, the weights matrix, and how the reference distribution is obtained.
A simple permutation of estimated residuals is not automatically an exact test: OLS residuals are constrained by the fitted design matrix and can have different variances across observations. The randomization result above applies to fixed values randomly assigned to locations; it does not, on its own, establish that estimated regression residuals are exchangeable. For formal inference, the calibration must respect the null regression and its design. A residual Moran statistic can still be reported as a diagnostic, with its reference method and assumptions made explicit.
Worked Example: Computing a Residual Diagnostic
Suppose four hypothetical locations lie in a line with the same binary adjacency weights as before. At each location, an OLS regression with an intercept is fitted using a covariate \(x=(-1,-1,1,1)\). The outcomes are \(y=(9,7,11,13)\). The fitted line is \(\hat{y}=10+2x\), giving fitted values \((8,8,12,12)\) and residuals \(\hat{e}=(1,-1,-1,1)\).
These residuals sum to zero, and they are orthogonal to the covariate: \(1-1-1+1=0\) and \((-1)(1)+(-1)(-1)+(1)(-1)+(1)(1)=0\). Their squared sum is \(Q_e=1+1+1+1=4\). The weights have \(S_0=6\). The three adjacent-pair products are \(-1,1,-1\), each counted twice, so \(\hat{e}'W\hat{e}=2(-1+1-1)=-2\). Thus the residual Moran statistic is
The value describes a negative weighted pattern in these four residuals for this line matrix. It is not, by itself, a valid significance conclusion: a reference distribution for estimated residuals must account for the regression fit. In this example, the calculation is a diagnostic summary, not a claim that the residuals follow the simple randomization null.
Common Pitfalls and Practical Reporting
A frequent error is to interpret a positive Moran’s I as proof of spatial dependence or as a causal effect of neighboring outcomes. The correction is to treat the statistic as a weighted summary and assess its extremeness against a clearly stated reference distribution. A significant result can be consistent with several explanations, including omitted spatially patterned variables; Moran’s I alone does not distinguish among them.
Another error is to quote \(E[I]=-1/(n-1)\) without checking that the statistic exists. The expectation result requires \(w_{ii}=0\), \(S_0>0\), and \(Q>0\). If all values are equal, then \(Q=0\), and the numerator-to-denominator ratio is undefined. Also avoid treating \(I=0\) as the randomization expectation: for finite \(n\), that expectation is negative.
A useful report states the outcome or residuals analyzed, the weights matrix and normalization, the observed Moran statistic, the reference distribution and its assumptions, the tail convention, and the p-value. If the analysis is based on residuals, say how the fitted model affects the calibration. These details make clear what spatial comparison was tested and what the result can—and cannot—support.
Check Your Understanding
Answer each question using the definitions and conditions stated above.
- What do \(S_0\) and \(Q\) represent in global Moran’s I, and what happens if \(Q=0\)?
- For \(n=10\), what is the randomization expectation of Moran’s I when the statistic is defined and the weights have a zero diagonal?
- Why can a positive Moran’s I indicate clustering of similar values without establishing that the clustering is statistically unusual?
- In a two-sided permutation assessment, why compare the observed statistic’s distance from \(E[I]\), rather than automatically comparing its absolute value with zero?
- Why is a permutation test on fitted OLS residuals not automatically justified by the randomization result for fixed values?