Skip to main content

A library for estimates of causal effects.

Project description

CausalEstimate

Unittests Lint using flake8 Formatting using black


CausalEstimate is a Python tool designed to produce causal estimates from propensity scores. It provides functionalities for matching, weighting, and other causal inference techniques, helping researchers and data scientists derive meaningful insights from observational data.


Features

  • Propensity score matching and weighting
  • Tools for average treatment effect (ATE) estimation
  • Easy integration with pandas DataFrames
  • Bootstrap standard error estimation

Installation

To install the required dependencies, run:

pip install -r requirements.txt

Usage

Example: Matching

Here is an example of how to use the matching functionality in a Jupyter notebook:

import numpy as np
import pandas as pd
from CausalEstimate.matching import match_optimal

# Simulate data
ps = np.array([0.3, 0.90, 0.5, 0.34, 0.351, 0.32, 0.35, 0.81, 0.79, 0.77, 0.90, 0.6, 0.52, 0.55])
treated = np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
ids = np.array([101, 102, 103, 103, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211])

df = pd.DataFrame({
    'PID': ids,
    'treatment': treated,
    'ps': ps
})

# Perform matching
result = match_optimal(df, n_controls=3, caliper=0.1)
print(result)

Development

Running Tests

To run the unit tests, use the following command:

python -m unittest

Linting

To lint the code using flake8, run:

pip install flake8
flake8 CausalEstimate tests

Formatting

To format the code using black, run:

pip install black
black CausalEstimate tests

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causalestimate-0.1.2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CausalEstimate-0.1.2-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file causalestimate-0.1.2.tar.gz.

File metadata

  • Download URL: causalestimate-0.1.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for causalestimate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1da78620abf0be194cd9dfd881f791554dd1e515f8b20718424c15de5c0a4749
MD5 8fe38b6889d9ee31c2cac623a39357b9
BLAKE2b-256 14fdca5c8970ba4a7c3e530699c45e2228683fe9916924f4a9062688f81d6482

See more details on using hashes here.

File details

Details for the file CausalEstimate-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: CausalEstimate-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for CausalEstimate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b2cf33ec7cd75468679e002030186f86cae62fd6c4a78b8a036b3499c5f1c8f
MD5 218750ba05cc72cdcc7d9bade1abe078
BLAKE2b-256 7fa3174c08f8a635c03a90bbf1c667ab13d73993fef3f4bf6b0b68381a30ce68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page