Skip to main content

dpd-stream

Arellano–Bond (difference) and Blundell–Bond (system) GMM for dynamic panels, out of core. One-step, two-step or iterated estimation with flexible instrument sets, Windmeijer-corrected and clustered inference, specification and identification tests, Ahn–Schmidt nonlinear moments and absorbed fixed effects. It works on data far larger than memory, and is much faster than the existing implementations on large panels. Where conventions differ, it follows Stata's xtabond2, and its results are tested against xtabond2, xtdpdgmm and other implementations.

from dpd_stream import dpd_stream

fit = dpd_stream("n ~ l(n, 1) + w + k | year | gmm(n, 2:4) + gmm(w + k, 1:3)",
                 "firms/*.parquet", panel=("firm", "year"), system=True)
fit.summary()

What it does

Estimators

  • Difference or system GMM: one-step, two-step (Windmeijer-corrected) or iterated.
  • First differences or forward orthogonal deviations.

Instruments

  • Lag limits, collapse, eq, split, passthru, orthogonal, mz, h(), pca.

Tests and inference

  • Arellano–Bond AR(m), Sargan, Hansen, difference-in-Hansen.
  • Clustering, one- and multi-way.
  • small-sample statistics.
  • Weights.

Also

  • Iterated GMM.
  • MMSC model selection.
  • Long-run effects.
  • Kleibergen–Paap and Sanderson–Windmeijer identification tests (ivreg2's forms; they differ in the digits from Stata's underid).
  • Ahn–Schmidt nonlinear moments (xtdpdgmm's nl()).
  • Absorbed time effects, and absorbed period-by-group effects in difference GMM.

Interface

  • pyfixest-style formulas with fixest's l()/f()/d() lag operators.
  • Results with hdfe-stream's reporting: summary(), tidy(), etable, wald_test(), summary_json().

Why it is fast

Everything linear GMM needs is a sum over panels: Z′X, Z′y, Σ Zᵢ′HZᵢ, and Σ gᵢgᵢ′ with gᵢ = Zᵢ′eᵢ.

  • One read of the source. The data are read once into blocks of whole panels, sorted by time.
  • No instrument matrix. Each pass is a numba kernel that builds every panel's rows and its sparse instruments and adds them into those sums. No instrument matrix is ever built.
  • Three passes in all give two-step estimates with Windmeijer's correction and the Arellano–Bond tests.

The other implementations instead hold every panel's dense instrument matrix: xtabond2, xtdpdgmm, plm, pdynmc and pydynpd.

Performance

Two-step GMM with Windmeijer-corrected standard errors on simulated panels of 8 periods, on an EC2 spot instance (16 vCPUs, 32 GiB):

Panels (rows) dpd-stream pydynpd plm pgmm pdynmc
100,000 (800,000) difference GMM 0.6 s, 1.3 GB 15 s, 1.0 GB 72 s, 5.2 GB > 1,800 s
1,000,000 (8 million) difference GMM 5.7 s, 1.6 GB 158 s, 7.7 GB out of memory —
1,000,000 (8 million) system GMM 5.3 s, 1.6 GB 159 s, 8.2 GB 799 s, 26 GB —
10,000,000 (80 million) system GMM 80 s, 9.7 GB out of memory out of memory —

Estimates agree to about 1e-13 (system GMM: with pydynpd; plm and pdynmc enter the year effects differently). With uncollapsed instruments over 20 periods (5,000 panels), dpd-stream takes 0.24 s; pydynpd, plm and pdynmc take 24, 47 and 441 s, and at 30 periods plm and pdynmc run out of memory. systemgmmkit, which builds collapsed instruments only, takes 500 s at 100,000 panels. See the benchmarks in the documentation.

Install

pip install dpd-stream

Python 3.10 or later. On Python 3.15, pyfixest 0.60 (which hdfe-stream's formula extra brings in) has no wheels yet: it builds from source with a Rust toolchain and PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 set; everything else installs from wheels.

Documentation

The documentation is at https://leetucker.github.io/dpd-stream/. Build it locally with:

pip install -e ".[docs]"
sphinx-build -W --keep-going -b html docs docs/_build/html

examples/ has runnable scripts, and benchmarks/ the performance comparisons (see benchmarks/README.md).

License

MIT.

Metadata

Release files for dpd-stream 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dpd-stream 0.2.1
File Size Uploaded Provenance Actions
dpd_stream-0.2.1.tar.gz 102.3 kB With provenance Details for dpd_stream-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dpd-stream 0.2.1
File Interpreter ABI Platform Actions
dpd_stream-0.2.1-py3-none-any.whl Python 3 none any Details for dpd_stream-0.2.1-py3-none-any.whl

Total release size: 188.1 kB

Release files / dpd_stream-0.2.1.tar.gz

Download URL dpd_stream-0.2.1.tar.gz
Size 102.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2e9515e773efa58bbe536bf9a0c778d962ddd94fd6c3e696b2a3161663559369
BLAKE2b-256 checksum
How to use checksums
b385eae2f1223108a7ba1c5c1e8a4568a37cdd1eb39a75965b785e86cf15d93a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 5, 2026.

Transparency log

Release files / dpd_stream-0.2.1-py3-none-any.whl

Download URL dpd_stream-0.2.1-py3-none-any.whl
Size 85.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c50e2f830514ca9e51ca4e98128576c4618c99d76c13b9dcc71e6896238f71cb
BLAKE2b-256 checksum
How to use checksums
dbbbb0196eab8046b28742bdaf261f2b06d22dccfa9987c6ebe60700b1f34e53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 5, 2026.

Transparency log

Security for dpd-stream 0.2.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dpd_stream-0.2.1.tar.gz

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 Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page