Learn R Programming

trtswitch (version 0.1.0)

ipe: Iterative Parameter Estimation (IPE) for Treatment Switching

Description

Obtains the causal parameter estimate from the accelerated failure-time (AFT) model and the hazard ratio estimate from the Cox model to account for treatment switching.

Usage

ipe(
  data,
  stratum = "",
  time = "time",
  event = "event",
  treat = "treat",
  rx = "rx",
  censor_time = "censor_time",
  base_cov = "",
  aft_dist = "weibull",
  strata_main_effect_only = 1,
  treat_modifier = 1,
  recensor = TRUE,
  admin_recensor_only = FALSE,
  autoswitch = TRUE,
  alpha = 0.05,
  ties = "efron",
  tol = 1e-06,
  boot = FALSE,
  n_boot = 1000,
  seed = NA
)

Value

A list with the following components:

  • psi: The estimated causal parameter.

  • psi_CI: The confidence interval for psi.

  • psi_CI_type: The type of confidence interval for psi, i.e., "log-rank p-value" or "bootstrap".

  • Sstar: A data frame containing the counter-factual unswitched survival times and the event indicators.

  • kmstar: A data frame containing the Kaplan-Meier estimates based on the counter-factual unswitched survival times by treatment arm.

  • logrank_pvalue: The two-sided p-value of the log-rank test based on the treatment policy strategy.

  • cox_pvalue: The two-sided p-value for treatment effect based on the Cox model.

  • hr: The estimated hazard ratio from the Cox model.

  • hr_CI: The confidence interval for hazard ratio.

  • hr_CI_type: The type of confidence interval for hazard ratio, either "log-rank p-value" or "bootstrap".

  • settings: A list with the following components:

    • aft_dist: The distribution for time to event for the AFT model.

    • strata_main_effect_only: Whether to only include the strata main effects in the AFT model.

    • treat_modifier: The sensitivity parameter for the constant treatment effect assumption.

    • recensor: Whether to apply recensoring to counter-factual survival times.

    • admin_recensor_only: Whether to apply recensoring to administrative censoring time only.

    • autoswitch: Whether to exclude recensoring for treatment arms with no switching.

    • alpha: The significance level to calculate confidence intervals.

    • ties: The method for handling ties in the Cox model.

    • tol: The desired accuracy (convergence tolerance).

    • boot: Whether to use bootstrap to obtain the confidence interval for hazard ratio.

    • n_boot: The number of bootstrap samples.

    • seed: The seed to reproduce the bootstrap results.

  • hr_boots: The bootstrap hazard ratio estimates if boot is TRUE.

  • psi_boots: The bootstrap psi estimates if boot is TRUE.

Arguments

data

The input data frame that contains the following variables:

  • stratum: The stratum.

  • time: The survival time for right censored data.

  • event: The event indicator, 1=event, 0=no event.

  • treat: The randomized treatment indicator, 1=treatment, 0=control.

  • rx: The proportion of time on active treatment.

  • censor_time: The administrative censoring time. It should be provided for all subjects including those who had events.

  • base_cov: The baseline covariates (excluding treat).

stratum

The name(s) of the stratum variable(s) in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

treat

The name of the treatment variable in the input data.

rx

The name of the rx variable in the input data.

censor_time

The name of the censor_time variable in the input data.

base_cov

The vector of names of baseline covariates (excluding treat) in the input data.

aft_dist

The assumed distribution for time to event for the AFT model. Options include "exponential", "weibull", "loglogistic", and "lognormal".

strata_main_effect_only

Whether to only include the strata main effects in the AFT model. Defaults to TRUE, otherwise all possible strata combinations will be considered in the AFT model.

treat_modifier

The optional sensitivity parameter for the constant treatment effect assumption.

recensor

Whether to apply recensoring to counter-factual survival times. Defaults to TRUE.

admin_recensor_only

Whether to apply recensoring to administrative censoring time only. Defaults to FALSE, in which case, recensoring will be applied to the actual censoring time for dropouts.

autoswitch

Whether to exclude recensoring for treatment arms with no switching. Defaults to TRUE.

alpha

The significance level to calculate confidence intervals.

ties

The method for handling ties in the Cox model, either "breslow" or "efron" (default).

tol

The desired accuracy (convergence tolerance) for psi.

boot

Whether to use bootstrap to obtain the confidence interval for hazard ratio. Defaults to FALSE, in which case, the confidence interval will be constructed to match the log-rank test p-value.

n_boot

The number of bootstrap samples.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified.

Author

Kaifeng Lu, kaifenglu@gmail.com

Details

We use the following steps to obtain the hazard ratio estimate and confidence interval had there been no treatment switching:

  • Use IPE to estimate the causal parameter \(\psi\) based on the AFT model for counter-factual survival times for both arms: \(U_{i,\psi} = T_{C_i} + e^{\psi}T_{E_i}\) for the control arm, and \(V_{i,\psi} = T_{E_i} + e^{-\psi}T_{C_i}\) for the experimental arm.

  • Fit the Cox proportional hazards model to the counter-factual survival times to obtain the hazard ratio estimate.

  • Use either the log-rank test p-value for the treatment policy strategy or bootstrap to construct the confidence interval for hazard ratio.

References

Michael Branson and John Whitehead. Estimating a treatment effect in survival studies in which patients switch treatment. Statistics in Medicine. 2002;21:2449-2463.

Ian R White. Letter to the Editor: Estimating treatment effects in randomized trials with treatment switching. Statistics in Medicine. 2006;25:1619-1622.

Examples

Run this code

library(dplyr)

# Example 1: one-way treatment switching (control to active)

data <- immdef %>% mutate(rx = 1-xoyrs/progyrs)

fit1 <- ipe(
  data, time = "progyrs", event = "prog", treat = "imm", 
  rx = "rx", censor_time = "censyrs", aft_dist = "weibull",
  boot = FALSE)

c(fit1$hr, fit1$hr_CI)

# Example 2: two-way treatment switching (illustration only)

# the eventual survival time
shilong1 <- shilong %>%
  arrange(bras.f, id, tstop) %>%
  group_by(bras.f, id) %>%
  filter(row_number() == n()) %>%
  select(-c("ps", "ttc", "tran"))

shilong2 <- shilong1 %>%
  mutate(rx = ifelse(co, ifelse(bras.f == "MTA", dco/ady, 
                                1 - dco/ady),
                     ifelse(bras.f == "MTA", 1, 0)))

fit2 <- ipe(
  shilong2, time = "tstop", event = "event",
  treat = "bras.f", rx = "rx", censor_time = "dcut",
  base_cov = c("agerand", "sex.f", "tt_Lnum", "rmh_alea.c",
               "pathway.f"),
  aft_dist = "weibull", boot = FALSE)

c(fit2$hr, fit2$hr_CI)

Run the code above in your browser using DataLab