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).
Release files for spur-python 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spur_python-0.1.1.tar.gz | 180.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spur_python-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:349.3 kB
Release files / spur_python-0.1.1.tar.gz
| Download URL | spur_python-0.1.1.tar.gz |
|---|---|
| Size | 180.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7815db6956e640e830778f69ad82cdb6929040628e0a0919a5549ade9d7abcf8
|
|
BLAKE2b-256 checksum How to use checksums |
c44664692ae8999ea8869def54046bd127a0a93f0dba6a0a79673e0d2b7db488
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.
Transparency logRelease files / spur_python-0.1.1-py3-none-any.whl
| Download URL | spur_python-0.1.1-py3-none-any.whl |
|---|---|
| Size | 168.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7e6d83b6c0e07154ad6a6146a90f2dd011d1bb5b1a6509cde42cb36186f0f73
|
|
BLAKE2b-256 checksum How to use checksums |
0405292afc99a7f0b609dad26723d506ff27174331c695de12cb78f41502fbcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.
Transparency log