Skip to main content

Post-double-selection LASSO for treatment effects with high-dimensional controls

Project description

pds-lasso

A simple Python implementation of the post-double selection LASSO estimator for treatment effects with high-dimensional controls, as proposed by Belloni, Chernozhukov, and Hansen (2014).

Features

  • Post-double selection LASSO for partially linear models with a minimal class-based interface
  • Feasible Lasso with optimal penalty loadings (default) as described in Belloni, Chernozhukov, and Hansen (2014)
  • Uses Lasso or LassoCV from scikit-learn for the two selection steps
  • Penalty level based on the parametric choice in BCH (2014) by default, with optional cross-validation
  • Uses statsmodels.api.OLS for the final unpenalized regression with HC1 robust standard errors
  • Supports partialling out of fixed effects (as categorical variables) and always-included controls

Installation

pip install pdslasso

Or install from source:

git clone https://github.com/ralfblochlinger/post-double-selection-lasso.git
cd post-double-selection-lasso
pip install -e .

Requirements

  • pandas
  • numpy
  • scikit-learn
  • statsmodels

Usage (minimal example)

from pdslasso import PDSLasso

df = pd.read_csv("mydata.csv")

model = PDSLasso(
    data=df,
    y="outcome_var",
    d="treatment_var",
    control_cols=["x1", "x2", "x3", "x4"],
)

results = model.fit()

print("Selected controls:", model.selected_controls)
print(results.summary())

Options

model = PDSLasso(
    data=df,
    y="outcome_var",
    d="treatment_var",
    control_cols=["x1", "x2", "x3", "x4"],
    control_always_include=["x1"],       # Controls always included (not penalized)
    fixed_effect_col="group",            # Fixed effects (partialled out)
    lasso_penalty_cv=False,              # Use parametric penalty (default) or CV
    penalty_c=1.1,                       # Constant for parametric penalty
    penalty_gamma=0.05,                  # Significance level for parametric penalty
)

Remarks / Disclaimer

This repository is a basic personal implementation of post-double selection LASSO, shared in case it is useful to other researchers:

  • It is not a production-ready econometrics package.
  • No guarantees are made about correctness, numerical stability, or suitability for any particular empirical setting.
  • Results may differ from reference implementations (e.g. pdslasso in Stata or hdm in R)

Citation

If you use this code in academic work, please cite the original methodological paper:

Alexandre Belloni, Victor Chernozhukov, Christian Hansen, Inference on Treatment Effects after Selection among High-Dimensional Controls, The Review of Economic Studies, Volume 81, Issue 2, April 2014, Pages 608-650, https://doi.org/10.1093/restud/rdt044

No warranty / no liability

This software is provided "as is", without any express or implied warranty. In no event shall the author be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or its use.

By using this code, you agree that you are responsible for verifying its suitability for your use case and for checking your results.

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

pdslasso-0.1.2.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

pdslasso-0.1.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file pdslasso-0.1.2.tar.gz.

File metadata

  • Download URL: pdslasso-0.1.2.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pdslasso-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4ba963656a18d558b6e35e136361ff0b266e0c54b3da1634087545fc55390c09
MD5 326487a572621a858fe12da4642df2b3
BLAKE2b-256 2f3f052d8bb858f909cc83c409540c0bfc05e0532600fde78027a0b3c9bb2c2c

See more details on using hashes here.

File details

Details for the file pdslasso-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pdslasso-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pdslasso-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 664dc9334ada8eae4204f81bd39cc1207f545905fd30c768c26b1d660a98a399
MD5 f4e89f2b80a28bcb50f158120515ef21
BLAKE2b-256 8e18d4cb22965ee34a20d5f938ccafc01d544803b2d2bfc95b08e9ea207f0299

See more details on using hashes here.

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