PStrata: An R Package for Principal Stratification

Bo Liu, Fan LiarXiv 2023 · DOI · arXiv

TL;DR

PStrata is a new R package that democratizes Principal Stratification, a powerful but historically difficult-to-implement framework for causal inference. By automating complex latent mixture modeling through a seamless R-to-Stan pipeline, it allows researchers to easily estimate causal effects in the presence of post-treatment complications like noncompliance, survival truncation, and clustered data.

What Problem Does This Paper Address?

In many clinical trials and observational studies, things happen after treatment that muddy the waters of causal inference. For example, a patient might not take the assigned drug (noncompliance), or they might die before the primary outcome can be measured (truncation by death). These "post-treatment variables" are often affected by the treatment itself, creating a form of confounding that standard methods struggle to handle.

Principal Stratification (PS) is the gold-standard framework for these problems. It works by categorizing individuals into "latent strata" based on how their intermediate behavior would change under different treatment assignments (e.g., "Always-takers" vs. "Compliers"). However, because these strata are never fully observed, estimating their effects requires sophisticated latent mixture models. Until now, this meant researchers had to write highly customized, complex code from scratch, making PS inaccessible to most applied scientists.

Methods

The authors introduce PStrata, an R package designed to automate the entire PS workflow. Its core innovation lies in its computing architecture:

  • Bayesian Paradigm: The package uses a "decoupled" approach. Users specify models using familiar R formulas. Behind the scenes, C++ code automatically generates the necessary Stan code and data structures. Stan then performs the heavy lifting of posterior sampling via Markov Chain Monte Carlo (MCMC).
  • Frequentist Paradigm: For those preferring non-Bayesian methods, the package implements a triply-robust weighting estimator based on the "principal ignorability" assumption.
  • Versatility: Unlike previous tools that might only handle simple noncompliance, PStrata supports:
  • Continuous and binary outcomes.
    • Time-to-event (survival) data using Cox proportional hazards or Accelerated Failure Time (AFT) models.
  • Multi-level/Clustered data by incorporating random effects into both the strata-membership and outcome models.

Datasets

The paper validates the package using both real-world data and rigorous simulations:

  • Flu Vaccination Case Study: A dataset from a study on whether physician encouragement letters (treatment) increased flu vaccinations (intermediate variable) and reduced hospital visits (outcome).
  • Simulated Benchmarks: The authors created four distinct simulation scenarios to test the package's limits:
  • Standard two-sided noncompliance.
  • Complex cases with two separate post-treatment variables.
  • Noncompliance with time-to-event (survival) outcomes.
  • Data featuring hierarchical/cluster effects.

Key Insights and Ideas

  • Automation is the Killer Feature: The "aha moment" is that users no longer need to be Stan experts to run complex Bayesian mixture models. The package handles the translation from R's lm()-style syntax to high-performance C++/Stan code automatically.
  • Principal Stratum as a Pre-treatment Variable: The package reinforces the core PS insight: while the actual intermediate behavior is post-treatment, the potential behavior (the stratum) is a fixed characteristic of the individual. Treating it as a latent pre-treatment variable allows for valid causal comparisons.
  • Handling "Truncation by Death": The package provides a formal way to calculate the "Survivor Average Causal Effect" (SACE), which is the only meaningful treatment effect when an outcome is only defined for those who survive.

Key Results

  • Accuracy: In all four simulation cases, PStrata successfully recovered the "true" underlying parameters. Posterior means for stratum probabilities and causal effects were consistently close to the ground truth with narrow credible intervals.
  • Case Study Findings: In the flu vaccine study, the package identified that while encouragement reduced hospital visits for "Compliers" (from 16.7% to 6.9%), the effect was not statistically significant at the 95% level. Interestingly, it also revealed that "Always-vaxers" had a counterintuitively higher hospital visit rate (10%), suggesting they might be a higher-risk subpopulation.
  • Survival Analysis: The package successfully generated survival probability curves with 95% confidence regions, allowing for a visual and statistical comparison of treatment effects over time within specific strata.

Limitations and Future Work

While PStrata is a major step forward, the authors note a few areas for growth:

  • Current Scope: The current version (0.0.1) focuses on single and double post-treatment variables.
  • Future Features: Planned updates include specialized modules for "informative missing data" and more robust graphic diagnostics to help users check model fit.
  • Assumptions: Like all causal inference tools, the results are only as good as the underlying assumptions (like monotonicity or exclusion restrictions), which the user must still justify based on their specific domain knowledge.

Summary updated

Abstract

Post-treatment confounding is a common problem in causal inference, including special cases of noncompliance, truncation by death, surrogate endpoint, etc. Principal stratification (Frangakis and Rubin 2002) is a general framework for defining and estimating causal effects in the presence of post-treatment confounding. A prominent special case is the instrumental variable approach to noncompliance in randomized experiments (Angrist, Imbens, and Rubin 1996). Despite its versatility, principal stratification is not accessible to the vast majority of applied researchers because its inherent latent mixture structure requires complex inference tools and highly customized programming. We develop the R package PStrata to automatize statistical analysis of principal stratification for several common scenarios. PStrata supports both Bayesian and frequentist paradigms. For the Bayesian paradigm, the computing architecture combines R, C++, Stan, where R provides user-interface, Stan automatizes posterior sampling, and C++ bridges the two by automatically generating Stan code. For the Frequentist paradigm, PStrata implements a triply-robust weighting estimator. PStrata accommodates regular outcomes and time-to-event outcomes with both unstructured and clustered data.
BibTeX
@misc{liu2023pstrata,
  author = {Bo Liu and Fan Li},
  title = {{PStrata: An R Package for Principal Stratification}},
  year = {2023},
  eprint = {2304.02740},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.02740},
}
Figure