Spatial error dependence diagnostics and corrections based on Müller-Watson, Econometrica 2024
Project description
spur-python: A Python Package for Spatial Unit Roots
A Python implementation of the methods for diagnosing and correcting spatial unit roots developed by Muller and Watson (2024). This is a complete port of the Stata package SPUR (Becker, Boll and Voth 2025) — see the forthcoming Stata Journal article for the practitioner's guide.
Installation
The easiest way to get started is to install our coding-agent skills.
Just point your agent at our spur-skills repository:
codex --dangerously-bypass-approvals-and-sandbox "Install spur-skills by following https://github.com/spatial-spur/spur-skills#install"
claude --dangerously-skip-permissions "Install spur-skills by following https://github.com/spatial-spur/spur-skills#install"
You can install just the package with:
uv pip install spur-python
Example Usage
We expose both the individual test functions and convenience wrappers running the entire pipeline.
To run the full pipeline, use the spur() wrapper:
import spur
from spur import load_chetty_data, standardize
# --- data processing ---
df = load_chetty_data()
df = df[~df.state.isin(["AK", "HI"])][["am", "fracblack", "lat", "lon"]]
df = df.dropna(subset=["am", "fracblack", "lat", "lon"])
df = standardize(df, ["am", "fracblack"])
# --- spur pipeline ---
result = spur.spur(
"am ~ fracblack",
df,
lon="lon",
lat="lat",
q=10,
nrep=500,
seed=42,
)
print(result.summary())
This prints both the spur-diagnostics:
--------------------------------------------
--------------------------------------------
SPUR Diagnostics
--------------------------------------------
Test LR p-value
i0 4.2961 0.0080
i1 2.5240 0.4660
i0resid 3.3153 0.0700
i1resid 570.7543 0.2540
--------------------------------------------
--------------------------------------------
and the regression results with transformed and untransformed variables:
Regression results
--------------------------------------------
--------------------------------------------
am
--------------------------
Coefficient Levels Transformed
--------------------------------------------
Intercept -0.0000 -0.0000
(0.1732) (0.0789)
fracblack -0.6009 -0.4240
(0.1187) (0.0903)
--------------------------------------------
N 693 693
R-squared 0.3611 0.1029
Adj. R-squared 0.3601 0.1016
SCPC q 8 8
SCPC cv 2.6097 2.6097
SCPC avc 0.0300 0.0300
--------------------------------------------
Citation
@Article{becker2025,
author = {Becker, Sascha O. and Boll, P. David and Voth, Hans-Joachim},
title = {Testing and Correcting for Spatial Unit Roots in Regression Analysis},
journal = {Stata Journal},
year = {forthcoming}
}
@Article{muller2024,
author = {M{\"u}ller, Ulrich K. and Watson, Mark W.},
title = {Spatial Unit Roots and Spurious Regression},
journal = {Econometrica},
year = {2024},
volume = {92},
number = {5},
pages = {1661--1695}
}
References
- Muller, Ulrich K. and Mark W. Watson (2024). "Spatial Unit Roots and Spurious Regression." Econometrica 92(5), 1661-1695.
- Becker, Sascha O., P. David Boll, and Hans-Joachim Voth (2025). "Testing and Correcting for Spatial Unit Roots in Regression Analysis." Stata Journal, forthcoming. [PDF]
- Chetty, Raj, Nathaniel Hendren, Patrick Kline, and Emmanuel Saez (2014). "Where is the Land of Opportunity? The Geography of Intergenerational Mobility in the United States." QJE 129(4).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spur_python-0.1.0b1.tar.gz.
File metadata
- Download URL: spur_python-0.1.0b1.tar.gz
- Upload date:
- Size: 180.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1caebabc92cd33341d1033fec9792fe0c6e05ecb44ff8c8febaf1b3674a06f2b
|
|
| MD5 |
88f83f0d854edcd6aa77e36eca5290b2
|
|
| BLAKE2b-256 |
ee0692f8eca158b99035dfed69cb102e1f66d7c25e86cb9287642bea8714fbcb
|
Provenance
The following attestation bundles were made for spur_python-0.1.0b1.tar.gz:
Publisher:
pypi.yaml on spatial-spur/spur-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spur_python-0.1.0b1.tar.gz -
Subject digest:
1caebabc92cd33341d1033fec9792fe0c6e05ecb44ff8c8febaf1b3674a06f2b - Sigstore transparency entry: 1349508425
- Sigstore integration time:
-
Permalink:
spatial-spur/spur-python@e98e629b1841ee26126858b37a66e6e287c22a80 -
Branch / Tag:
refs/tags/v0.1.0b1 - Owner: https://github.com/spatial-spur
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@e98e629b1841ee26126858b37a66e6e287c22a80 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spur_python-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: spur_python-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 168.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b6145d7fa273d0d0d5431af8fa086679fa9f3a99d3420bb3f8b819c8fc17896
|
|
| MD5 |
19ee3eaca0fca374e3ed7557e1a0ac4f
|
|
| BLAKE2b-256 |
7c42088804ff26d8cbc69d3f0a62c6dab0d29f87c84ed0dd4f54699354dd6a05
|
Provenance
The following attestation bundles were made for spur_python-0.1.0b1-py3-none-any.whl:
Publisher:
pypi.yaml on spatial-spur/spur-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spur_python-0.1.0b1-py3-none-any.whl -
Subject digest:
9b6145d7fa273d0d0d5431af8fa086679fa9f3a99d3420bb3f8b819c8fc17896 - Sigstore transparency entry: 1349508481
- Sigstore integration time:
-
Permalink:
spatial-spur/spur-python@e98e629b1841ee26126858b37a66e6e287c22a80 -
Branch / Tag:
refs/tags/v0.1.0b1 - Owner: https://github.com/spatial-spur
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@e98e629b1841ee26126858b37a66e6e287c22a80 -
Trigger Event:
release
-
Statement type: