Skip to main content

Tests Python Version

███████  ██████ ██████   ██████       ██████  ██    ██ ████████ ██   ██  ██████  ███    ██ 
██      ██      ██   ██ ██            ██   ██  ██  ██     ██    ██   ██ ██    ██ ████   ██ 
███████ ██      ██████  ██      █████ ██████    ████      ██    ███████ ██    ██ ██ ██  ██ 
     ██ ██      ██      ██            ██         ██       ██    ██   ██ ██    ██ ██  ██ ██ 
███████  ██████ ██       ██████       ██         ██       ██    ██   ██  ██████  ██   ████ 
                                                                                           

scpc-python: Spatial Correlation-Robust Inference

scpc-python provides spatial correlation-robust inference for regression coefficients following Müller and Watson (2022, 2023).

Installation

You can install scpc-python from PyPI (coming soon) with:

uv venv --python 3.11
uv pip install scpc-python

or from GitHub with:

uv venv --python 3.11
uv pip install git+https://github.com/DGoettlich/scpc-python.git

Basic Usage

This example starts from the transformed branch of the Becker, Boll, and Voth (2026) workflow. In the full workflow, you would first use spurtest to decide whether to stay in levels or transform. Here we assume the transformed branch and move directly to the regression plus scpc step.

# assumes spur-python is installed
from spur import load_chetty_data, spurtransform
from scpc import scpc
import statsmodels.formula.api as smf

data = load_chetty_data()

data = data[~data["state"].isin(["AK", "HI"])][
    ["am", "gini", "fracblack", "lat", "lon"]
]
data = data.dropna(subset=["am", "gini", "fracblack", "lat", "lon"]).copy()

transformed = spurtransform(
    "am ~ gini + fracblack",
    data,
    lon="lon",
    lat="lat",
    transformation="lbmgls",
    prefix="h_",
)

fit = smf.ols("h_am ~ h_gini + h_fracblack", data=transformed).fit()

result = scpc(
    fit,
    data=transformed,
    lon="lon",
    lat="lat",
    cvs=True,
)

print(result)

scpc() returns an SCPCResult object:

  • print(result): prints an R-like SCPC inference table
  • result.scpcstats: the main inference table with coefficient estimates, standard errors, t statistics, p values, and 95% interval endpoints
  • result.scpccvs: optional stored critical values at 32%, 10%, 5%, and 1%
  • result.coef(): returns named coefficient estimates in scpc-python>=0.1.2
  • result.confint(): returns named confidence intervals in scpc-python>=0.1.2
  • result.summary(): prints the main table plus confidence intervals in scpc-python>=0.1.2
  • result.avc: the average pairwise correlation bound used in the analysis
  • result.c0: the kernel scale implied by avc
  • result.cv: the unconditional 5% critical value
  • result.q: the number of retained non-constant spatial principal components

Key Arguments

The most important scpc() arguments in the workflow above are:

  • model: the fitted regression model
  • data: the data frame
  • lon, lat: the geodesic coordinate column names
  • coords_euclidean: use this instead of lon / lat when coordinates are Euclidean rather than geographic
  • cluster: optional clustering column
  • ncoef: how many coefficients to report
  • avc: upper bound on the average pairwise correlation
  • uncond: whether to skip the conditional adjustment
  • cvs: whether to store the extra critical values

Release files for scpc-python 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scpc-python 0.1.2
File Size Uploaded
scpc_python-0.1.2.tar.gz 42.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scpc-python 0.1.2
File Interpreter ABI Platform
scpc_python-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 68.5 kB

Release files / scpc_python-0.1.2.tar.gz

Download URL scpc_python-0.1.2.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
031d59006eb2cae0ebce9068b11fc30403a7f284107015fadf11743692a2a142
BLAKE2b-256 checksum
How to use checksums
6c2f4ef7e49f1f0a8888f4efff274a023fe8a6783385f8894a14fc80f893bb58
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 23, 2026.

Transparency log

Release files / scpc_python-0.1.2-py3-none-any.whl

Download URL scpc_python-0.1.2-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be715bdf7bf6dae2eca84b4a1fa92dd38578090f8ee667457e5bb085a346bc38
BLAKE2b-256 checksum
How to use checksums
dd5b4c86a10f9ca9d8cea149cac05ed6fa3d6662b70c192210d31ae126f66881
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 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page