Spatial Error Model
v1.0.2
Agriculture, Forestry & Aquatic context — Spatial Error Model. Regression that accounts for the spatial neighborhood structure of agac_capi_cm. Spatial weight matrix: K-nearest neighbor (k=5), row-standardized.
🎯 What is it for?
Classic OLS assumes the observations are independent — but in lat/lon data, nearby points take on similar values (spatial autocorrelation). The Spatial Error Model incorporates this structure into the model; otherwise the standard errors of the OLS β estimates come out too small (type-I error).
📌 When is it used?
- Spatial data (with lat/lon) + continuous DV in Agriculture, Forestry & Aquatic
- Moran’s I p < .05 — evidence of spatial autocorrelation
- Spatial clustering in the OLS residuals (hotspot over DBSCAN)
⚙ Assumptions
- Lat/lon coordinates ({lat, lon}).
- Continuous DV (agac_capi_cm).
- Design of the spatial weight matrix (KNN k=5 — default, with a dist.band alternative).
- The λ parameter is stable between 0-1; there is a risk of fragility at the boundary.
📊 How to Run in MerQur
Panel assignments (form fields in the program):
- Columns:
{'y': 'birim_id', 'x': ['X1', 'X2'], 'lat': 'lat', 'lon': 'lon'} - Parameters:
{'weights': 'knn', 'k': 5}
📊 Sample Dataset — Agriculture, Forestry & Aquatic
ℹ Note: The scenario, MerQur output and interpretation below were produced by actually running the real example dataset in MerQur. Numeric results on your own data will differ; the goal is to show how the analysis is set up and interpreted end-to-end.
🎬 Example File
This analysis is demonstrated on the following example dataset for Agriculture, Forestry & Aquatic:
Ziraat_Orman_Su/106_spatial_error_residual.xlsx
🎬 Scenario
Again across spatial units we model Y_value with X1, X2; but this time the spatial dependence is in the residuals (from
unobserved shared environmental factors). The spatial-error model (SEM) models the spatial structure of the error term to keep
the coefficients from becoming biased/inflated: what are the X effects once they are purified from the hidden spatial residual
arising from the neighborhood?
⚙️ Variable Selection
- Dependent (outcome): Y_value
- Predictors: X1, X2
- Coordinates: lat, lon
Data Preview (First 5 Rows)
| unit_id | lat | lon | X1 | X2 | Y_value |
|---|---|---|---|---|---|
| 1.0 | 40.729 | 36.2513 | 58.0 | 18.3 | 369.6 |
| 2.0 | 37.3016 | 39.779 | 60.9 | 46.8 | 460.7 |
| 3.0 | 38.3563 | 33.0728 | 73.2 | 48.6 | 495.5 |
| 4.0 | 41.2077 | 28.8098 | 82.7 | 15.0 | 199.5 |
| 5.0 | 40.7324 | 29.6924 | 48.9 | 32.5 | 410.3 |
n = 100 · Columns: unit_id, lat, lon, X1, X2, Y_value
📈 MerQur Output
─────────────────────────────────────────────
λ (lambda) = 0.590 z = 6.38, p < .001 Pseudo R² = 0.84 AIC = 1037.4
Y_value ~ X1 + X2 (lat/lon)
💬 Interpretation
Again across spatial units we modeled Y with X1, X2; but this time the spatial dependence is in the residuals (from
unobserved shared environmental factors). The spatial-error model (SEM) models the spatial structure of the error
term to keep the coefficients from becoming biased/inflated. The result is significant: lambda = 0.59, z = 6.38, p <
.001 — a strong spatial autocorrelation in the residuals. This supports the “omitted spatial variables” hypothesis:
something spatially structured that we did not include is affecting the residuals. With pseudo R² = 0.84 the model is
still strong. Choosing between SAR and SEM means asking whether the spillover is in the outcome (SAR) or in the error
(SEM); here AIC finds SEM slightly better.
⚠ Common Mistakes
- λ ≈ 1 → matrix singularity; try a looser W (k=10).
- The choice of W matrix affects the results — compare KNN and DistanceBand.
- Projected coordinates (UTM) instead of Lat/Lon may be preferable for accurate distance.
📚 MerQur’a Atıf
Örücü, Ö. K. (2026). MerQur: Integrated Academic Data Analysis & Reporting Platform [Computer software] (Version 1.0.0). https://doi.org/10.53463/merqur.2026001
📝 Üretim Notu — Bu sayfadaki örnek veri sentetik olarak üretilmiştir (sabit SEED=42, generator: samples/Ileri_Duzey_v102/_generate_v102_datasets.py). Sayfa içeriği Anthropic Claude desteği ile hazırlanmış, akademik doğruluk yazar tarafından kontrol edilmiştir.