Skip to main content

Bayesian spatial-spillover synthetic control (Sakaguchi & Tagawa) for causal inference on panel data.

Project description

scspill — Bayesian synthetic control with spillovers and key result plots

scspill

CI Docs PyPI Python License: MIT Ruff Open in Colab

Synthetic control when the treatment leaks. scspill is a Python implementation of the Bayesian spatial-spillover synthetic control of Sakaguchi & Tagawa (Identification and Bayesian Inference for Synthetic Control Methods with Spillover Effects, The Econometrics Journal): it relaxes SUTVA by letting the treatment spill over to the donor pool through a spatial-autoregressive channel with user-supplied weights, and estimates both the treatment effect on the treated unit and the spillover effect received by every donor — with full Bayesian uncertainty.

The estimator follows the mlsynth architecture (a pydantic config in, a standardized results object out) so the two libraries compose naturally; the documentation site follows geometrics.

Installation

pip install scspill              # NumPy/SciPy sampler backend
pip install "scspill[numba]"     # + JIT-compiled samplers (~10x faster)
pip install "scspill @ git+https://github.com/quarcs-lab/scspill.git"   # latest

Python 3.10+.

At a glance

from scspill import SCSPILL
from scspill.data import load_california

panel = load_california()        # Prop 99 panel + rook-contiguity weights
result = SCSPILL(
    {**panel.config_kwargs(), "m_iter": 20_000, "burn": 10_000, "seed": 42}
).fit()

result.att, result.att_ci          # treatment effect on California + 95% CrI
result.rho_hat, result.rho_ci      # spillover intensity posterior
result.spillover_panel["Nevada"]   # the effect received by Nevada, per year
result.diagnostics()               # ESS / R-hat / MCSE per chain
result.plot(kind="panel")          # counterfactual | effect | top spillovers

What's inside

Subpackage What it does Docs
scspill SCSPILL(config).fit() — the two-step Bayesian sampler (horseshoe synthetic weights, SAR spillover block, adaptive Metropolis for the spillover intensity) and the identification formulas Get started
scspill.validation The Geweke (2004) joint distribution test of the sampler, prior-sensitivity grids, prior predictive checks Validation
scspill.simulate The paper's Monte Carlo engine: rook-lattice SAR DGP, SCM/BSCM/SCSPILL comparison, the Tables 1–2 grid Simulation study
scspill.data The bundled California Prop 99 and Sudan secession case studies Datasets

Validated against the R replication package

The Python port is cross-validated against the authors' R replication package (python benchmarks/run_benchmarks.py --all --report): California and Sudan posteriors against the frozen R credible intervals, the Monte Carlo grid against the paper's frozen Tables 1–2, prior predictive statistics to three decimals, and the samplers against the Geweke joint distribution test. The defaults are paper-correct: several documented bugs of the reference implementation (a covariate memory-layout mismatch, a missing horseshoe prior, alpha-frozen credible intervals, two incoherent factor-block conditionals) are fixed here, each with an escape hatch or a benchmark quantifying the difference — see the method article.

Documentation

Full documentation, executed tutorials, and the API reference live at https://quarcs-lab.github.io/scspill/. Machine-readable entry points for AI agents: llms.txt and llms-full.txt.

Development

git clone https://github.com/quarcs-lab/scspill && cd scspill
uv sync --all-extras --group dev --group docs
make test      # pytest (fast tier; `make test-slow` for the long tier)
make lint      # ruff check + format
make typecheck # mypy
make docs      # quartodoc build -> quarto render -> llms.txt

Citing

If you use scspill, please cite both the software and the methodological article (machine-readable metadata lives in CITATION.cff):

Mendez, C., Sakaguchi, S., & Tagawa, H. (2026). Bayesian Synthetic Control with Spillovers in Python (version 0.1.1). https://github.com/quarcs-lab/scspill

Sakaguchi, S., & Tagawa, H. (2026). Identification and Bayesian Inference for Synthetic Control Methods with Spillover Effects. The Econometrics Journal. https://doi.org/10.1093/ectj/utag006

Acknowledgments

The method and the original R/C++ implementation are the work of Shosei Sakaguchi and Hayato Tagawa, who are credited as co-authors of this library on that basis; the Python implementation is by Carlos Mendez and any bug in it is his. Their replication package is MIT-licensed, and every release of scspill is cross-validated against its frozen results. The estimator architecture follows Jared Greathouse's mlsynth; the documentation stack follows the QuaRCS-lab geometrics package.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scspill-0.1.1.tar.gz (136.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scspill-0.1.1-py3-none-any.whl (149.8 kB view details)

Uploaded Python 3

File details

Details for the file scspill-0.1.1.tar.gz.

File metadata

  • Download URL: scspill-0.1.1.tar.gz
  • Upload date:
  • Size: 136.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for scspill-0.1.1.tar.gz
Algorithm Hash digest
SHA256 546437908b86646958dbb6590dcce2a4e5b1ee310a0f44a4257b0ae4341c6c60
MD5 50e5405b57867a78adf0f26136e43377
BLAKE2b-256 ac913cb28b68473a3bf5cf3197446c207e4dc5cafbf8017bb274e86be36cf72c

See more details on using hashes here.

Provenance

The following attestation bundles were made for scspill-0.1.1.tar.gz:

Publisher: release.yml on quarcs-lab/scspill

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scspill-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: scspill-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 149.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for scspill-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 558b2b8cf55f1c1254b3598410658adde84fa876649e5db654564d050cd6ac81
MD5 5d9968dd60b6988cfb6b34581434ec40
BLAKE2b-256 7f7f7f941009a3d8d150f2e7efe7b3a84d2f82317c7eb2e819965d001f802eb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for scspill-0.1.1-py3-none-any.whl:

Publisher: release.yml on quarcs-lab/scspill

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page