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



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()

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