Skip to main content

EpiPyLab

EpiPyLab is a computational epidemiology framework for Python.

The package provides epidemiology-focused tools for mortality, morbidity, descriptive and analytic epidemiology, measures of association, precision and uncertainty, validity and diagnostic performance, stratified analysis, regression, survival and competing-risks analysis, complex survey analysis, surveillance, pharmacoepidemiology, sample-size planning, data preparation, machine learning, visualization, interpretation, teaching, publication-oriented workflows, and causal inference.

Package status

Version 0.2.4 is an alpha release. It adds the epipylab.causal subpackage to the existing EpiPyLab distribution.

Installation

The distribution name and Python import package are both epipylab.

pip install epipylab
import epipylab
print(epipylab.__version__)

There is no separate epipylab-causal distribution. Causal methods are imported from epipylab.causal.

Causal inference (epipylab.causal)

epipylab.causal is a time-fixed binary-treatment causal-inference subpackage. Numerical estimation does not establish causal identification. Observational causal interpretation depends on identification assumptions that the analyst states; the software does not empirically prove them.

The public API is:

  • estimands: average_treatment_effect, average_treatment_effect_treated, average_treatment_effect_controls
  • identification records: observational_assumptions, randomized_assumptions
  • result helpers: causal_result, format_causal_result, validate_binary_treatment, validate_binary_outcome
  • algebraic contrasts of supplied means: causal_difference, causal_ratio, causal_odds_ratio, causal_effect_from_means
  • parametric g-formula / standardization: g_formula
  • propensity-score estimation: propensity_score
  • IPTW: iptw
  • 1:1 greedy nearest-neighbor propensity-score matching: propensity_score_matching
  • standardized mean differences: standardized_mean_differences
  • causal diagnostics: causal_diagnostics
  • AIPW: aipw
  • TMLE: tmle
  • bootstrap inference: bootstrap_inference

Estimand constructors name ATE, ATT, or ATC targets; they do not estimate effects from data. Algebraic contrast functions require already targeted mu1 and mu0. propensity_score estimates an assignment probability; it is not itself an effect estimator. standardized_mean_differences and causal_diagnostics summarize observed data and do not return a treatment effect. bootstrap_inference wraps a supplied estimator; it is not a causal method of its own.

g_formula and iptw support ATE, ATT, and ATC. Matching estimates ATT only. AIPW and TMLE estimate ATE only.

import pandas as pd
from epipylab.causal import (
    observational_assumptions,
    g_formula,
)

data = pd.DataFrame(
    {
        "A": [0, 0, 0, 0, 1, 1, 1, 1],
        "Y": [1.0, 2.0, 1.5, 2.5, 3.0, 4.0, 3.5, 5.0],
        "X": [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0],
    }
)

assumptions = observational_assumptions(
    treatment="A",
    outcome="Y",
    covariates=["X"],
)

result = g_formula(
    data=data,
    treatment="A",
    outcome="Y",
    outcome_type="continuous",
    covariates=["X"],
    estimand="ATE",
    scale="difference",
    identification_assumptions=assumptions,
)

print(result["estimate"])
print(result["causal_language"])

result["causal_language"] is True only because an identification record was attached. That flag does not mean the assumptions were verified.

Limitations

  • Observational causal interpretation depends on stated identification assumptions and is not proven by a fitted estimate, measured-covariate balance, overlap summaries, or a bootstrap interval.
  • Matching is ATT-only. If treated units remain unmatched, the contrast is among the matched treated subset and their matched controls; it is not automatically the ATT for the entire original treated population and is not relabeled as ATE.
  • AIPW and TMLE are ATE-only.
  • This implementation does not cross-fit, does not use Super Learner, and is not CV-TMLE.
  • Propensity scores and weights are not automatically clipped or trimmed.
  • AIPW and TMLE do not provide an analytic standard error or confidence interval in this release.
  • Bootstrap inference is available separately through bootstrap_inference. It does not upgrade causal_language and does not add cross-fitting, Super Learner, CV-TMLE, or analytic influence-curve inference.
  • g_formula is a time-fixed parametric g-formula / standardization estimator, not a longitudinal g-formula.

Author

Shams Rahman
Email: shams16@gmail.com

License

EpiPyLab is released under the MIT License.

Copyright (c) 2026 Shams Rahman

Metadata

Release files for epipylab 0.2.4

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

Source distribution (sdist)

Source distribution for epipylab 0.2.4
File Size Uploaded
epipylab-0.2.4.tar.gz 229.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for epipylab 0.2.4
File Interpreter ABI Platform
epipylab-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 517.4 kB

Release files / epipylab-0.2.4.tar.gz

Download URL epipylab-0.2.4.tar.gz
Size 229.5 kB
Tags Source
SHA-256 checksum
How to use checksums
841700477ff7be74924b03d03a6c59d645bc96bbffa49d9ff751d6d0419278bb
BLAKE2b-256 checksum
How to use checksums
b57cfa610bce1e66763e8fcb51238ab08eab4ceb46dc3d4a37f6d8fe8dfa2167
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / epipylab-0.2.4-py3-none-any.whl

Download URL epipylab-0.2.4-py3-none-any.whl
Size 287.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbc8cd0d6a458c2f6e3cecbdbd08c78b87dcdaa951022c8f6ff0d2c5770b2a62
BLAKE2b-256 checksum
How to use checksums
bc052a590629cb35ad8b4ace468c2cc1e58258d5903e605571e1041194195083
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

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