This release is a pre-release and may not be stable for production use.
qte — Quantile Treatment Effects in Python
Alpha software: the API may change without notice between releases.
This is an attempt at a Python implementation of the qte R package by Brantly Callaway from here.
The main features are:
- Availability of cross-sectional quantile treatment effects estimators (simple, inverse probability weighted, outcome regression, doubly robust) and non-linear difference-in-differences estimator (changes-in-changes and quantile difference-in-differences);
- Fast:
- as opposed to the R-package we can use highly optimized Numpy functions for computing weighted quantiles;
- quantile regression is magnitudes faster than in other Python packages since we use highly optimized Fortran code directly (falling back to statsmodels where the extension is unavailable);
- parallelism for bootstrapped standard errors;
- batching and vectorization in performance critical places;
- built natively on Polars;
- Beautiful: Graphs and tables for the console, the web, and latex powered by Altair, Great Tables and Rich.
Installation
Requires Python 3.12 or newer.
uv add py-qte
# or
pip install py-qte
Prebuilt wheels ship for Linux (x86_64) and macOS (Intel and Apple Silicon).
On those platforms quantile regression uses the bundled Fortran Frisch-Newton
solver. Everywhere else — including Windows — a pure-Python wheel falls back to
statsmodels for quantile regression: same
results to roughly 1e-5, but slower.
Building from source additionally needs a Fortran compiler (gfortran) and
BLAS/LAPACK development libraries. When they are missing, the build
automatically skips the extension and installs the pure-Python fallback.
Examples
Cross-Sectional Data
We can estimate quantile treatment (and average) treatment effects using an augmented inverse propensity score (AIPW) estimator .
from qte.cross_sectional import estimate_aipw_qte
from qte.datasets import load_lalonde
ds = load_lalonde()
res = estimate_aipw_qte(
ds=ds,
outcome_c="re78",
treatment_c="treat",
or_x_formular="age + education",
ps_x_formular="age + education",
)
print(res) # Rich table (not shown good for console)
res.plot() # Vega-Altair plot (see below)
res.tabulate() # Great Tables output (see below)
|
|
|
Non-Linear Difference-in-Differences
We can estimate quantile treatment (and average) treatment effects with the changes-in-changes estimator.
import polars as pl
from qte.non_linear_did.changes_in_changes import (
estimate_changes_in_changes_for_panel,
CounterfactualModel,
)
from qte.datasets import load_mpdta
ds = load_mpdta().with_columns(
pl.col("first.treat").replace(0, float("inf")).alias("first.treat"),
pl.col("year").cast(pl.Float64).alias("year"),
)
res = estimate_changes_in_changes_for_panel(
ds,
"lemp",
"first.treat",
"year",
"countyreal",
qs=[0.25, 0.5, 0.75],
counterfactual_model=CounterfactualModel.CIC,
)
|
|
|
Development
Regenerate the figures above after changing the estimators or their presentation:
uv run python -m docs.readme
Metadata
Release files for py-qte 0.1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_qte-0.1.0a1.tar.gz | 231.1 kB | Details |
Built distributions (wheels)
Total release size: 15.5 MB
Release files / py_qte-0.1.0a1.tar.gz
| Download URL | py_qte-0.1.0a1.tar.gz |
|---|---|
| Size | 231.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
026baf88bbd1e3e46f03ea4c8242c6c4fba94b3c5b0eeaad9840a2709b65ac43
|
|
BLAKE2b-256 checksum How to use checksums |
2a588c3e536c544bd2e376d4c4a14510679ad9295bb491c814982b07d7f109b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-py3-none-any.whl
| Download URL | py_qte-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 154.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b4f907e67333c98bad369a13875ecce16aa18e7b7225d88b48a0743df4af754
|
|
BLAKE2b-256 checksum How to use checksums |
8b5c611b502ca1104f79a958e9dde52cc7653d51315b740c665bf54c7b28c2e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | py_qte-0.1.0a1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4e186ac9df04a5724e7a668ddc012bae6639e6f5d5b1484f288382569957f3d2
|
|
BLAKE2b-256 checksum How to use checksums |
5607b4ba2aa4dde34301d6872465decc9e47dba8747ec41bb23a2bb100dff941
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | py_qte-0.1.0a1-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 177.3 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5463f6827eeaa31350d3376000621a176dd4d2128feeabef504a12f082bbc733
|
|
BLAKE2b-256 checksum How to use checksums |
e8916bb0b2ae48bd51f623455ede1a9a342ce8c7acf358c4c63463f15395c2e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | py_qte-0.1.0a1-cp314-cp314-macosx_10_15_x86_64.whl |
|---|---|
| Size | 178.4 kB |
| Tags | CPython 3.14 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
7b32dd52ecf12b9afa5fddff29cc15f09bdbbaf00d30fc7eb5627fe343d44786
|
|
BLAKE2b-256 checksum How to use checksums |
c119cbc295b0341dbbd2e33b573abbe1c47629c1292952bd2c57c6c855062232
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | py_qte-0.1.0a1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4db3aa827491a311d874339271a35268396c76449617326e41f6a880823fcfa2
|
|
BLAKE2b-256 checksum How to use checksums |
91741945adfa0b6d3bd36027465e9bfaf6f7754338f776d179c970fb558fd904
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | py_qte-0.1.0a1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 177.3 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1b4d3a9e29687d15f3d64a72d60af91b12fdce0757d437298e7832b4820d1a1e
|
|
BLAKE2b-256 checksum How to use checksums |
41cfffbb86dddba8e87a91ac85cac95923a2a32c53d603df896cafa72bb560d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | py_qte-0.1.0a1-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 178.3 kB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
c7b06bbeff60df626c0d1b6f2e90c7d7850e7ffad5397095d4d86e2cbcc535f7
|
|
BLAKE2b-256 checksum How to use checksums |
632663039c88f05353489433b59d6fd3205983452eb10e4ae095359e57c64db0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | py_qte-0.1.0a1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
19aed86a70432b5a03b4045e0104b58209071a428a9db3a1a28bef551ff7c134
|
|
BLAKE2b-256 checksum How to use checksums |
25c0714c2630c45a2e33138a7ea180ea5feeb0720ae1e4074ea892d95f41c205
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | py_qte-0.1.0a1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 177.3 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ce3d79537823d58e409d5c8a416bb9f5891842899c89ee92eaaced7043df147d
|
|
BLAKE2b-256 checksum How to use checksums |
b7b8f93bff3987b779d3b92cd1cdd74a50b35673432adfc37d8d38efb7ba0d7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / py_qte-0.1.0a1-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | py_qte-0.1.0a1-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 178.3 kB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
eea1c63e80ef176e08b8b15f0bc6b8678218cf98aa2d25c1e06f16b6b07a6acc
|
|
BLAKE2b-256 checksum How to use checksums |
ab215654ac0bff9ea2f714f3672642ea4256b5f4810ab1ef1d45b4654eb0af5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log