Put geography into a regression and “space” almost never means one thing. It hides two different problems that demand different tools, and naming which one you have is the first real modelling decision — get it wrong and everything downstream is quietly invalid.
Two phenomena, not one
Spatial dependence is a property of the covariance of the data: an outcome, or the errors around it, are correlated across nearby units. Tobler’s first law — near things are more related than distant ones — is the informal version. You encode “nearby” in a spatial weights matrix W (contiguity, distance bands, or k-nearest-neighbours, usually row-standardised) and then write one of two canonical models:
Spatial lag (SAR): y = ρ W y + X β + ε
Spatial error (SEM): y = X β + u , u = λ W u + ε
In the lag model the outcome itself spills over: my value responds to my neighbours’ values, with ρ measuring the strength. Because y sits on both sides, a shock anywhere propagates everywhere through the reduced form y = (I − ρW)⁻¹(Xβ + ε), so a covariate’s effect splits into a direct part and an indirect (spillover) part — the naïve β is no longer the marginal effect. In the error model the spillover lives in omitted, spatially structured factors captured by λ; here the coefficients β remain consistent under OLS, but the standard errors are wrong and inference is misleading.
The crucial point: in both, the relationship is global. One β vector describes the whole map. Space lives in the covariance structure, not in the parameters.
Spatial heterogeneity is the opposite — the parameters themselves move across space:
y_i = β₀(u_i, v_i) + Σ_k β_k(u_i, v_i) · x_ki + ε_i
where (u_i, v_i) are the coordinates of observation i. Geographically weighted regression (GWR) estimates a separate, kernel-weighted regression at every location — the bandwidth chosen by AICc or cross-validation — and returns a surface of local coefficients, one β per place. There is no single “effect of X”; there is an effect-here and an effect-there. Space now lives in the parameters, not (only) in the covariance.
Telling them apart
- Fit a global OLS and look at the residuals.
- Moran’s I on those residuals tests for leftover spatial structure:
I = (n / S₀) · (eᵀ W e) / (eᵀ e)
A significant I says “space remains” — but it does not say which kind. Both dependence and unmodelled heterogeneity leave autocorrelated residuals, so Moran’s I is a smoke alarm, not a diagnosis.
3. To discriminate dependence, use the LM (Lagrange multiplier) tests and their robust variants (Anselin’s decision rule): the robust LM-error versus robust LM-lag statistic points you toward SEM or SAR.
4. To detect heterogeneity, ask a different question — does a global model misfit systematically across whole regions? Spatial-regime / Chow-type tests, an AICc improvement of GWR over the global fit, or a patchy local-R² surface are the tells.
Why the distinction is not pedantic
- Model a genuinely varying relationship with a single lag term and you fold the misfit into
ρ, then report one averaged coefficient that is true nowhere. - Model merely neighbour-correlated errors with GWR and you let the coefficients wander to absorb noise, over-fitting a “heterogeneity” surface that is really an artefact.
And they co-occur. A relationship can vary across space and leave neighbour-correlated errors; then you need both — GWR with spatially robust inference, a spatially-varying-coefficient model, or MGWR when different covariates operate at different spatial scales.
The one-line test
Ask: is my neighbour’s value leaking into mine, or does the rule linking X to y change as I move across the map? The first is a covariance problem (spatial dependence); the second is a parameter problem (spatial heterogeneity). The entire modelling chain follows from which answer is yes.