Metadata-Version: 2.4
Name: pdslasso
Version: 0.1.2
Summary: Post-double-selection LASSO for treatment effects with high-dimensional controls
Author: Ralf Bloechlinger
License: MIT License
        
        Copyright (c) 2025 Ralf Blochlinger
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS 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 THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/ralfblochlinger/post-double-selection-lasso
Project-URL: Repository, https://github.com/ralfblochlinger/post-double-selection-lasso
Project-URL: Issues, https://github.com/ralfblochlinger/post-double-selection-lasso/issues
Keywords: lasso,econometrics,causal-inference,treatment-effects,high-dimensional-data
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: scikit-learn
Requires-Dist: statsmodels
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# 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

```bash
pip install pdslasso
```

Or install from source:

```bash
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)

```python
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

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