Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PySynthCon. All flavours of synthetic control in python. Ten estimators measure a simulated regional jobs programme with a known six-point employment gain, first with unaffected neighbours and then with four neighbours gaining three points.

PyPI beta Documentation Tests and documentation Python 3.10 and newer License GPL-3.0-only Purpose Research

Quick start · Six worked examples · Estimators · Documentation

PySynthCon lets you fit several synthetic controls to the same panel and see how the estimated effect changes with the method or donor pool. Compare held-out pretreatment predictions, refit after excluding donors, and put published benchmarks beside the estimates that reproduce them.

The header follows a simulated jobs programme. A district gains six employment-index points. How much of that gain can ten estimators recover if four neighbouring districts also benefit? Run the simulation · Compact jobs figure

Quick start

Install the 0.1 beta with Python 3.10 or newer. The distribution is pysynthcon and the Python import is pysynth.

python -m pip install "pysynthcon[plot]==0.1.0b5"

The header uses a simulated jobs programme with a known effect. For a real-data example, compare West Germany’s GDP per capita after reunification in 1990 with two estimates of its path without reunification. Outcome-matching synthetic control (SCM) and synthetic difference-in-differences (SDID) use the same GDP panel.

from pysynth import SyntheticControl, SyntheticDID, compare, plot_effects, save_figure
from pysynth.datasets import DATASETS, load_dataset

panel = DATASETS["germany"].panel(load_dataset("germany"))
fits = {"SCM": SyntheticControl().fit(panel), "SDID": SyntheticDID().fit(panel)}

print(compare(fits)[["att", "pre_rmse"]])
fig, axes = plot_effects(fits, ylabel="GDP gap per capita (current US$, PPP-adjusted)", xlabel="Year")
save_figure(fig, "outputs/custom/germany-effects")

The mean annual GDP gaps over 1990–2003 are −$1,297 per person with SCM and −$1,471 with SDID, in current US dollars adjusted for purchasing power parity. Each gap is observed GDP per capita minus the fitted counterfactual. The notebook also reconstructs the original study’s predictor-based specification. West Germany notebook · Interpreting SDID iteration-limit warnings

For your own data, Panel.from_frame takes unit, time and outcome columns, an explicit treatment date and an optional donor list. The treatment date is the first affected observation. Panels are balanced and use a common onset within each panel. ISC and 2SISC also accept case-specific panels and aggregate in event time. Prepare a panel

Six worked examples

Open the notebook What to look for
Simulation · a regional jobs programme The programme raises the treated district’s employment index by six points. Across 200 simulated economies, outcome SCM estimates 5.98 points with unaffected donors and 3.20 when neighbouring districts also benefit.
West Germany · reunification Rebuild the historical predictor specification and compare the GDP gap with the paper’s roughly US$1,600 annual loss per person (1990–2003, PPP-adjusted).
California · tobacco control Recover the published SDID effect of −15.6 packs per person and SE of 8.4. With the original tobacco predictors, both R Synth and the Python optimizer rank California first of 39. Allowing one state to be twice as likely to receive treatment puts the reassignment p-value between 0.013 and 0.050.
Basque Country · conflict Recover the published SCM donor weights for Catalonia (0.8508) and Madrid (0.1492), and compare the GDP path with the original R fit.
Kansas · tax cuts Match the authors’ ridge-augmented SCM vignette at −0.0401 log points and check all 16 quarterly effects.
Rhode Island · decriminalization of indoor sex work Test a six-year effect path against every cyclic shift in time. Reproduce the joint p-value of 0.04 and the six annual pointwise confidence sets for female gonorrhea incidence.

Four studies compare eleven estimators on a common panel. Rhode Island focuses on inference for outcome-matching SCM. All five empirical notebooks download hash-verified data into memory. Rhode Island and the main simulation run entirely in Python. The simulation generates its own data. Its optional ten-estimator header comparison also uses the local reference backends for SCUL and ISC. Figures are embedded in the notebooks. Executing them also writes PDF, SVG, PNG and numerical tables under outputs/empirical_examples/<study>/ or outputs/simulated_examples/donor_spillovers/. Reference targets and tolerances · Figure exports

git clone --branch v0.1.0b5 --depth 1 https://github.com/crahal/pysynthcon.git
cd pysynthcon
python -m pip install -e ".[notebooks]"
python scripts/execute_notebooks.py --examples rhode_island donor_spillovers

For all six notebooks, use Python 3.11 or 3.12, install the pinned replication requirements and provision the separately supplied local R reference bundle. SCUL and vanilla ISC use the original R backends. The California reassignment comparison also requires local R Synth 1.1-10 and the optional rpy2 bridge. Reproducing the California paper’s exact placebo sampling plan also uses the bundle. Once provisioned, python scripts/execute_notebooks.py runs all six. Local R setup

Estimators

Method Python interface What determines the counterfactual
Outcome-matching SCM SyntheticControl() Convex weights match the full pretreatment outcome path, with equal weight on each period. This is an outcome-only specification of classical SCM.
Predictor-based SCM PredictorSyntheticControl() Convex weights balance predictors. Their relative importance can be fitted against pretreatment outcomes. Abadie & Gardeazabal (2003) · Abadie, Diamond & Hainmueller (2010)
Ridge-augmented SCM AugmentedSyntheticControl() A ridge outcome model corrects residual imbalance. Donor weights can be negative. Ben-Michael, Feller & Rothstein (2021)
Penalized SCM PenalizedSyntheticControl(lambda_=0.01) A pairwise penalty discourages weight on donors far from the treated unit in predictor space. Abadie & L’Hour (2021)
Differenced SCM DifferencedSyntheticControl() Fit changes, then restore the average pretreatment level gap. The default uses zero pairwise penalty. Engelbrektson (2021), working paper
Robust SCM RobustSyntheticControl(lambda_=0.1, sv_count=3) Singular-value truncation denoises donor outcomes. Ridge weights fitted before treatment combine the denoised donor series. Amjad, Shah & Shen (2018)
SCUL SCUL() Lasso with rolling-origin tuning, signed weights and an intercept. Hollingsworth & Wing (2020)
Individual synthetic control IndividualSC() Fit each treated individual against the full eligible donor pool. Vagni & Breen (2021)
Two-stage individual synthetic control TwoStageIndividualSC(n_neighbors=10) Screen the nearest donors on pretreatment features, then fit SCM in that group. Petrillo et al. (2025)
Synthetic difference-in-differences SyntheticDID() Weight both donors and pretreatment periods. Arkhangelsky et al. (2021)
Difference-in-differences DifferenceInDifferences() The comparison baseline uses uniform weights across donors and pretreatment periods.

The penalty and rank values shown above are example choices. Use python -m pip install "pysynthcon[backends]==0.1.0b5" for predictor-based, augmented, penalized and differenced SCM and the default 2SISC fit. Method definitions and tuning · Implementation credits and backend details

Compare specifications

select_estimator scores each candidate on the same withheld pretreatment periods and refits the selected candidate on the full panel. donor_sensitivity refits after each donor exclusion. Pass named groups to examine a possible spillover region, as in the simulation.

from pysynth import donor_sensitivity, select_estimator

candidates = {"SCM": SyntheticControl, "SDID": SyntheticDID}
selection = select_estimator(panel, candidates, initial_window=20, horizon=4)
print(selection.validation.summary)
print(donor_sensitivity(panel, candidates).summary)

plot_comparison aligns ATT estimates with pretreatment RMSE, and plot_effects preserves a common outcome scale across methods. Both return editable Matplotlib figures. Evaluation guide · Plotting guide

Is the effect unusual across units or across time?

Use state reassignments when the comparison is across units. When the question concerns the timing of a particular effect path, impose that path on the treated outcome and compare its residuals across time. The methods make different assumptions. Inference guide

from pysynth import conformal_test
from pysynth.datasets import DATASETS, load_dataset

ri = DATASETS["rhode_island"].panel(load_dataset("rhode_island"))
test = conformal_test(ri, null_effect=0)
print(test.p_value)  # 0.04: one of 25 cyclic windows is at least as extreme
print(test.rotations.nlargest(3, "statistic"))

The Rhode Island notebook also tests each annual effect on the authors’ full grid. The spillover simulation applies the same sharp-path test to a known treatment effect and measures what happens when donors themselves respond to treatment. Rhode Island replication · Spillover experiment

Documentation

The full manual on Read the Docs includes the statistical methods, inference conventions, API and worked examples. The versioned documentation sources accompany the beta.

Authors · Charles Rahal, Anda Raluca Epure, and Daniel Valdenegro.

When publishing, cite PySynthCon together with the method papers and upstream packages used in your analysis. Software citation · Method references

Metadata

Release files for pysynthcon 0.1.0b5

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

Source distribution (sdist)

Source distribution for pysynthcon 0.1.0b5
File Size Uploaded Provenance Actions
pysynthcon-0.1.0b5.tar.gz 4.1 MB With provenance Details for pysynthcon-0.1.0b5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysynthcon 0.1.0b5
File Interpreter ABI Platform Actions
pysynthcon-0.1.0b5-py3-none-any.whl Python 3 none any Details for pysynthcon-0.1.0b5-py3-none-any.whl

Total release size: 4.8 MB

Release files / pysynthcon-0.1.0b5.tar.gz

Download URL pysynthcon-0.1.0b5.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
2cae803e09e4561f0a9952bd68f59cad74670e308e3ea366878872a2328e1635
BLAKE2b-256 checksum
How to use checksums
bd184c9fb15446f9f2394fa042724f23e7170cb19888314cd4f5a7241df60f5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 29, 2026.

Transparency log

Release files / pysynthcon-0.1.0b5-py3-none-any.whl

Download URL pysynthcon-0.1.0b5-py3-none-any.whl
Size 726.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78a67542bded75a2a17bf9c11e7b0b86fba669391e873d679da9f48d6387b18f
BLAKE2b-256 checksum
How to use checksums
f25fa9263b744081ee14c7ab5da41908b407d391ef3e70da10522bb9ff2c966b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 29, 2026.

Transparency log

Security for pysynthcon 0.1.0b5

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pysynthcon-0.1.0b5.tar.gz

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 Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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