Predict IPW-Weighted Survival Curves

Description

Fits an inverse-probability-weighted pooled logistic regression with time modeled using restricted cubic splines and arm-by-time interaction terms, then uses g-computation to generate marginal survival curves for each trial arm.

Usage

predict_survival_ipw(
  long_data,
  weight_col = "wp99",
  covariate_cols = NULL,
  outcome_col = "dead_t1",
  arm_col = "arm",
  month_col = "month2",
  id_col = "id",
  max_month = 95L,
  rcs_knots = c(6, 48, 72)
)

Arguments

long_data A data frame in long format (one row per participant-arm-month), as produced by expand_to_long(). Must contain columns specified by outcome_col, arm_col, and month_col. Both arms (“STOPBASE” and “CONTINUE”) must be present; a non-empty subset with only one arm will raise an error.
weight_col Name of the column containing IPW weights (e.g., as produced by compute_ipw_weights()). Set to NULL for unweighted estimation. Default: “wp99”.
covariate_cols Character vector of column names to include as additional adjustment terms in the model. These covariates are used during g-computation standardization over baseline rows (month = 0), so they must be measured at or before baseline. Set to NULL for no additional adjustment. Default: NULL.
outcome_col Name of the binary outcome column (0/1, NA for censored). Default: “dead_t1”.
arm_col Name of the trial arm column (“STOPBASE” / “CONTINUE”). Default: “arm”.
month_col Name of the time variable column (0-indexed month relative to trial entry). Default: “month2”.
id_col Name of the participant identifier column, used to deduplicate baseline rows during standardization. Default: “id”.
max_month Maximum month for survival prediction. Rows with month beyond this value are excluded from both model fitting and prediction. Default: 95.
rcs_knots Numeric vector with at least 3 elements specifying the knots for the restricted cubic spline: the first element is the left boundary knot, the last element is the right boundary knot, and any middle elements are interior knots. Must have at least one interior knot. Default: c(6, 48, 72) (one interior knot at month 48).

Details

Extends predict_survival_unadjusted() by passing participant-level IPW weights to stats::glm(). This up-weights participants with low probability of following their assigned arm protocol, creating a pseudo-population in which protocol adherence is independent of baseline characteristics.

Value

A data frame with one row per month (0 through max_month), containing:

  • month: Month index (0-indexed from trial entry).

  • s_continue: Estimated marginal survival probability in the CONTINUE arm.

  • s_stopbase: Estimated marginal survival probability in the STOPBASE arm.

References

García-Albéniz X, Uno H, Bhatt DL, McArdle PH, Joffe MM, Hernán MA. Continuation of Annual Screening Mammography and Breast Cancer Mortality in Women Older Than 70 Years: A Prospective Observational Study. Ann Intern Med. 2020;172(6):381–389. doi:10.7326/M18-1199

See Also

predict_survival_unadjusted(), predict_survival_baseline_adjusted(), compute_ipw_weights(), expand_to_long()

Examples

Code
library("ettbc")

cloned <- clone_censor(cohort, screening_mammograms, diagnostic_mammograms)
long_data <- expand_to_long(cloned)
long_data$wp99 <- 1.0
surv <- predict_survival_ipw(long_data, weight_col = "wp99")
head(surv)
  month s_continue s_stopbase
1     0  0.9961485  0.9979071
2     1  0.9924180  0.9957995
3     2  0.9888043  0.9936770
4     3  0.9853035  0.9915398
5     4  0.9819117  0.9893876
6     5  0.9786251  0.9872205