Skip to main content

Dual bounds for model-agnostic inference

Project description

A python implementation of the dual bounds framework for inference on partially identified estimands (and the solutions to optimization problems more generally). See https://dualbounds.readthedocs.io/en/latest/ for detailed documentation and tutorials.

Installation

To install dualbounds, just use pip:

pip install dualbounds

Documentation

Documentation and tutorials are available at https://dualbounds.readthedocs.io/en/latest/.

Quickstart

Given a response vector y, binary treatment vector W, covariate matrix X, and an (optional) propensity score vector pis, dualbounds allows analysts to perform inference on partially identified estimands of the form E[f(Y(0), Y(1), X)], for any choice of f. For example, the code below shows how to perform inference in P(Y(0) < Y(1)), the proportion of individuals who benefit from the treatment. Dual bounds can wrap on top of any machine learning model to provide provably valid confidence intervals in randomized experiments.

	import dualbounds as db
	# Generate synthetic data from a heavy-tailed linear model
	data = db.gen_data.gen_regression_data(
		n=900, # Num. datapoints
		p=30, # Num. covariates
		r2=0.95, # population R^2
		tau=3, # average treatment effect
		interactions=True, # ensures treatment effect is heterogenous
		eps_dist='laplace', # heavy-tailed residuals
		sample_seed=123, # random seed
	)

	# Initialize dual bounds object
	dbnd = db.generic.DualBounds(
		f=lambda y0, y1, x: y0 < y1, # defines the estimand
		X=data['X'], # n x p covariate matrix
		W=data['W'], # n-length treatment vector
		y=data['y'], # n-length outcome vector
		pis=data['pis'], # n-length propensity scores (optional)
		Y_model='ridge', # description of model for Y | X, W
	)

	# Perform inference
	dbnd.compute_dual_bounds(
		nfolds=5, # number of cross-fitting folds
		alpha=0.05 # nominal level
	)

Reference

If you use dualbounds in an academic publication, please consider citing Ji, Lei, and Spector (2023). The bibtex is below:

@misc{ji2023modelagnostic,
      title={Model-Agnostic Covariate-Assisted Inference on Partially Identified Causal Effects}, 
      author={Wenlong Ji and Lihua Lei and Asher Spector},
      year={2023},
      eprint={2310.08115},
      archivePrefix={arXiv},
      primaryClass={econ.EM}
}

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

dualbounds-1.0.1.tar.gz (48.9 kB view details)

Uploaded Source

File details

Details for the file dualbounds-1.0.1.tar.gz.

File metadata

  • Download URL: dualbounds-1.0.1.tar.gz
  • Upload date:
  • Size: 48.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for dualbounds-1.0.1.tar.gz
Algorithm Hash digest
SHA256 dee1509d4559c3d40fb994915bca4d30ed8f902175db3adcf5a63e0130b26f80
MD5 a4065ec6291ff26a950a85feab0065da
BLAKE2b-256 069327a86e0772c59d5fa63961faee3eebd6c604c33f927f6d9ecd96946099a9

See more details on using hashes here.

Supported by

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