MerQuR+Statistics Glossary

Statistics Glossary → Spatial Error Model (SEM)

Spatial Error Model (SEM)analysis

A spatial regression model for when the similarity of neighbouring areas comes from shared factors left out of the model, which models this dependence in the error term and estimates the effects of the explanatory variables with correct standard errors.

Concept

In spatial data, neighbouring units resembling each other does not always mean 'spillover'. Often the similarity comes from unmeasured factors that cluster in space: neighbouring villages share soil and climate, neighbouring neighbourhoods share cultural traits. When such factors are not in the model, they collect in the error terms and the errors of neighbouring units become correlated. Ordinary regression then gives misleading standard errors and inefficient estimates.

The spatial error model (SEM) places the dependence in the error term: y = Xβ + u, u = λWu + ε. W is the neighbourhood weights matrix, and λ shows how similar the errors of neighbouring units are. Since the outcome itself does not spread to the neighbours, the βs are direct marginal effects; no direct-indirect split is needed as in the SAR model. The Spatial Durbin Error Model (SDEM) also adds the neighbours' explanatory variables (WX); here the indirect effect is read directly from these extra coefficients.

The results are sensitive to the neighbourhood definition (W). The choice between SEM and SAR is usually made with Lagrange multiplier tests on the OLS residuals, but in small samples the distinction can remain unclear and both models should be reported. The spatial Hausman test checks whether the OLS and SEM coefficients differ clearly; a large difference suggests there may be an unmeasured factor correlated with the explanatory variables, and that SEM may not be adequate.

When to use it

  • When the residuals of spatial units show clear spatial autocorrelation and this is thought to come from unmeasured regional factors rather than from the outcome spreading to neighbours.
  • If the neighbours' outcome is thought to genuinely affect a unit's own outcome, use the SAR (spatial lag) model; if the neighbours' explanatory variables also matter, use SDEM or SDM.
  • If the effects of the explanatory variables vary from region to region, geographically weighted regression (GWR) is preferred.

An everyday example

A provincial agriculture office explains wheat yield in 80 villages by the amount of fertiliser used and the share of irrigated land. The model's prediction errors are not scattered randomly on the map: in all the villages of one valley, yield is above the prediction. The reason may be unmeasured soil structure and microclimate. If the spatial error model finds λ = 0.6, the unmeasured conditions of neighbouring villages are strongly similar; by allowing for this, the model gives the fertiliser effect with a more accurate standard error.

Parameters in MerQur

Dependent variable (numeric), Predictors (X), Latitude, Longitude

Concept: The dependent and explanatory variables are as in ordinary regression; the coordinates give each unit's location, and the neighbourhood relations are built from them.

Everyday example: In the village example the dependent variable is wheat yield per decare and the explanatory variables are fertiliser amount and irrigation share; the latitude and longitude of each village centre define the neighbourhoods.

What it does: Selects the variables of the model and the point coordinates.

Effect on the result: All estimates change.

On the validation data: Columbus: CRIME ~ HOVAL + INC.

Neighbourhood method (k-NN (k nearest neighbours) / Distance band (distance threshold) / Distance band - user threshold (binary) / Inverse distance 1/d (within threshold) / External weights file (.gal / .gwt)), Distance threshold (coordinate units), Weights file

Concept: The neighbourhood method builds the weights matrix (W) that defines between which units the error terms are treated as related: the k nearest units, units within a distance, weights declining with distance, or a ready-made file. The distance threshold is the neighbourhood radius in the band methods.

Everyday example: If the villages in the valley are 3-4 km apart, a 5 km threshold makes them neighbours. If a GIS file with shared-border information exists, it can be used directly; this is also how villages on opposite sides of a mountain can be kept from counting as neighbours.

What it does: Options shared with the SAR form: k-NN, automatic distance band, binary band with a user threshold, 1/d within the threshold and an external .gal/.gwt file.

Effect on the result: λ, β, SE and logL depend entirely on W. The threshold has no effect when k-NN is selected.

On the validation data: Columbus: k-NN (k = 5) λ = 0.6788 (logL -179.47); distance band λ = 0.6216 (logL -181.59). With the Anselin .gal and the Example 32.1 W, λ = 0.561779. In Boston, units without neighbours arise at a 2 km threshold.

→ Spatial weights matrix (W)

k (for k-NN)

Concept: In the k-nearest-neighbour method, sets how many neighbours each unit has; k reflects an assumption about how wide an area shares the unmeasured factors.

Everyday example: If soil structure is similar only over small patches of a few villages, a small k is suitable; if it spreads over a whole plain, a larger k is more realistic. Checking how λ changes across several k values is a good check.

What it does: The number of neighbours of each unit; active only in k-NN (it has no effect in the distance band and the field is disabled).

Effect on the result: λ and SE change.

On the validation data: λ = 0.5312 for k = 2, 0.6788 for k = 5, 0.5630 for k = 10 (SE 0.196). k = 50 exceeds n-1: error ("k can be at most 48").

→ Spatial weights matrix (W)

W standardisation (W - row-standardised (default) / B - binary (raw weights) / C - globally standardised (sum = n) / U - unit sum (sum = 1) / S - variance-stabilising (Tiefelsdorf))

Concept: Sets the scale of W. With row standardisation each unit's neighbour weights sum to 1 and Wu is the neighbours' average error; on other scales the numerical value of λ changes but the same dependence is expressed in different units.

Everyday example: With a row-standardised W, λ = 0.6 says a village's unmeasured conditions are strongly related to its neighbours' average. With a binary W, λ may come out as a much smaller number; this does not mean the dependence is weaker.

What it does: Shared with SAR; λ is reported on the original W scale.

Effect on the result: The scale of λ and logL change (B, C, U are the same model).

On the validation data: With the distance band, λ: W 0.6216, B 0.1273, C 0.5664, U 27.7554, S 0.6727; logL: -174.49 in B, C and U, -181.59 in W.

→ Spatial weights matrix (W)

Distance metric (Euclidean - coordinate units (default) / Great circle - latitude/longitude (km))

Concept: Euclidean distance is used on a flat map with projected coordinates; great-circle distance accounts for the Earth's curvature and is used with latitude-longitude degrees.

Everyday example: For villages within one district, both distance measures give almost the same neighbourhoods. For a study covering several provinces with coordinates in degrees, great-circle distance is more accurate.

What it does: Euclidean distance in coordinate units or great-circle (km) distance.

Effect on the result: The k-NN neighbours and the threshold change.

On the validation data: Boston, k = 5: Euclidean λ = 0.7811 (logL -1443.50); great circle λ = 0.7788 (logL -1431.48).

→ Distance measure (Euclidean, Manhattan, Gower, great-circle)

Model (SEM (spatial error, default) / SDEM (Spatial Durbin Error: + WX))

Concept: SEM models dependence only in the error term; SDEM also adds the neighbours' explanatory variables. In SDEM, the effect of a variable on a unit's own outcome is the direct effect and the effect of its value in the neighbours is the indirect effect, with no feedback loop as in SAR.

Everyday example: A village's yield may also depend on neighbouring villages' irrigation: if a lot of water is drawn upstream, less is left for the village downstream. SDEM shows this 'neighbour's irrigation' effect as a separate indirect effect.

What it does: SDEM adds the WX terms; the effects become direct = β, indirect = θ, total = β + θ (there is no feedback).

Effect on the result: Coefficients and effects change.

On the validation data: With k-NN, SDEM λ = 0.7223; HOVAL direct effect -0.2753 (SE 0.0854), indirect -0.2779 (0.2802), total -0.5533 (0.3205).

→ Spatial lag and spatial Durbin models (SAR, SDM, SDEM)

Extra output: Spatial Hausman test (Pace & LeSage 2008)

Concept: If the error model is correct, the OLS and SEM coefficients should be close; only their efficiency differs. The spatial Hausman test checks whether the two sets of coefficients differ clearly; a significant difference suggests a missing factor in the model that is correlated with the explanatory variables.

Everyday example: If the fertiliser coefficient is 0.8 under OLS and 0.3 under SEM and the Hausman test is significant, unmeasured soil fertility may be affecting both yield and how much fertiliser farmers use. Then fixing the error term alone is not enough.

What it does: Tests the difference between the OLS and SEM coefficients (Pace and LeSage 2008); a significant result suggests that the SEM may be misspecified. When SDEM is selected, the box is disabled and an explanatory note is printed.

Effect on the result: Only adds output.

On the validation data: k-NN H = 6.510 (df 3, p = 0.089); distance band H = 7.555 (p = 0.056); Baltimore H = 30.27 (p = 0.0008); Columbus .gal H = 5.256 (p = 0.154).

→ Hausman test

Confidence Level (%90 / %95 / %99 / Other (custom))

Concept: Sets the confidence level of the interval estimates for the coefficients and λ; the higher the level, the wider the interval.

Everyday example: If the 95% confidence interval for λ is [0.45, 0.85], neighbouring villages' unmeasured conditions are probably strongly similar; choosing 90% narrows the interval.

What it does: The level of the Wald confidence interval.

Effect on the result: Only the interval limits change.

On the validation data: Columbus (k = 5): λ = 0.6788, SE 0.1141, 95% CI [0.4552, 0.9024].

→ Confidence level and confidence interval

Example on real data

Data: Anselin 1988 Columbus crime data, R spData

Variables: dependent CRIME (crime rate), predictors HOVAL (house value) and INC (income), coordinates Y and X (49 neighbourhoods)

  • Question: In Columbus, in the relationship of the crime rate (CRIME) with house value (HOVAL) and income (INC), is the spatial dependence arising from unmeasured regional factors located in the error term? (W: 5 nearest neighbours, row-standardised.)
  • Result: λ = 0.679 (SE 0.114, 95% CI [0.455, 0.902], z = 5.95, p < .001): the error terms of neighbouring areas are strongly similar, that is, there is a spatial factor that is not in the model.
  • Coefficients: House value (β = -0.247, z = -3.02, p = .003) and income (β = -1.014, z = -3.31, p < .001) reduce the crime rate. In the SEM the βs are direct marginal effects (there is no spillover effect).
  • Model fit: logL = -179.47, AIC = 368.94 (SAR with the same W 370.63, OLS 382.75); σ² = 80.04; pseudo R² = 0.55. By AIC, the SEM is slightly better than the SAR.
  • Limitation: n = 49 is small; the distinction between SEM and SAR is sensitive to the LM tests and the choice of W, so the two models should be reported together.
  • APA: Spatial error model (ML, k-NN W, k = 5, N = 49): λ = 0.68, z = 5.95, p < .001; INC β = -1.01, p < .001; pseudo R² = .55, AIC = 368.94.

Related concepts

Confidence level and confidence intervalSpatial weights matrix (W)Spatial lag and spatial Durbin models (SAR, SDM, SDEM)Hausman testDistance measure (Euclidean, Manhattan, Gower, great-circle)Inverse distance weighting (IDW)Maximum likelihood (ML) estimationOrdinary least squares (OLS)

The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.