Skip to content

Spatial Econometrics Tutorials

Learning Path

Prerequisites: Static Models tutorials, understanding of spatial concepts (proximity, contiguity) Time: 4--7 hours Level: Intermediate -- Advanced

Overview

Spatial econometrics extends panel models to account for geographic or network dependence between cross-sectional units. When outcomes in one region are influenced by outcomes or characteristics in neighboring regions, standard panel estimators produce biased and inconsistent results.

These tutorials cover the full spectrum of spatial panel models: the Spatial Autoregressive model (SAR), Spatial Error model (SEM), Spatial Durbin model (SDM), and dynamic spatial panels. You will learn how to construct spatial weight matrices, estimate direct and indirect (spillover) effects, and test for the appropriate spatial specification.

The Spatial Econometrics notebook tutorial provides a self-contained end-to-end example that complements these tutorials.

Notebooks

# Tutorial Level Time Colab
1 Introduction to Spatial Econometrics Intermediate 45 min Open In Colab
2 Spatial Weight Matrices Intermediate 45 min Open In Colab
3 Spatial Lag Model (SAR) Intermediate 45 min Open In Colab
4 Spatial Error Model (SEM) Intermediate 45 min Open In Colab
5 Spatial Durbin Model (SDM) Advanced 60 min Open In Colab
6 Spatial Marginal Effects Advanced 45 min Open In Colab
7 Dynamic Spatial Panels Advanced 60 min Open In Colab
8 Specification Tests Advanced 45 min Open In Colab

Learning Paths

Core (4 hours)

Essential spatial models for applied research:

Notebooks: 1, 2, 3, 4, 5

Covers weight matrix construction, the three canonical spatial models (SAR, SEM, SDM), and how to choose between them.

Advanced (7 hours)

Complete spatial econometrics coverage:

Notebooks: 1--8

Adds direct/indirect effects decomposition, dynamic spatial panels, and formal specification testing.

Key Concepts Covered

  • Spatial dependence: Why ignoring spatial correlation leads to bias
  • Weight matrices: Contiguity, distance-based, k-nearest neighbors
  • SAR (Spatial Lag): Endogenous spatial lag of the dependent variable
  • SEM (Spatial Error): Spatial correlation in the error term
  • SDM (Spatial Durbin): Both spatially lagged dependent variable and regressors
  • Direct vs indirect effects: Own-region vs spillover impacts
  • Dynamic spatial: Combining temporal dynamics with spatial dependence
  • LM tests: Lagrange Multiplier tests for spatial specification

Quick Example

from panelbox.models.spatial import SpatialLag
import numpy as np

# Create a spatial weight matrix (row-standardized)
W = ...  # your NxN weight matrix

# Estimate Spatial Lag model
sar = SpatialLag(
    data=data,
    formula="y ~ x1 + x2",
    entity_col="id",
    time_col="year",
    w=W
).fit()

print(sar.summary())
print(f"Spatial rho: {sar.rho:.4f}")