Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 051
Research workflow/4 steps

Bayesian principal stratification (PStrata)

01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 4 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 4
01
Data prep

Specify the principal stratification model

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

PStrataModel() declares the strata from the (Z, D) pattern - never-takers '00', compliers '01', always-takers '11' - the outcome family, priors, and which strata obey the exclusion restriction.

Formula
Y_i(1)=Y_i(0)\ \text{for}\ S_i\in\{n,a\}\quad(\text{exclusion restriction})
Reads fromNot specified Feeds into#2
Key code
# Install:  install.packages("PStrata")
library(PStrata)

model <- PStrataModel(
  S.formula = Z + D ~ 1,
  Y.formula = Y ~ 1,
  Y.family  = gaussian(link = "identity"),
  strata    = c(n = "00", c = "01", a = "11"),
  ER        = c("n", "a"),
  prior_intercept = prior_normal(0, 1),
  prior_sigma     = prior_inv_gamma(1)
)
summary(model)

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

One row per unit: treatment Z, a post-treatment intermediate D, outcome Y, and any covariates.

Show data format & exampleHide example
Z D Y
1 1 2.31
0 0 -0.4
1 0 0.88
0 0 1.05
03
Read the evidence

Results & interpretation

1 figure Workflow discussion 0
01FigurePosterior distribution of the complier average causal effect (mean ≈ 1.04, 95% credible interval shaded).

Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.

The estimate

\tau_g=\mathbb E\big[Y(1)-Y(0)\,\big|\,S=g\big],\qquad S=\big(D(0),\,D(1)\big)

Context & interpretation

⚠️ Unofficial community showcase of PStrata (docs). Not affiliated with the authors — all credit to Fan Li & coauthors; this summarizes public documentation.

What it does. PStrata estimates principal causal effects — effects defined within latent principal strata such as compliers, always-takers and never-takers — when an intermediate (post-treatment) variable confounds the treatment-outcome relationship. It handles continuous, binary, count, and time-to-event outcomes (Liu & Li, 2023).

How it works. Units are modeled as a finite mixture over principal strata defined by joint potential values of the intermediate variable. A Bayesian model (compiled to Stan) jointly estimates stratum membership probabilities and outcome models within each stratum via MCMC. The workflow is PStrataModel() to specify strata, exclusion-restriction (ER) and monotonicity assumptions and priors; fit() to run MCMC; then estimate() and contrast() for stratum-specific potential outcomes and effects. Users can toggle assumptions (e.g. drop ER) to probe sensitivity.

Assumptions. SUTVA, ignorable treatment assignment, plus user-chosen structural assumptions (monotonicity, exclusion restriction) and outcome-model/prior specification; identification is driven by the mixture model.

What you get — Posterior stratum membership probabilities and stratum-specific causal contrasts (e.g. complier/LATE effect) with credible intervals.

Example output

# Posterior summary of stratum effects (contrast Z=1 vs Z=0)

  stratum    mean     sd    2.5%   median   97.5%  Rhat
1       n  0.0000  0.000   0.000   0.0000  0.0000  1.00
2       c  1.0382  0.1471   0.751   1.0376  1.3271  1.00
3       a  0.0000  0.000   0.000   0.0000  0.0000  1.00

# Stratum proportions
  stratum    mean     sd    2.5%   97.5%
1       n  0.3013  0.0205  0.262   0.342
2       c  0.4021  0.0231  0.357   0.448
3       a  0.2966  0.0198  0.259   0.336

Links: package · paper

Peer notes

Discuss the workflow (0)

  • No comments yet — start the conversation.
IN THE MARGINS

Peer discussion