[Paper Review] CausalGPS: An R Package for Causal Inference With Continuous Exposures
CausalGPS is an R package that enables causal inference with continuous exposures using generalized propensity scores (GPS) via weighting or matching. It automates GPS estimation, covariate balance optimization through iterative transformations, and outcome modeling, achieving improved balance and efficient estimation in real-world data, as shown in PM2.5 exposure analysis with optimal caliper selection and trimming strategies.
Quantifying the causal effects of continuous exposures on outcomes of interest is critical for social, economic, health, and medical research. However, most existing software packages focus on binary exposures. We develop the CausalGPS R package that implements a collection of algorithms to provide algorithmic solutions for causal inference with continuous exposures. CausalGPS implements a causal inference workflow, with algorithms based on generalized propensity scores (GPS) as the core, extending propensity scores (the probability of a unit being exposed given pre-exposure covariates) from binary to continuous exposures. As the first step, the package implements efficient and flexible estimations of the GPS, allowing multiple user-specified modeling options. As the second step, the package provides two ways to adjust for confounding: weighting and matching, generating weighted and matched data sets, respectively. Lastly, the package provides built-in functions to fit flexible parametric, semi-parametric, or non-parametric regression models on the weighted or matched data to estimate the exposure-response function relating the outcome with the exposures. The computationally intensive tasks are implemented in C++, and efficient shared-memory parallelization is achieved by OpenMP API. This paper outlines the main components of the CausalGPS R package and demonstrates its application to assess the effect of long-term exposure to PM2.5 on educational attainment using zip code-level data from the contiguous United States from 2000-2016.
Motivation & Objective
- To address the challenge of causal inference with continuous exposures in observational studies where traditional methods fail due to lack of overlap or imbalance.
- To develop a modular, efficient, and reliable R package that supports GPS estimation, pseudo-population generation, and outcome modeling with customizable tuning.
- To automate the selection of optimal hyperparameters and covariate transformations to achieve acceptable covariate balance.
- To provide users with flexible tools for trimming exposure and GPS support, hyperparameter tuning, and iterative balance improvement.
Proposed method
- The package estimates GPS using ensemble machine learning models (e.g., XGBoost) with user-defined hyperparameters and supports parametric, semi-parametric, and non-parametric outcome modeling.
- It implements a novel iterative covariate transformation strategy that applies user-defined univariate functions (e.g., power-2, power-3) to the most imbalanced covariate at each step to improve GPS estimation.
- Covariate balance is assessed via absolute correlations between exposures and covariates; the process stops when balance thresholds (e.g., 0.1) are met or maximum iterations are reached.
- Users can apply trimming to exposure (exposure_trim_qtls) and GPS values (gps_trim_qtls) to improve positivity and support overlap.
- The package supports two causal inference approaches: inverse probability weighting and matching, with matching using L1 distance and caliper-based neighbor selection.
- It includes a logging system, performance-optimized C++ back-end, and comprehensive unit and functional testing for reliability and scalability.
Experimental results
Research questions
- RQ1How can generalized propensity scores be effectively estimated and optimized for continuous exposures in observational data with high-dimensional confounders?
- RQ2What is the impact of exposure and GPS trimming on covariate balance and estimation efficiency in matching-based causal inference?
- RQ3Can iterative covariate transformation improve GPS estimation and achieve acceptable balance without prior knowledge of optimal transformations?
- RQ4How do different hyperparameter configurations and model libraries affect GPS estimation and resulting causal effect estimates?
- RQ5What is the computational cost and performance trade-off of iterative balance optimization across varying trimming and hyperparameter settings?
Key findings
- Trimming exposure data to the 10th and 90th percentiles yielded the best balance (maximal absolute correlation of 0.094) with only 3 iterations and 287.32 seconds, outperforming broader trimming ranges.
- The optimal caliper size (delta_n) varied with trimming: 1.7 for 1st–99th, 0.9 for 5th–95th, and 1.9 for 10th–90th percentiles, indicating sensitivity to support definition.
- The iterative covariate transformation approach successfully reduced imbalance, with the best balance achieved after 3 iterations when trimming to the 10th–90th percentiles.
- Excluding extreme GPS values (via gps_trim_qtls) improved match quality but altered the target estimand, highlighting the need for careful interpretation of the causal estimand.
- The package achieved reliable performance with a maximum of 10 iterations, and the time cost increased significantly with broader trimming and higher hyperparameter search space.
- The S3 object output from generate_pseudo_pop() includes full metadata, including original and adjusted correlations, best hyperparameters, and matched pseudo-population, enabling full reproducibility.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.