StatsOtter Causal inference workflows
11
Workflow·3 steps

PS weighting for survival outcomes (PSsurvival)

Summary by StatsOtter

Propensity-score balancing weights for time-to-event outcomes: counterfactual survival curves, survival differences, and marginal hazard ratios.

1

Input · what goes in

One row per unit: covariates X, treatment Z, follow-up time, and an event/censoring indicator.

Show data format & exampleHide example
Z X1 B1 time event
A 0.31 1 12.4 1
B -0.8 0 20.0 0
A 1.05 1 6.7 1
B -0.2 0 15.3 0
2

Pipeline · the recipe

↑ Click any step in the diagram to read its logic, code, assumptions & discussion.

1
Data prep

Load package and survival data

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

What happens here

Load simdata_bin, which holds a binary treatment Z, covariates, and right-censored (time, event) outcomes for two arms A and B.

Reads from the input data Feeds into #2
Key code
# Install:  install.packages("PSsurvival")
library(PSsurvival)
data(simdata_bin)

head(simdata_bin)
table(simdata_bin$Z)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
2
Estimation

Run surveff() with overlap weights

The core estimate — where the causal quantity itself is computed.

What happens here

surveff fits the propensity model and a Weibull censoring model, forms overlap weights, and produces inverse-probability-of-censoring-weighted survival curves per arm.

Formula
\hat S_z(t)=\frac{\sum_i w_i\,\mathbb{1}\{Z_i=z\}\,\hat S_i(t)}{\sum_i w_i\,\mathbb{1}\{Z_i=z\}}
Reads from #1 Feeds into #3
Key code
result_bin <- surveff(
  data = simdata_bin,
  ps_formula = Z ~ X1 + X2 + X3 + B1 + B2,
  censoring_formula = survival::Surv(time, event) ~ X1 + B1,
  weight_method = "OW",
  censoring_method = "weibull"
)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3
Inference

Survival difference with confidence intervals

Uncertainty quantification — standard errors, intervals, and aggregation.

What happens here

summary() reports the weighted KM survival functions for A and B and their difference B − A at each evaluation time, with analytical SEs and 95% Wald intervals.

Formula
\Delta(t)=\hat S_B(t)-\hat S_A(t)
Reads from #2 Feeds into the final output
Key code
summary(result_bin, conf_level = 0.95, max.len = 5)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3

Output · what you get

Overlap-weighted counterfactual survival curves for the two treatment arms.
Fig 1Overlap-weighted counterfactual survival curves for the two treatment arms.

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

Result · the numbers

\Delta S(t)=S_1(t)-S_0(t),\quad \hat S_z(t)=\prod_{t_k\le t}\!\Big(1-\frac{\sum_i w_i\,dN_i(t_k)}{\sum_i w_i\,Y_i(t_k)}\Big)

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

What it does. PSsurvival extends propensity-score weighting to censored time-to-event data, estimating counterfactual survival functions, survival differences, and marginal hazard ratios under binary or multiple treatments.

How it works. It combines propensity-score balancing weights (IPW, overlap/ATO, ATT, with optional symmetric trimming) with inverse-probability-of-censoring weights to handle dependent censoring. surveff() returns weighted counterfactual survival probabilities and their differences; marCoxph() fits a weighted Cox model for a marginal hazard ratio; weightedKM() produces weighted Kaplan-Meier and cumulative-incidence curves. The censoring model can be Weibull or Cox, and variances come from analytic sandwich formulas or the bootstrap. Overlap weights smoothly down-weight extreme propensity scores, reducing the variance inflation that plagues IPW survival estimators (Cheng, Li, Thomas & Li, AJE 2022).

Assumptions. Unconfoundedness, positivity (relaxed under OW), correctly specified PS and censoring models, and non-informative censoring conditional on covariates.

What you get — Weighted counterfactual survival curves and survival-difference estimates, a marginal hazard ratio, with analytic or bootstrap SEs/CIs.

Example output

Treatment groups: A, B 
Number of groups: 2 
Estimand: overlap 
Censoring method: weibull 
Variance method: analytical 
Evaluation times: 666 time points

Survival function estimates:
        A      B
[1,] 0.9979 1.0000
[2,] 0.9960 1.0000
[3,] 0.9960 0.9973

Treatment effect estimates:
     B vs A
[1,] 0.0021
[2,] 0.0040
[3,] 0.0013

Links: package · paper

Discussion (0)

  • No comments yet — start the conversation.