pymte
Instrumental variables and marginal treatment effects in Python.
Documentation: https://pymte.readthedocs.io
pymte estimates treatment parameters such as the ATE, ATT or a policy relevant treatment effect from instrumental variables data, using the marginal treatment effect (MTE) framework of Heckman and Vytlacil (2005) and the moment-based implementation of Mogstad, Santos and Torgovitsky (2018). The user specifies parametric or nonparametric (spline) marginal treatment response functions, optional shape restrictions such as boundedness or monotonicity, and a set of IV-like estimands. The package returns either a point estimate (when the model is point identified) or sharp bounds obtained by linear or quadratically constrained programming, together with bootstrap confidence intervals and specification tests.
This package is a port of the R package ivmte by Joshua Shea and Alexander Torgovitsky, released under the GPL-3. It reproduces the R package's estimands, options and numerical results; the API follows Python conventions.
Installation
pip install pymte
Linear programs are solved with HiGHS (through SciPy) and quadratically constrained programs with Clarabel (through CVXPY); both are installed automatically. MOSEK and Gurobi can be used instead when licensed:
pip install "pymte[mosek]"
pip install "pymte[gurobi]"
pip install "pymte[plots]" # matplotlib for plot_mtr, plot_mte, plot_weights
Quick start
import pymte
ae = pymte.load_ae()
r = pymte.ivmte(
ae,
target="att",
m0="~ u + yob",
m1="~ u + yob",
ivlike="worked ~ morekids + samesex + morekids*samesex",
propensity="morekids ~ samesex + yob",
)
print(r)
Bounds on the target parameter: [-0.1028836, -0.07818869]
Audit terminated successfully after 1 round(s)
MTR coefficients: 6
Independent/total moments: 4/4
Minimum criterion: 0
Solver: highs
Add bootstraps=50 for confidence regions, point=True for GMM when the model is point identified, or replace ivlike with outcome="worked" for the regression approach.
The full user guide, a theory primer and the API reference are on Read the Docs.
Contributing
pymte is a new project. If you find a bug, want a feature, see a way to make something faster, or have an application that the package does not yet cover, open an issue or a pull request on GitHub. Small fixes, new examples, and documentation improvements are as welcome as new estimators. If you would prefer to talk first, or want to discuss a larger piece of work, email me at alex.ronczewski@gmail.com.
Citing
If you use this package, please cite the papers that developed the methodology:
- Mogstad, M., A. Santos and A. Torgovitsky (2018). Using Instrumental Variables for Inference About Policy Relevant Treatment Parameters. Econometrica 86(5), 1589-1619. doi:10.3982/ECTA15463.
- Shea, J. and A. Torgovitsky (2023). ivmte: An R Package for Extrapolating Instrumental Variable Estimates Away From Compliers. Observational Studies 9(2), 1-42.
- Heckman, J. J. and E. Vytlacil (2005). Structural Equations, Treatment Effects, and Econometric Policy Evaluation. Econometrica 73(3), 669-738.
- Mogstad, M. and A. Torgovitsky (2018). Identification and Extrapolation of Causal Effects with Instrumental Variables. Annual Review of Economics 10, 577-613.
BibTeX entries are in the documentation under "Citing". The AE dataset is derived from Angrist and Evans (1998), American Economic Review 88(3).
Licence
GPL-3.0-only. This package is a derivative work of the R package ivmte, Copyright (C) 2018-2024 Joshua Shea and Alexander Torgovitsky, which its authors distribute under GPL-2 or GPL-3; this port takes it under version 3 and is distributed under the same version. See LICENSE for the licence text and NOTICE for the copyright notices.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymte-1.0.1.tar.gz.
File metadata
- Download URL: pymte-1.0.1.tar.gz
- Upload date:
- Size: 658.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2a73249951ba88c0ba9c21eba0e2869ba6687c2eaea12207ab253df8807fae5
|
|
| MD5 |
037ef4b7285ab6152e8feaedab1604d9
|
|
| BLAKE2b-256 |
956cabd8eda009382a28d8fdb15d71a777c6336d1c15b0a1003f5d6649342feb
|
Provenance
The following attestation bundles were made for pymte-1.0.1.tar.gz:
Publisher:
release.yml on Alexr951/pymte
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymte-1.0.1.tar.gz -
Subject digest:
a2a73249951ba88c0ba9c21eba0e2869ba6687c2eaea12207ab253df8807fae5 - Sigstore transparency entry: 2823959048
- Sigstore integration time:
-
Permalink:
Alexr951/pymte@00c36da8dc0e1f14439c45c76f1fabba3db3cc60 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Alexr951
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@00c36da8dc0e1f14439c45c76f1fabba3db3cc60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymte-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pymte-1.0.1-py3-none-any.whl
- Upload date:
- Size: 521.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
018e57eea205ff8ed0b839a719ee29031b65220f1a25ca7dad37de3c17f1df64
|
|
| MD5 |
11251bfc18fccd44e9e1ec2e7129cd7e
|
|
| BLAKE2b-256 |
60b796e2e72f227d7c4978d71cc67d9d3eb6c7e52eda5970756c72b2a29cdd53
|
Provenance
The following attestation bundles were made for pymte-1.0.1-py3-none-any.whl:
Publisher:
release.yml on Alexr951/pymte
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymte-1.0.1-py3-none-any.whl -
Subject digest:
018e57eea205ff8ed0b839a719ee29031b65220f1a25ca7dad37de3c17f1df64 - Sigstore transparency entry: 2823959342
- Sigstore integration time:
-
Permalink:
Alexr951/pymte@00c36da8dc0e1f14439c45c76f1fabba3db3cc60 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Alexr951
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@00c36da8dc0e1f14439c45c76f1fabba3db3cc60 -
Trigger Event:
push
-
Statement type: