How this calculation works
Enter one measurement for each location and a square weight matrix in exactly the same location order. A row identifies the location receiving a spatial lag; a column identifies the contributing neighbor. An accidental reorder changes the scientific question even when the matrix dimensions still match. Keep your location identifier list outside the numeric fields.
I=(n/S0)(zᵀWz)/(zᵀz); z=x−mean(x); E0[I]=−1/(n−1). Monte Carlo p=(1+extreme)/(B+1).A worked example
Eight ring locations with values 1,2,3,4,8,7,6,5 and row-standardized adjacent weights give I=23/42≈0.547619048.
Good to know
8–120 locations, finite nonconstant values, nonnegative zero-diagonal supplied weights with every row positive; explicit raw or row-standardized weights. Seeded 999–9999 label permutations, product n*n*B capped at 20 million. Greater, less or absolute centered-at-null two-sided statistic selected in advance; no local LISA, coordinate geocoding or spatial regression.
Reference: spdep — moran.mc (opens in a new tab) ↗
Start with locations and a defensible neighbor graph
Enter one measurement for each location and a square weight matrix in exactly the same location order. A row identifies the location receiving a spatial lag; a column identifies the contributing neighbor. An accidental reorder changes the scientific question even when the matrix dimensions still match. Keep your location identifier list outside the numeric fields.
Weights describe which pairs matter before the outcomes are inspected. Binary adjacency, inverse separation, or another nonnegative neighborhood definition can lead to different answers. This page accepts the supplied graph; it cannot discover whether administrative borders, travel time, or straight-line distance represents the mechanism behind your measurements. Record that choice with the result.
Compare this with the Empirical directional variogram calculator from spatial coordinates and values. Tests global alignment between centered values and their supplied spatial lag. Existing variogram only bins squared increments and has no spatial-weight null randomization.
What global Moran I measures
Subtract the overall mean from every value to obtain z. Moran I equals n divided by the sum of all weights, multiplied by z transpose W z divided by z transpose z. Neighbor pairs with deviations of the same sign contribute positively; pairs straddling the mean contribute negatively. Constant measurements have no denominator and no defined statistic.
Global I summarizes the entire graph. A positive value can arise from several separate clusters or one dominant region, and opposite patterns can cancel. It does not identify a particular hotspot or explain why similarity occurs. Under unrestricted random relabeling of nonconstant values with zero diagonal weights, the randomization expectation is minus one divided by n minus one.
Choose weights and a tail before testing
Raw weights retain the entered relative row totals. Row standardization divides every positive row by its own sum, giving each location a neighbor average and making the total weight n. This transformation can make a symmetric adjacency matrix asymmetric. It is a convention with consequences, rather than a cosmetic output option; report it alongside I.
For a positive-association question count permuted statistics at least as large as observed. A negative-association question reverses that comparison. The two-sided option compares absolute distances from the randomization mean, not from zero. Choose the alternative before viewing the outcomes. The Monte Carlo probability uses the observed arrangement plus the sampled permutations, preventing a reported p of zero.
Eight locations around a ring
The prefilled measurements are 1, 2, 3, 4, 8, 7, 6, and 5. Each ring vertex connects to its immediate predecessor and successor, including the connection between the eighth and first locations. Row standardization gives each neighbor weight one half. The mean is 4.5 and the sum of squared centered values is 42.
For these inputs the centered cross-product with the standardized spatial lag is 23, so I is 23 divided by 42, approximately 0.547619. Enumerating all 40,320 label permutations gives an upper-tail proportion near 0.0150794. The browser's seeded sample estimates that randomization distribution; its 999-permutation p need not equal the exhaustive reference or a different program's sampled p.
Read the spatial-lag illustration
The diagram pairs a ring graph with a value-versus-spatial-lag view. A rising relationship means above-average values tend to receive positive neighbor deviations and below-average values tend to receive negative ones. Labels refer to the same vertices on both views. Neither the angle of the drawing nor the physical spacing of its nodes defines an additional weight.
A Moran scatterplot depends on the chosen normalization. With standardized rows and common centered scaling, its regression slope equals I. With arbitrary raw weights the slope must be adjusted by n over total weight. Keep this distinction when comparing a plotted slope to a printed statistic, especially when the graph has substantially unequal degrees across locations.
Exchangeability is the essential limitation
Randomization moves values among the fixed locations while preserving the observed collection of measurements and the entered weights. This null requires exchangeability. Repeated observations from the same site, a strong unmodeled trend, unequal measurement precision, or a stratified sampling design can invalidate unrestricted relabeling even when a matrix passes every numeric check. A small p is conditional on that null.
The tool requires 8 to 120 locations, a zero diagonal, nonnegative finite weights, and a positive weight total in every row. Isolated locations must be addressed scientifically before analysis. Work is limited by n squared times the permutation count, capped at twenty million. Increasing permutations improves Monte Carlo resolution; it does not repair an unsuitable graph or a violated sampling assumption.
Use the result for a focused spatial question
Compare this page with an empirical variogram when selecting a tool. A variogram bins squared value differences by separation and helps describe scale or direction. Moran I instead evaluates agreement with a specified weight network and supplies a label-randomization reference. A spatially patterned variogram does not imply the same null hypothesis or the same evidence as this test.
For a reproducible report retain the complete weight matrix, observation order, normalization, alternative, seed, number of permutations, I, and p. Interpret a non-significant result as limited evidence under this analysis, rather than proof of spatial randomness. When spatial inference matters, investigate residual trends and the study design before treating the global test as a final model assessment.
A few questions, answered
Can I enter latitude and longitude instead of weights?
No. Supply the spatial weight matrix in observation order; this page does not geocode locations or construct geographic distances.
Why is the null mean negative?
For nonconstant values randomly assigned to a zero-diagonal graph, E(I) is -1/(n-1), which differs from zero in a finite sample.
Does a significant I identify a hotspot?
No. This is a global statistic; location-specific hotspot inference requires a separate local method.
Will increasing permutations change I?
No. I is fixed by the values and weights. More permutations refine the estimated randomization tail.