Learn R Programming

trtswitch (version 0.1.0)

tsesimp: The Simple Two-Stage Estimation (TSE) Method for Treatment Switching

Description

Obtains the causal parameter estimate of the AFT model and the hazard ratio estimate of the Cox model to account for treatment switching.

Usage

tsesimp(
  data,
  stratum = "",
  time = "time",
  event = "event",
  treat = "treat",
  censor_time = "censor_time",
  pd = "pd",
  pd_time = "pd_time",
  swtrt = "swtrt",
  swtrt_time = "swtrt_time",
  base_cov = "",
  base2_cov = "",
  aft_dist = "weibull",
  strata_main_effect_only = TRUE,
  recensor = TRUE,
  admin_recensor_only = FALSE,
  swtrt_control_only = TRUE,
  alpha = 0.05,
  ties = "efron",
  offset = 1,
  boot = TRUE,
  n_boot = 1000,
  seed = NA
)

Value

A list with the following components:

  • psi: The estimated causal parameter for the control group.

  • psi_CI: The confidence interval for psi.

  • psi_CI_type: The type of confidence interval for psi, i.e., "AFT model" or "bootstrap".

  • 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 "model" 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.

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

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

    • swtrt_control_only: Whether treatment switching occurred only in the control group.

    • alpha: The significance level to calculate confidence intervals.

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

    • offset: The offset to calculate the time to event, PD, and treatment switch.

    • 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 simulation results.

  • psi_trt: The estimated causal parameter for the treatment group if swtrt_control_only is FALSE.

  • psi_trt_CI: The confidence interval for psi_trt if swtrt_control_only is FALSE.

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

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

  • psi_trt_boots: The bootstrap psi_trt estimates if boot is TRUE and swtrt_control_only is FALSE.

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.

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

  • pd: The disease progression indicator, 1=PD, 0=no PD.

  • pd_time: The time from randomization to PD.

  • swtrt: The treatment switch indicator, 1=switch, 0=no switch.

  • swtrt_time: The time from randomization to treatment switch.

  • base_cov: The values of baseline covariates (excluding treat).

  • base2_cov: The values of baseline and secondary baseline covariates (excluding swtrt).

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.

censor_time

The name of the censor_time variable in the input data.

pd

The name of the pd variable in the input data.

pd_time

The name of the pd_time variable in the input data.

swtrt

The name of the swtrt variable in the input data.

swtrt_time

The name of the swtrt_time variable in the input data.

base_cov

The vector of names of base_cov variables (excluding treat) in the input data for the Cox model.

base2_cov

The vector of the names of base2_cov variables (excluding swtrt) in the input data for the AFT model.

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.

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.

swtrt_control_only

Whether treatment switching occurred only in the control group.

alpha

The significance level to calculate confidence intervals.

ties

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

offset

The offset to calculate the time to event, PD, and treatment switch. We can set offset equal to 1 (default), 1/30.4375, or 1/365.25 if the time unit is day, month, or year.

boot

Whether to use bootstrap to obtain the confidence interval for hazard ratio. Defaults to TRUE.

n_boot

The number of bootstrap samples.

seed

The seed to reproduce the bootstrap 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 an AFT model to estimate the causal parameter \(psi\) based on the patients in the control group who had disease progression.

  • Derive the counter-factual survival times for control patients had there been no treatment switching.

  • Fit the Cox model to the observed survival times on the treatment arm and the counter-factual untreated survival times on the control arm to obtain the hazard ratio estimate.

  • Use bootstrap to construct the p-value and confidence interval for hazard ratio.

References

Nicholas R Latimer, KR Abrams, PC Lambert, MK Crowther, AJ Wailoo, JP Morden, RL Akehurst, and MJ Campbell. Adjusting for treatment switching in randomised controlled trials - A simulation study and a simplified two-stage method. Statistical Methods in Medical Research. 2017;26(2):724-751.

Examples

Run this code

library(dplyr)

# 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"))

# the last value of time-dependent covariates before pd
shilong2 <- shilong %>%
  filter(pd == 0 | tstart <= dpd) %>%
  arrange(bras.f, id, tstop) %>%
  group_by(bras.f, id) %>%
  filter(row_number() == n()) %>%
  select(bras.f, id, ps, ttc, tran)

# combine baseline and time-dependent covariates
shilong3 <- shilong1 %>%
  left_join(shilong2, by = c("bras.f", "id"))

# apply the two-stage method
fit <- tsesimp(
  data = shilong3, time = "tstop", event = "event",
  treat = "bras.f", censor_time = "dcut", pd = "pd",
  pd_time = "dpd", swtrt = "co", swtrt_time = "dco",
  base_cov = "",
  base2_cov = c("agerand", "sex.f", "tt_Lnum", "rmh_alea.c",
                "pathway.f", "ps", "ttc", "tran"),
  aft_dist = "weibull", alpha = 0.05,
  recensor = TRUE, swtrt_control_only = FALSE, offset = 1,
  boot = FALSE)

c(fit$hr, fit$hr_CI)

Run the code above in your browser using DataLab