Skip to main content

Specification Curve

Specification Curve is a Python package that performs specification curve analysis; it helps with the problem of the "garden of forking paths" (many defensible choices) when doing analysis by running many regressions and summarising the estimated coefficients in an easy to digest chart. Estimation is done by pyfixest, so specifications can vary the outcome, the regressor of interest, controls, fixed effects, instruments, standard errors, weights, the sample and the estimator (OLS, Poisson, logit, probit and quantile regression).

PyPI Status Python Version License Read the documentation at https://aeturrell.github.io/specification_curve/ Tests Codecov Ruff pre-commit Google Colab DOI Downloads

Linux macOS Windows

Source

Go to the full documentation for Specification Curve.

Quickstart

import specification_curve as sc

df = sc.load_example_panel()  # a made-up panel of firms
sco = sc.SpecificationCurve(
    df,
    y="log(sales)",
    x="treated",
    controls=["size", "leverage", "rd"],
    fe=[None, "firm", "firm + year"],
    vcov=["hetero", {"CRV1": "firm"}],
)
sco.fit()
sco.plot()

A specification curve: the estimated effect of treatment across 48 specifications, with panels showing the controls, fixed effects and standard errors each one uses

Each column is one specification. Here the true effect is 0.3, and the specifications without firm fixed effects overstate it. The estimates are in sco.results, one row per specification.

The same specifications can be written as a pyfixest formula, with comb0() standing for every combination of its terms:

sco = sc.SpecificationCurve(
    df,
    "log(sales) ~ treated + comb0(size, leverage, rd) | sw0(firm, firm + year)",
    x="treated",
    vcov=["hetero", {"CRV1": "firm"}],
)

Installation

You can install Specification Curve via uv:

uv add specification-curve

To install the development version from git, use:

pip install git+https://github.com/aeturrell/specification_curve.git

Citing Specification Curve

You can find full citation information at the following link: https://zenodo.org/badge/latestdoi/282989537.

Using Specification Curve in your paper? Let us know by raising an issue beginning with "citation".

License

Distributed under the terms of the MIT license.

Similar Packages

In RStats, there is specr (which inspired many design choices in this package) and spec_chart. Some of the example data in this package is the same as in specr, but please note that results have not been cross-checked across packages.

Metadata

Release files for specification-curve 0.4.0

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

Source distribution (sdist)

Source distribution for specification-curve 0.4.0
File Size Uploaded Provenance Actions
specification_curve-0.4.0.tar.gz 303.9 kB Without provenance Details for specification_curve-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for specification-curve 0.4.0
File Interpreter ABI Platform Actions
specification_curve-0.4.0-py3-none-any.whl Python 3 none any Details for specification_curve-0.4.0-py3-none-any.whl

Total release size: 371.5 kB

Release files / specification_curve-0.4.0.tar.gz

Download URL specification_curve-0.4.0.tar.gz
Size 303.9 kB
Tags Source
SHA-256 checksum
How to use checksums
73222b95f989c49041c1d7de737cf165ea91466d8cec07c49bdb467641862313
BLAKE2b-256 checksum
How to use checksums
3b04076e1cbace2aef6817a79a2190f48017be4606e63b8c6ff62705d6834854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / specification_curve-0.4.0-py3-none-any.whl

Download URL specification_curve-0.4.0-py3-none-any.whl
Size 67.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c14f8b7e60ebbde008f92d1f93cc565bcac9d32dd55d31ddc4b1411f7bf73dd
BLAKE2b-256 checksum
How to use checksums
be4369c05a861de629452cdcf3b0e73568500223546d4fa25050f788352abbe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for specification-curve 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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