Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

Moran’s I: Formula, Meaning and Worked Example

Moran’s I measures spatial autocorrelation. See the formula, a hand-computed example, how to read I against its expected value, and Excel, R and Python code.

Written and maintained by CASRAI Editorial Board

Last updated

Moran’s I is the most widely used global measure of spatial autocorrelation: a single statistic that tells you whether similar values of a variable sit near each other (positive), dissimilar values sit near each other (negative), or the pattern is indistinguishable from spatial randomness. This guide gives the formula with every symbol defined, a six-unit example computed by hand, a reading table, the mistakes that most often invalidate a result, an APA reporting pattern, and short Excel, R and Python snippets. It sits inside the wider spatial data analysis workflow.

What is Moran’s I? (meaning)

Moran’s I compares each location’s deviation from the overall mean with the deviations of its neighbours. When above-average values tend to be next to above-average values (and below-average next to below-average), the statistic is positive; when high values tend to sit next to low values, it is negative. Esri’s ArcGIS Pro documentation describes the Global Moran’s I tool as evaluating whether the pattern expressed is clustered, dispersed, or random, and says the index value cannot be interpreted directly: it is read against the null hypothesis of complete spatial randomness, using a z-score and p-value.

Moran’s I formula

As given in the Esri ArcGIS Pro tool reference (read 2026-11-07):

I = (n / S0) × [ Σi Σj wij zi zj ] / [ Σi zi² ]

  • n: the number of features (locations).
  • xi: the value of the variable at location i; zi = xi − x̄, its deviation from the mean.
  • wij: the spatial weight between locations i and j (zero for non-neighbours and for i = j).
  • S0: the sum of all the weights, Σi Σj wij.

The expected value under the null hypothesis is E[I] = −1 / (n − 1), and the z-score is z = (I − E[I]) / √V[I], where V[I] = E[I²] − (E[I])². Because E[I] is slightly below zero rather than exactly zero, a value of I near 0 is “no autocorrelation” only for large n. With row-standardised weights the statistic is bounded between −1 and +1 (Esri).

Worked example with the arithmetic shown

Six areas lie along a line, and each is a neighbour of the area(s) directly next to it (binary contiguity). The values are x = 2, 4, 5, 9, 10, 12. This is a teaching-sized example; real analyses need far more features (see assumptions).

  1. Mean: (2 + 4 + 5 + 9 + 10 + 12) / 6 = 42 / 6 = 7.
  2. Deviations zi: −5, −3, −2, 2, 3, 5.
  3. Denominator Σ zi²: 25 + 9 + 4 + 4 + 9 + 25 = 76.
  4. Weights: five neighbouring pairs, each counted in both directions, so S0 = 10.
  5. Numerator Σi Σj wij zi zj: each pair contributes its product twice. The pair products are (−5)(−3) = 15, (−3)(−2) = 6, (−2)(2) = −4, (2)(3) = 6, (3)(5) = 15; their sum is 38, doubled to 76.
  6. I = (6 / 10) × 76 / 76 = 0.600.
  7. Expected value: E[I] = −1 / (6 − 1) = −0.200.

I is well above E[I]: low values neighbour low values and high neighbour high. With only six units, significance should come from a permutation test rather than from the large-sample z-score. If the same data are row-standardised (each row of weights sums to 1, so S0 = 6), the numerator becomes 53 and I = 53 / 76 = 0.697. The same data give different I values under different weighting schemes, which is why the weights must always be reported.

Interpreting Moran’s I (reading guide)

Result Reading
I significantly above E[I] (positive z-score, small p) Clustering: similar values are spatially close (Esri)
I significantly below E[I] (negative z-score, small p) Dispersion: dissimilar values are spatially close (Esri)
I close to E[I], p not small Cannot reject complete spatial randomness
A value such as 0.6 or −0.4 on its own Not interpretable without the null hypothesis, n and the weights (Esri: index values cannot be interpreted directly)

Moran’s I is also the slope of the line fitted in a Moran scatterplot of the standardised variable against its spatially lagged value (Rey, Arribas-Bel and Wolf, Geographic Data Science with Python, chapter 6).

Global vs local Moran’s I (LISA)

Global Moran’s I returns one number for the whole study area, so it can hide pockets of clustering in one region cancelled by dispersion in another. Esri notes the global statistic can miss such local patterns. Local Indicators of Spatial Association (LISA) decompose the statistic into one value per location so you can map where clusters occur; the same Python text covers this in its chapter on local spatial autocorrelation, and Esri points to hot spot analysis (Getis-Ord Gi*) for the same local question. Treat the global result as a screening step and the local result as the map.

Assumptions and common mistakes

  • Weights define the answer. Queen contiguity, k nearest neighbours and distance bands give different neighbourhoods and different I values. Choose the definition from the process you study, state it, and check that conclusions survive a reasonable alternative.
  • Row-standardise polygon weights. Esri recommends row standardisation with polygon data, which also gives the −1 to +1 bound.
  • Enough features. Esri advises at least 30 features; every feature should have at least one neighbour, and no feature should neighbour all the others. With skewed data, Esri suggests around eight neighbours each.
  • Do not compare z-scores or p-values across study areas. Esri cautions they are not comparable between differently sized or shaped areas.
  • Asymmetric weights. With k-nearest-neighbour weights, the R spdep documentation advises symmetrising the list (listw2U) before using moran.test.
  • Variance assumption. spdep’s moran.test uses the randomisation variance by default; randomisation=FALSE gives the normality-assumption variance. Say which you used.

How to report Moran’s I (APA style)

Report the statistic, its expected value, the test statistic, the p-value, the weights definition and n. Example format with illustrative numbers: Global Moran’s I indicated significant positive spatial autocorrelation in district crime rates, I = 0.51, E[I] = −0.02, z = 5.63, p < .001 (queen contiguity, row-standardised weights, n = 49). For permutation-based p-values, state the number of permutations. Report the software and package version, and pair the statistic with a map of local results where possible, as with any effect size or interval estimate.

How to calculate Moran’s I in Excel, R or Python

Excel

Put the values in A2:A7 and a 6×6 weight matrix in C2:H7. In one cell (array-aware in current Excel):

=ROWS(A2:A7)/SUM(C2:H7) * SUMPRODUCT(MMULT(C2:H7, A2:A7-AVERAGE(A2:A7)), A2:A7-AVERAGE(A2:A7)) / DEVSQ(A2:A7)

With the binary line-neighbour matrix above this returns 0.6.

R

For real data use spdep: build neighbours, convert with nb2listw(nb, style="W"), then moran.test(x, listw), which returns the statistic, p-value, I, expectation and variance. A package-free check of the worked example:

x <- c(2,4,5,9,10,12); n <- 6
W <- matrix(0, n, n); for (i in 1:(n-1)) W[i,i+1] <- W[i+1,i] <- 1
z <- x - mean(x)
(n/sum(W)) * sum(W * outer(z, z)) / sum(z^2)   # 0.6

Python

The PySAL stack used in Geographic Data Science with Python is esda.moran.Moran(y, w) with weights from libpysal (for example weights.KNN.from_dataframe(df, k=8) then w.transform = "R"); the object exposes .I and a permutation .p_sim (999 permutations by default, so the smallest reportable value is 0.001). A numpy check of the worked example:

import numpy as np
x = np.array([2,4,5,9,10,12.]); n = len(x)
W = np.zeros((n, n))
for i in range(n-1): W[i, i+1] = W[i+1, i] = 1
z = x - x.mean()
print(n / W.sum() * (W * np.outer(z, z)).sum() / (z**2).sum())  # 0.6

FAQ

What does Moran’s I mean in plain terms?

It measures how strongly nearby locations resemble each other on one variable. Positive means neighbours are alike, negative means neighbours differ, and values near the expected −1/(n−1) mean no detectable spatial pattern.

What is a good Moran’s I value?

There is no good or bad value. Significance depends on the z-score or permutation p-value against complete spatial randomness, with n and the weights stated.

What is the difference between global and local Moran’s I?

Global gives one statistic for the whole area; local (LISA) gives one value per location to show where clustering occurs.

Can Moran’s I be greater than 1?

With row-standardised weights it lies between −1 and +1 (Esri); with other weightings the range can differ, so standardise the weights and report them.

Does Moran’s I work with fewer than 30 locations?

It can be computed, as in the example above, but Esri advises at least 30 features; use permutation tests and caution below that.

Sources

  • Esri, ArcGIS Pro documentation, “How Spatial Autocorrelation (Global Moran’s I) works”: doc.esri.com (read 2026-11-07).
  • R spdep package, moran.test reference: r-spatial.github.io/spdep (read 2026-11-07).
  • Rey, S., Arribas-Bel, D. and Wolf, L., Geographic Data Science with Python, chapter 6, Spatial Autocorrelation: geographicdata.science (read 2026-11-07).

Related: spatial data analysis, sampling methods, what is a p-value.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Moran’s I: Formula, Meaning and Worked Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →