Lecture Slides: Theory, Intuition & Spatial Statistics Modeling

Advanced Spatial Statistics

Theory, Intuition & Spatial Statistics Modeling

Adedoyin S. Ajeyomi
01
Why Spatial Statistics in the Real World
02
Exploring Space: ESDA, Moran's I & LISA
03
Testing & Modelling Spatial Dependence
04
Space-Time Pattern Mining: Emerging Hot Spots
05
Tools, Software & Hands-on Notebook Use Cases
06
Q&A / Open Discussion

Why Spatial Statistics in the Real World?

Traditional statistical methods and data science pipelines operate under the assumption of independent and identically distributed ($i.i.d.$) observations, the assumption that what happens in one village, ward, or neighborhood is completely independent of its neighbors. In reality, human settlements, economic commerce, disease vectors, and infrastructural access do not stop at administrative boundaries.

When public institutions and private corporations make strategic decisions based on state or national averages, they fall victim to three major fallacies:

1

The Fallacy of the Average

A state or province can appear "moderately wealthy" or "well-served by healthcare" on paper, while masking extreme internal inequality, such as affluent metropolitan centers sitting beside vast rural "healthcare deserts" where hundreds of thousands of citizens have zero access to clinics.

2

The Spillover Blindspot (Tobler's First Law)

"Everything is related to everything else, but near things are more related than distant things" (Waldo Tobler, 1970). Investing in a major regional hospital, agricultural market, or road corridor in one ward creates positive spatial externalities (spillovers) across neighboring wards. Standard regressions dismiss this as unexplainable noise; spatial econometrics explicitly models and quantifies it.

3

The Capital Misallocation Trap

Deploying bank branches, supermarket retail stores, or drilling water boreholes without spatial intelligence leads to capital waste: saturating already competitive clusters while completely missing high-demand, underserved communities.

What Spatial Statistics Can Do

Spatial statistics goes beyond guesswork and what the eye sees on a map. It uses science, data and measurable metrics to test whether a spatial pattern is real, measure how strong it is, and show exactly where it matters. Using Nigeria's administrative wards as a worked example, it answers questions such as:

Healthcare deserts map
1
Where are the most urgent healthcare deserts?

(e.g. areas with $>17{,}000$ residents and zero registered clinics).

Retail catchment map
2
Where are prime, untapped consumer retail catchments?

(e.g. areas with high purchasing power but low commercial market density).

Religious geography map
3
How do religious and civic institutions sort geographically?

(e.g. areas where churches and mosques sit side by side).

Map of water-desert clusters across Nigerian wards
4
How unequal is clean water infrastructure?

(e.g. 759 neighbouring wards in the north with almost no water points, home to about 21 million people).

5
What is the true economic multiplier of public investments?

(e.g. a new clinic that also helps the wards next door).

The Superpower of Spatial Statistics: Exploratory Spatial Data Analysis (ESDA) for Pattern Discovery

Why is spatial statistics so exceptionally powerful for exploratory analysis?

Traditional non-spatial data exploration relies on summary metrics (mean, median, standard deviation), histograms, and correlation matrices. These tools operate in "feature space" and completely discard geographic coordinates and spatial relationships:

Traditional EDA
[Values]
Summary Stats (Mean, SD)
BLIND to geographic arrangement
Spatial EDA
[Values + Space]
Moran's I + LISA Maps
UNLOCKS hidden clusters & anomalies

What Traditional Exploratory Data Analysis (EDA) Misses

1

Geographic Blindness

You can shuffle the locations of 9,308 Nigerian wards randomly across the map, and the dataset's histogram, mean, and standard deviation will remain 100% identical. Traditional EDA cannot tell whether poverty is randomly scattered or concentrated in vast regional belts.

2

Hidden Structural Regimes

A single national correlation coefficient ($r = 0.80$) can conceal that the relationship between healthcare facilities and population is strongly positive in the South, but non-existent or reversed in remote Sahelian border areas.

3

Inability to Detect Local Spatial Anomalies

Standard outlier detection (e.g. Tukey boxplots or $z$-scores $> 3$) only finds values that are globally extreme across the entire country. It completely misses spatial outliers, such as an affluent commercial ward surrounded by severe poverty, or an impoverished rural pocket inside a wealthy metropolitan corridor.

What Exploratory Spatial Data Analysis (ESDA) Unlocks

Global Moran's I scatterplot of ward wealth
1

Hypothesis-Free Pattern Discovery: ESDA allows analysts to detect statistically significant geographic structures before formulating complex parametric equations.

2

Global Spatial Autocorrelation (Moran's $I$): Statistically proves whether an observed map pattern is genuine clustering or mere random chance ($p < 0.001$).

What Exploratory Spatial Data Analysis (ESDA) Unlocks

Anselin LISA wealth clusters across Nigeria
3

Local Indicators of Spatial Association (Anselin LISA $I_i$): Pinpoints the exact coordinates of:

Hotspots (HH): Statistically robust clusters of high values (e.g., concentrated wealth in Lagos and Abuja).

Coldspots (LL): Entrenched structural deprivation zones requiring targeted social interventions.

Spatial Outliers (HL & LH): Regional economic engines ("Islands of Wealth") and underserved pockets within affluent zones ("Opportunity Sinks").

4

Spatial Heterogeneity & Boundary Regimes: Reveals non-stationary processes across state borders, river basins, and agro-ecological zones.

In short, spatial statistics transforms raw geodata into structured pattern intelligence, enabling decision-makers to see the structural geography that standard data science leaves invisible.

The Spatial Statistics Workflow: Each Step Builds on the Last

Every method depends on the one before it: the neighbourhood matrix $W$ feeds Moran's $I$ and LISA, their results justify moving beyond OLS, and the diagnostics decide which spatial model to fit.

1
Neighbourhood ($W$)

Define who is a neighbour: contiguity, distance or k-NN.

libpysal
2
Global Moran's $I$

Is there spatial clustering at all? Uses $W$.

esda
3
Anselin LISA ($I_i$)

Where are the hotspots, coldspots & outliers?

esda
4
OLS Baseline

Aspatial model; test its residuals with Moran's $I$ & LM tests.

spreg
5
SAR / SEM / SDM

The tests tell us why neighbours look alike: the problem spreads, they share a hidden cause, or both.

spreg
6
GWR / MGWR

Let each coefficient vary across space and scale.

mgwr
7
Spatio-Temporal Models

Add time: how clusters and effects evolve across years.

giddy

Checking Spatial Dependence: The Testing Toolkit

Global: one answer for the whole map Local: one answer per location Model diagnostics
1
Global Moran's $I$

Is there clustering anywhere on the map?

esda.Moran
2
Geary's $C$

Are neighbours similar? More sensitive to local differences.

esda.Geary
3
Getis-Ord General $G$

Is it the high or the low values that cluster?

esda.G
4
Join Counts

Do categories cluster? (urban / rural, has clinic / none)

esda.Join_Counts
5
Anselin LISA ($I_i$)

Where are the hotspots, coldspots & outliers?

esda.Moran_Local
6
Getis-Ord $G_i^*$

Where are statistically hot and cold spots?

esda.G_Local
7
Bivariate LISA

Does X around me relate to Y here?

esda.Moran_Local_BV
8
Local Geary

Where are neighbours unusually alike on many variables?

esda.Geary_Local
9
Residual Moran's $I$ + LM tests

Did OLS leave spatial structure? LM-lag vs LM-error picks SAR, SEM or SDM.

spreg.OLS(spat_diag=True)

Rule of thumb: test globally first (is there dependence?), then locally (where is it?), then fit OLS and read the residual diagnostics to choose the spatial model.

Spatial Lag Model (SAR): When the Problem Spreads

In plain words

A ward's outcome is pushed up or down by its neighbours' outcomes. The problem itself spreads from place to place.

Ask yourself: Does a change in one ward cause a change in the next ward?

The model
$$y = \rho W y + X\beta + \varepsilon$$

What it gives you$\rho$: how strongly outcomes spread, and the ripple multiplier $\frac{1}{1-\rho}$. If $\rho = 0.45$, every local change grows about 1.8× across the area.

Same example, this model: malaria in neighbouring wards

Malaria in one ward raises malaria in the next ward, because infected people and mosquitoes move between them. Treating one ward also lowers malaria next door.

SARthe problem spreads
SEMa shared hidden cause
SDMboth, plus neighbours' resources

Spatial Error Model (SEM): When Neighbours Share a Hidden Cause

In plain words

Neighbouring wards look alike because they share something the data left out, not because they affect each other.

Ask yourself: Is there a hidden shared cause (rainfall, soil, state policy) that my data does not include?

The model
$$y = X\beta + u, \quad u = \lambda W u + \varepsilon$$

What it gives youHonest $p$-values, so you do not claim an effect that is not real. $\lambda$ shows how strong the shared hidden cause is.

Same example, this model: malaria in neighbouring wards

Neighbouring wards all have high malaria because they sit in the same swampy, rainy zone. One ward is not infecting the next; they share the same environment.

SARthe problem spreads
SEMa shared hidden cause
SDMboth, plus neighbours' resources

Spatial Durbin Model (SDM): Both at Once

In plain words

Outcomes spread between wards and your neighbours' characteristics (their clinics, roads, wealth) also affect you.

Ask yourself: Do my neighbours' resources change my outcome, not just my own?

The model
$$y = \rho W y + X\beta + W X\theta + \varepsilon$$

What it gives youDirect effect (in your ward) + indirect effect (spillover to neighbours) = total effect. The safe choice when unsure between SAR and SEM.

Same example, this model: malaria in neighbouring wards

A new clinic with bed nets lowers malaria in its own ward (direct) and in neighbouring wards whose families use it (spillover). OLS only sees the first part.

SARthe problem spreads
SEMa shared hidden cause
SDMboth, plus neighbours' resources

Local Regression: GWR & MGWR

Traditional regression (OLS)

One equation for the whole map, so one slope applies everywhere.

$y = \beta_0 + \beta_1 x + \varepsilon$

Course result: one national slope, $R^2 = 0.13$

Geographically weighted regression (GWR)

One equation per place, fitted with nearby places weighted more than distant ones.

$y_i = \beta_0(u_i,v_i) + \sum_k \beta_k(u_i,v_i)\,x_{ik} + \varepsilon_i$

Course result: bandwidth 48 LGAs, $R^2 = 0.57$, AICc 2091 → 1830

MGWR goes one step further: each variable gets its own bandwidth (village, regional or national scale).
Course result: local slope of purchasing power → schools per 10k people
GWR local slope map across Nigerian LGAs
negative weak positive significant (48 LGAs)

Space-Time Pattern Mining: Emerging Hot Spot Analysis

1
Create Space Time CubeBin values by location × time step
2
Getis-Ord $G_i^*$ per binCompare each bin with its space-time neighbours
3
Mann-Kendall trendIs each location intensifying or diminishing?

Reading the map: New, consecutive & intensifying = emerging, act early. Persistent = structural. Diminishing & historical = cooling. ArcGIS Pro: arcpy.stpm · R: sfdep.

Tools, Software & Libraries for Spatial Statistics

Python

Python

PySALPySAL ecosystem

libpysal Spatial weights $W$ (contiguity, distance, k-NN)

esda Moran's $I$, LISA, Getis-Ord $G_i^*$

spreg OLS diagnostics, SAR, SEM, SDM

mgwr GWR & MGWR

splot Moran scatterplots & LISA maps

giddy Space-time dynamics (spatial Markov, LISA over time)

GeoPandas

GeoPandas Ward boundaries, spatial joins & choropleth maps (with rasterio / rasterstats for satellite rasters)

R

R

sf Spatial vector data & mapping

spdep Weights, Moran's $I$, LISA

spatialreg SAR, SEM, SDM & impacts

GWmodel GWR & multiscale GWR

CARBayesST Spatio-temporal areal models

Desktop GIS

ArcGIS Pro

ArcGIS Pro Spatial Statistics toolbox: Hot Spots, Cluster & Outlier, GWR, Space-Time Cube

arcpy.stats Spatial Statistics tools in Python

arcgis ArcGIS API for Python

GeoDa

GeoDa Free point-and-click ESDA & LISA maps

The course notebooks run on free, open-source Python: geopandas, libpysal, esda, spreg and splot. The same analyses are available in ArcGIS Pro.

Thank you

Q&A / Open Discussion