{"id":34983803,"url":"https://github.com/jaabmar/confounder-lower-bound","last_synced_at":"2026-03-15T21:44:26.227Z","repository":{"id":214648779,"uuid":"717129489","full_name":"jaabmar/confounder-lower-bound","owner":"jaabmar","description":"Implementation for the paper \"Hidden yet quantifiable: A lower bound for confounding strength using randomized trials\"","archived":false,"fork":false,"pushed_at":"2025-04-28T07:34:18.000Z","size":1356,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-28T08:32:55.887Z","etag":null,"topics":["causal-inference","causality","epidemiology","healthcare","hidden-confounding","observational-study","postmarketing","randomized-trial","sensitivity-analysis"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2312.03871","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaabmar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-10T16:14:52.000Z","updated_at":"2025-04-28T07:34:22.000Z","dependencies_parsed_at":"2023-12-29T16:41:27.241Z","dependency_job_id":"707888f3-7d76-4e82-a9e4-e5108c6de17b","html_url":"https://github.com/jaabmar/confounder-lower-bound","commit_stats":null,"previous_names":["jaabmar/confounder-lower-bound"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jaabmar/confounder-lower-bound","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaabmar%2Fconfounder-lower-bound","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaabmar%2Fconfounder-lower-bound/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaabmar%2Fconfounder-lower-bound/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaabmar%2Fconfounder-lower-bound/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaabmar","download_url":"https://codeload.github.com/jaabmar/confounder-lower-bound/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaabmar%2Fconfounder-lower-bound/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28067237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["causal-inference","causality","epidemiology","healthcare","hidden-confounding","observational-study","postmarketing","randomized-trial","sensitivity-analysis"],"created_at":"2025-12-27T01:11:06.132Z","updated_at":"2026-03-15T21:44:26.221Z","avatar_url":"https://github.com/jaabmar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testing for Hidden Confounding in Observational Studies\n\n[![arXiv](https://img.shields.io/badge/stat.ML-arXiv%3A2312.03871-B31B1B.svg)](https://arxiv.org/abs/2312.03871)\n[![Python 3.11.5](https://img.shields.io/badge/python-3.11.5-blue.svg)](https://python.org/downloads/release/python-3115/)\n[![Pytorch 2.0.1](https://img.shields.io/badge/pytorch-2.0.1-green.svg)](https://pytorch.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Python Tests](https://github.com/jaabmar/confounder-lower-bound/actions/workflows/python-tests.yml/badge.svg)](https://github.com/jaabmar/confounder-lower-bound/actions/workflows/python-tests.yml)\n\nThis repository contains the Python implementation of the **AISTATS 2024 paper** [Hidden yet quantifiable: A lower bound for confounding strength using randomized trials](https://arxiv.org/abs/2312.03871).\n\n* [Overview](#overview)\n* [Getting Started](#getting-started)\n* [Usage](#usage)\n* [Contributing](#contributing)\n* [License](#license)\n* [Contact](#contact)\n* [Citation](#citation)\n\n## Overview\n\nThis repository implements the methods from the paper \"Hidden yet quantifiable: A lower bound for confounding strength using randomized trials.\" The tools are designed for researchers in the field of epidemiology, enabling them to identify and lower bound the impact of unobserved confounding in observational studies. Unobserved confounders are variables that are not measured or accounted for in a study but can significantly influence its outcomes, leading to biased results.\n\nOur approach consists of two components:\n\n1. **Statistical Test**: Our framework includes two statistical tests to detect the presence of unobserved confounding with strength above a given threshold. \n\n2. **Lower Bound Estimation**: This tool estimates a lower bound for the strength of unobserved confounding. This is key for distinguishing between _weak_ and _strong_ unobserved confounding. Establishing a lower bound helps understand how unobserved confounding might alter the study's conclusions, enabling practitioners to proactively reduce its impact.\n\n\nOur tool becomes particularly useful in drug regulation and post-marketing surveillance, where researchers often have access to data from randomized trials and observational studies. It allows for a more rigorous analysis of the treatment's effectiveness and safety by quantifying the potential biases due to unobserved confounders.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"motivating_example.png\" alt=\"An illustrative example of the drug regulatory process: our lower bound allows taking proactive measures to address the unobserved confounding problem.\"/\u003e\n\u003c/p\u003e\n\nAs depicted in the image above, applying our methodology in the drug regulatory process enables a more informed and accurate assessment of medical treatments. By providing a way to quantify the influence of unobserved confounders, our tool aids in refining the conclusions drawn from observational studies.\n\n## Getting Started\n\n### Dependencies\n\n- Python 3.11.5\n- Numpy 1.24.3\n- Scipy 1.10.1\n- Scikit-learn 1.3.0\n- Pandas 1.5.3\n- XGBoost 1.7.3\n- Scikit-uplift 0.5.1\n- Quantile-forest 1.2.0\n- Torch 2.0.1\n- CVXPY 1.3.1\n\n### Installation\n\nTo set up your environment and install the package, follow these steps:\n\n#### Create and Activate a Conda Environment\n\nStart by creating a Conda environment with Python 3.11.5. This step ensures your package runs in an environment with the correct Python version. \n```bash\nconda create -n myenv python=3.11.5\nconda activate myenv\n```\n#### Install the Package\n\nThere are two ways to install the package:\n\n1. **Local Installation:**\n   If you have the package locally, upgrade `pip` to its latest version. Then, use the local setup files to install your package. This method is ideal for development or when you have the source code.\n   ```bash\n   pip install --upgrade pip\n   pip install -e .\n   ```\n2. **Direct Installation from GitHub:**\n   You can also install the package directly from GitHub. This method is straightforward and ensures you have the latest version.\n   ```bash\n   pip install git+https://github.com/jaabmar/confounder-lower-bound.git\n   ```\n\n#### Installing Dependencies for Unit Testing\n\nTo run the unit tests located in the `\\tests` folder, you need to install additional dependencies. These dependencies are required for testing and ensure that you can run all the tests properly.\n```bash\npip install .[tests]\n```\n\n## Usage\n\nExample of using the package:\n\n```bash\nfrom test_confounding.cate_bounds.cate_bounds import MultipleCATEBoundEstimators\nfrom test_confounding.cate_bounds.utils_cate_bounds import compute_bootstrap_variance\nfrom test_confounding.datasets import synthetic\nfrom test_confounding.test import run_multiple_cate_hypothesis_test\n\ndata = synthetic.Synthetic(\n        num_examples_obs =  5000,\n        num_examples_rct = 1000,\n        gamma_star = 10.0,\n        effective_conf = 1.0,\n        sigma_y = 0.01,\n        seed = 42,    \n)\n\nx_rct, t_rct, y_rct = (\n  data.rct.x,\n  data.rct.t,\n  data.rct.y,\n)\n\nx_obs, t_obs, y_obs = (\n    data.x,\n    data.t,\n    data.y,\n)\n\nate = y_rct[t_rct == 1].mean() - y_rct[t_rct == 0].mean()\nate_variance = compute_bootstrap_variance(Y = y_rct, T = t_rct, n_bootstraps = 50, arm = None)\n\nbounds_estimator = MultipleCATEBoundEstimators(\n    gammas = [1.0, 3.0, 5.0, 7.0, 9.0, 11.0], n_bootstrap = 50\n)\n\nbounds_estimator.fit(x_obs=x_obs, t_obs=t_obs, y_obs=y_obs)\n\nresults_dict_cate = run_multiple_cate_hypothesis_test(bounds_estimator = bounds_estimator, ate = ate, ate_variance = ate_variance, alpha = 5.0, x_rct = x_rct, user_conf = [1.0, 3.0, 5.0, 7.0, 9.0, 11.0], verbose = False)\n```\n\nFor detailed tutorials with synthetic and semi-synthetic data, refer to [Tutorial (Part 1)](src/synthetic.ipynb) and [Tutorial (Part 2)](src/semi_synthetic.ipynb).\n\n## Contributing\n\nWe welcome contributions to improve this project. Here's how you can contribute:\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n\n## Contact\n\nFor any inquiries, please reach out:\n\n- Javier Abad Martinez - [javier.abadmartinez@ai.ethz.ch](mailto:javier.abadmartinez@ai.ethz.ch)\n- Piersilvio de Bartolomeis - [pdebartol@ethz.ch](mailto:pdebartol@ethz.ch)\n- Konstantin Donhauser - [konstantin.donhauser@ai.ethz.ch](mailto:konstantin.donhauser@ai.ethz.ch)\n\n## Citation\n\nIf you find this code useful, please consider citing our paper:\n ```\n@inproceedings{de2024hidden,\n  title={Hidden yet quantifiable: A lower bound for confounding strength using randomized trials},\n  author={De Bartolomeis, Piersilvio and Martinez, Javier Abad and Donhauser, Konstantin and Yang, Fanny},\n  booktitle={International Conference on Artificial Intelligence and Statistics},\n  pages={1045--1053},\n  year={2024},\n  organization={PMLR}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaabmar%2Fconfounder-lower-bound","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaabmar%2Fconfounder-lower-bound","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaabmar%2Fconfounder-lower-bound/lists"}