Skip to content

About

Specification Curve is a Python package that performs specification curve analysis: exploring how a coefficient varies under multiple different specifications of a statistical model.

Topics

Resources

Stars

33 stars

Watchers

2 watching

Forks

Repository files navigation

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 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.

About

Specification Curve is a Python package that performs specification curve analysis: exploring how a coefficient varies under multiple different specifications of a statistical model.

Topics

Resources

Stars

33 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages