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.1.tar.gz (17.4 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.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdslasso-0.1.1.tar.gz
  • Upload date:
  • Size: 17.4 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.1.tar.gz
Algorithm Hash digest
SHA256 e1a8643d4c14a2f34f57d85b6c9fc6bcea36242e04e66535459b4aa7efa049b2
MD5 b46739ade2e0364bef94a2bdc9516313
BLAKE2b-256 f0d5d1e08295b3dd4660bf0d421945f600b2c99b00dc362f8c7d6bf045eebdb4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pdslasso-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ddfa2c8863310c13180f40674c7641b9bb113734afd45d48fc7df2610d78be1c
MD5 30517a206919125f6ab3808b6598a29e
BLAKE2b-256 67a5160c855769b7cec28329e48230f058c899b4ce014af3c5eaf30dab91e4e4

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