Skip to article frontmatterSkip to article content

Reading route. Follow the polygon-to-graph example, the three main neighbour rules, row standardisation and the worked spatial lag. Check the graph diagnostics before applying a rule. Higher-order neighbourhoods and inverse-distance decay are optional extensions; the Singapore maps illustrate how membership changes.

Neighbours are part of the question

The income maps in Section 6.1 invite us to compare nearby areas. But a shared border, a short straight-line distance and a short journey describe different relationships. A weights specification makes that choice explicit before we calculate spatial association.

After reading, you should be able to translate a neighbour rule into a matrix, distinguish contiguity, distance-band and k-nearest-neighbour weights, calculate a spatial lag, and explain row standardisation and graph diagnostics. We use nonnegative weights and exclude self-neighbours unless a later statistic explicitly states otherwise.

From polygons to a neighbour graph

Rook contiguity connects polygons sharing a boundary segment of positive length. Queen contiguity also permits contact at a point. On a regular square grid these resemble chess moves: an interior cell has four first-order rook neighbours or eight first-order queen neighbours. Queen includes rook contacts; it does not require every neighbour to share both an edge and a corner.

Regular grid comparing rook, diagonal-only bishop and queen neighbours of a central cell.

Figure 1:The chess analogy on a regular grid. Rook selects shared edges; the diagonal-only bishop illustration selects corner contacts; queen includes both. The focal cell is excluded from its own neighbourhood.

Singapore subzone maps comparing rook and queen neighbours of Chong Boon.

Figure 2:Chong Boon, Singapore: the same focal subzone has additional neighbours under queen contiguity because point contacts are included. The highlighted areas show neighbour membership, not income values or statistical significance.

Six labelled synthetic polygons illustrating shared-edge contiguity.

Figure 3:Six synthetic units. Rook neighbours share an edge of non-zero length; point contact alone is insufficient. These are teaching geometries, not Malaysian administrative boundaries.

Six nodes joined by eight undirected shared-edge relationships.

Figure 4:The same units as a graph. Links are 1–2, 1–4, 1–5, 2–4, 2–5, 3–5, 3–6 and 4–5. The graph preserves the selected relationships, not polygon shape or area.

Let aij=1a_{ij}=1 when jj is a selected neighbour of ii, and zero otherwise. With row and column order 1–6,

A=[010110100110000011110010111100001000].A=\begin{bmatrix} 0&1&0&1&1&0\\ 1&0&0&1&1&0\\ 0&0&0&0&1&1\\ 1&1&0&0&1&0\\ 1&1&1&1&0&0\\ 0&0&1&0&0&0 \end{bmatrix}.

The diagonal is zero. The matrix is symmetric because shared-edge contact is mutual. Unit 5 has four neighbours; unit 6 has only one. There are eight undirected links but sixteen nonzero matrix entries: each link appears in both directions. Preserve that convention in later sums over ii and jj.

Go deeper: higher-order neighbourhoods

Higher-order neighbours

Graph distance counts the minimum number of links needed to reach another unit. Exactly second-order neighbours are two links away, excluding first-order neighbours and the focal unit. A cumulative neighbourhood up to order two includes first- and second-order neighbours. State which version is used.

For unit 6, the first-order neighbour is 3 and the exactly second-order neighbour is 5. The cumulative set through order two is therefore {3, 5}. Matrix powers count walks and can include repeated routes and returns to the focal unit; they are not automatically the desired binary higher-order neighbourhood.

Four Singapore maps comparing exactly second-order and cumulative first-plus-second-order rook and queen neighbours of Chong Boon.

Figure 5:Higher-order neighbourhoods around Chong Boon. The upper panels show exactly second order; the lower panels combine first and second order. Compare these different sets before interpreting an order parameter.

Topology is not a display detail

Small gaps, overlaps or generalised coastlines can create missing or spurious contacts. Use geometries suitable for the analysis and inspect the graph. The Peninsular Malaysia income maps use generalised display outlines; those outlines should not be used to infer exact shared-border adjacency. Island units also require an explicit decision: lack of land contact need not imply lack of a meaningful geographical connection.

Distance-based relationships

A binary distance band connects observations whose representative locations are within a threshold d0d_0:

aij=1(0<dij≤d0),i≠j.a_{ij}=\mathbf{1}(0<d_{ij}\leq d_0),\qquad i\ne j.

This expression assumes distinct representative coordinates. Coincident locations require a separate rule, rather than silently excluding a pair because its distance is zero. For polygon data, specify whether distance is between centroids, interior points, population centres or another representation. A geometric centroid may fall outside an irregular polygon and does not necessarily represent where people live.

A fixed distance band has a consistent distance threshold but can produce very different neighbour counts in dense and sparse regions. It may leave some units without neighbours. Straight-line distance also need not represent travel or environmental connectivity across barriers.

Singapore distance-band illustration showing a focal location, its distance threshold and selected neighbouring spatial units.

Figure 6:Fort Canning, Singapore, with a 1,200 m distance band. Membership is based on representative points falling within the displayed threshold; a polygon can be selected without sharing a border with the focal polygon.

Singapore maps comparing distance-band neighbourhoods around Fort Canning and Holland Road at two thresholds.

Figure 7:Fort Canning has 16 neighbours at 1,200 m and 23 at 1,500 m in this illustration; Holland Road has zero and one respectively. Increasing the threshold changes the selected set. Inspect the thresholds and representative locations rather than interpreting polygon size as distance.

Go deeper: distance-decay weights

Distance-based weights need not be binary. For distinct locations, one option is inverse-distance weighting within a stated cutoff:

bij=dij−α1(dij≤d0),i≠j,α>0.b_{ij}=d_{ij}^{-\alpha}\mathbf{1}(d_{ij}\leq d_0), \qquad i\ne j,\quad \alpha>0.

Set bii=0b_{ii}=0 and define how coincident points are handled before using this expression. A larger exponent gives nearer neighbours greater relative weight. A distance band selects who contributes; a decay function additionally determines how contribution varies with distance. They are separate choices.

Use projected metric coordinates suitable for the region, or a documented geodesic calculation. A threshold in metres cannot be applied directly to unprojected longitude and latitude as if degrees were metres. For a road-travel question, a network travel-time relationship may be more appropriate than Euclidean distance.

k-nearest-neighbour weights

A k-nearest-neighbour (kNN) rule selects the kk closest other observations for each focal unit. With enough observations and an explicit tie rule, each row has kk outgoing neighbours, but the distance to the furthest selected neighbour varies.

Consider four synthetic points on a line at 0, 1, 3 and 10 km. With k=1k=1, their directed selections are A→B, B→A, C→B and D→C. C selects B, but B does not select C. Thus kNN weights need not be symmetric even though the underlying distance is symmetric. The selected distance ranges from 1 km to 7 km in this example.

Choosing k≥1k\geq1 avoids empty outgoing neighbour sets, but does not guarantee that the entire graph is connected. Separate groups can select neighbours only within themselves. Equal-distance ties and coincident coordinates need documented handling; arbitrary coordinate jitter changes the geometry and should not be an unexplained default.

If a symmetric relation is required, distinguish the union rule (connect a pair if either selects the other) from the mutual rule (connect only if both select each other). Symmetrising changes neighbour counts, and a mutual rule can create isolates. libpysal’s KNN documentation describes its implementation and tie handling.

Singapore subzone maps comparing k-nearest-neighbour selections for k equal to four and twelve.

Figure 8:The Singapore kNN example selects four neighbours in the upper panels and twelve in the lower panels. Fixing the neighbour count allows the geographical reach to vary between focal locations. These membership maps do not imply symmetric directed selections.

Row standardisation changes the summary

The neighbour relation and its numerical transformation are distinct. Starting with binary adjacency, define ki=∑jaijk_i=\sum_j a_{ij}. For a non-isolated row,

wij=aijki,∑jwij=1.w_{ij}=\frac{a_{ij}}{k_i},\qquad \sum_jw_{ij}=1.

For general nonnegative weights, divide by the row’s positive weight sum instead. The transformed weights specify relative contribution to the focal unit’s neighbour summary. They do not demonstrate influence or causation.

In the six-unit example, row 5 assigns weight 1/41/4 to each neighbour; row 6 assigns weight 1 to unit 3. Every nonempty row has total weight one, but each neighbour’s contribution differs. Standardisation changes a neighbour sum into an average; it does not make all geographical specifications or statistical results universally comparable.

Even a symmetric binary graph can become numerically asymmetric. Units 3 and 5 are mutual neighbours, but w35=1/2w_{35}=1/2 while w53=1/4w_{53}=1/4. Distinguish asymmetry in whether a link exists from asymmetry in its transformed weight.

Let S0=∑i∑jwijS_0=\sum_i\sum_jw_{ij}. For the binary matrix above, S0=16S_0=16. With all six rows standardised, S0=6S_0=6. The identity S0=nS_0=n requires every included row to sum to one; do not apply it without checking isolates.

A worked spatial lag

A spatial lag is the weighted neighbour summary

(Wx)i=∑jwijxj.(W\mathbf{x})_i=\sum_jw_{ij}x_j.

For binary weights it is a sum; after row standardisation it is the mean of the selected neighbours. More generally, nonnegative weights summing to one give a weighted mean. The focal value is excluded when wii=0w_{ii}=0.

Assign the six synthetic units values x=(2,4,6,8,10,12)\mathbf{x}=(2,4,6,8,10,12):

UnitNeighboursBinary lag: neighbour sumRow-standardised lag: neighbour mean
12, 4, 52222/322/3
21, 4, 52020/320/3
35, 62211
41, 2, 51616/316/3
51, 2, 3, 4205
6366

Unit 5 has value 10 but neighbour mean 5. Unit 6 has value 12 but neighbour mean 6. A lag can differ substantially from the focal value and can hide disagreement among neighbours: a mean of 5 need not describe any individual neighbour.

For a mean-centred vector d=x−xˉ1\mathbf{d}=\mathbf{x}-\bar{x}\mathbf{1}, the corresponding lag is WdW\mathbf{d}. With nonempty row-standardised weights, Wd=Wx−xˉ1W\mathbf{d}=W\mathbf{x}-\bar{x}\mathbf{1}. In this example xˉ=7\bar{x}=7, so unit 5 has deviation 3 and neighbour deviation lag 5−7=−25-7=-2. Their product is negative, a contrast contributing to Moran’s numerator. This is descriptive, not a local significance test.

A spatial lag is not a fitted prediction and does not establish that neighbouring values cause the focal value. Section 6.3 uses these products to construct the global statistic and its reference comparison.

Diagnose the graph before calculating the statistic

An isolate has no selected neighbours. A disconnected graph contains components with no links between them, even if no unit is isolated. Record both. An empty row cannot be standardised by division; representing its lag as zero is a software convention, not an observed neighbour average of zero.

Possible responses include revisiting a justified threshold, using a substantively suitable alternative relation, or reporting an explicit exclusion and its effect on the study population. Do not add arbitrary links solely to obtain a preferred coefficient. A graph across islands, mountain barriers or disconnected land masks deserves geographical inspection.

Match matrix row/column identifiers to table and geometry identifiers. Reordering a table without reordering its matrix assigns values to the wrong units. After dropping missing observations, reconstruct or correctly subset and restandardise the weights as required; neighbour counts can change.

For Malaysian districts, geometry quality, islands and unequal unit sizes require inspection. The Singapore illustrations show how rules change membership; the chapter’s empirical income analysis uses its own explicitly documented graph. Neither adjacency nor distance automatically represents commuting or income transmission.

Choose and report a defensible specification

RuleHeld consistent by constructionMain issue to inspect
Rook/queenA boundary-contact criterionTopology, islands and unequal unit sizes
Distance bandA distance thresholdIsolates, variable neighbour counts and representative points
kNNOutgoing neighbour count before symmetrisationLong links, ties, asymmetry and separate components
Distance decayA stated weighting functionCutoff, exponent, distance units and coincident points

Report the spatial support, geometry/coordinate system, neighbour rule and parameters, self-weight convention, transformation, isolates, components and data ordering. Compare a small set of justified alternatives while keeping other inputs fixed. A sensitivity result should explain how the question changes, rather than select the weights yielding the smallest p-value.

Check your reasoning

Self-check: Can queen neighbours share only an edge?

Feedback

Yes. Queen includes shared-edge and point-contact relationships; rook requires an edge.

Self-check: Does kNN guarantee one connected graph?

Feedback

No. Each observation can have outgoing neighbours while separate groups remain disconnected. Directed selections can also be asymmetric.

Self-check: Must row-standardised weights remain symmetric?

Feedback

No. Mutual neighbours with different neighbour counts receive different reciprocal weights. The underlying relation can still be symmetric.

Self-check: What is unit 5’s lag, and does it include its own value of 10?

Feedback

The binary lag is 20 and the row-standardised lag is 5. Its own value is excluded. The difference reflects the transformation, not a change in observations.

Self-check: Is a zero lag for an isolate the same as having neighbours whose values average to zero?

Feedback

No. The isolate has no neighbour information under that rule. A stored zero is a computational convention requiring explicit handling.

Read further and continue

Next: Moran’s I: combine focal deviations with their spatial lags, normalise the sum, and assess it against a fixed-weights permutation reference.

References
  1. Anselin, L. (2002). Under the hood Issues in the specification and interpretation of spatial regression models. Agricultural Economics, 27(3), 247–267. 10.1111/j.1574-0862.2002.tb00120.x