PStrata_PACKAGE: PStrata: Principal STRATification Analysis for Data with...

PStrata_PACKAGER Documentation

PStrata: Principal STRATification Analysis for Data with Post-Randomization Confounding

Description

The PStrata package is designed for estimating causal effects in the presence of post-treatment confounding using principal stratification. It provides an interface to fit the Bayesian principal stratification model, which is a complex mixture model, using Stan, a C++ package for obtaining full Bayesian inference. The formula syntax is an extended version of the syntax applied in many regression functions and packages, such as lm, glm and lme4-package, to provide a simple interface. A wide variety of distributions and link functions are supported, allowing users to fit linear, binary or count data, and survival models with principal stratification. Further modeling options include multiple post-treatment confounding variables and cluster random effects. The monotonicity and exclusion restriction assumptions can be easily applied, and prior specifications are flexible and encourage users to reflect their prior belief. In addition, all parameters can be inferred from the posterior distribution, which enables further analysis other than provided by the package.

Details

The Bayesian principal stratification analysis relies on two models, the principal stratum model and the outcome model. The main workflow is:

  1. PStrataModel: specify the model (formulas, strata, priors).

  2. fit: compile and run MCMC sampling via Stan.

  3. estimate: extract posterior potential outcomes.

  4. contrast: compute causal effect contrasts.

Based on the supplied formulas, data and additional information, it automatically generates the Stan code via make_stancode and fits the model using Stan.

The estimated probability for each principal stratum and the estimated mean response are calculated with Stan as it is faster and more space-efficient. Post-processing methods summary and plot provide overviews and visualization.

Because PStrata heavily relies on Stan for posterior sampling, a C++ compiler is required. The program Rtools (available on https://cran.r-project.org/bin/windows/Rtools/) comes with a C++ compiler for Windows. On Mac, Xcode is suggested. For further instructions on how to get the compilers running, please refer to the prerequisites section at the RStan-Getting-Started page.

References

The Stan Development Team. Stan Modeling Language User's Guide and Reference Manual. https://mc-stan.org/users/documentation/

Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org/

See Also

PStrataModel, fit, estimate, contrast


PStrata documentation built on May 14, 2026, 5:06 p.m.