rpsftm {trtswitch} | R Documentation |
Rank Preserving Structural Failure Time Model (RPSFTM) for Treatment Switching
Description
Obtains the causal parameter estimate from the log-rank test, the Cox proportional hazards model, or a parametric survival regression model, and obtains the hazard ratio estimate from the Cox model to adjust for treatment switching.
Usage
rpsftm(
data,
id = "id",
stratum = "",
time = "time",
event = "event",
treat = "treat",
rx = "rx",
censor_time = "censor_time",
base_cov = "",
psi_test = "logrank",
aft_dist = "weibull",
strata_main_effect_only = TRUE,
low_psi = -2,
hi_psi = 2,
n_eval_z = 101,
treat_modifier = 1,
recensor = TRUE,
admin_recensor_only = TRUE,
autoswitch = TRUE,
gridsearch = FALSE,
alpha = 0.05,
ties = "efron",
tol = 1e-06,
boot = FALSE,
n_boot = 1000,
seed = NA
)
Arguments
data |
The input data frame that contains the following variables:
|
id |
The name of the id variable in the input data. |
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 names of baseline covariates (excluding
treat) in the input data for the outcome Cox model.
These covariates will also be used in the Cox model for estimating
|
psi_test |
The survival function to calculate the Z-statistic, e.g., "logrank" (default), "phreg", or "lifereg". |
aft_dist |
The assumed distribution for time to event for the
accelerated failure time (AFT) model when
|
strata_main_effect_only |
Whether to only include the strata main
effects in the AFT model. Defaults to |
low_psi |
The lower limit of the causal parameter. |
hi_psi |
The upper limit of the causal parameter. |
n_eval_z |
The number of points between |
treat_modifier |
The optional sensitivity parameter for the constant treatment effect assumption. |
recensor |
Whether to apply recensoring to counterfactual
survival times. Defaults to |
admin_recensor_only |
Whether to apply recensoring to administrative
censoring times only. Defaults to |
autoswitch |
Whether to exclude recensoring for treatment arms
with no switching. Defaults to |
gridsearch |
Whether to use grid search to estimate the causal
parameter |
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 |
boot |
Whether to use bootstrap to obtain the confidence
interval for hazard ratio. Defaults to |
n_boot |
The number of bootstrap samples. |
seed |
The seed to reproduce the bootstrap results. The default is missing, in which case, the seed from the environment will be used. |
Details
We use the following steps to obtain the hazard ratio estimate and confidence interval had there been no treatment switching:
Use RPSFTM to estimate the causal parameter
\psi
based on the log-rank test (default), the Cox proportional hazards model, or a parametric survival regression model for counterfactual untreated survival times:U_{i,\psi} = T_{C_i} + e^{\psi}T_{E_i}
Fit the Cox proportional hazards model to the counterfactual unswitched survival times to obtain the hazard ratio estimate.
Use either the log-rank test p-value for the intention-to-treat (ITT) analysis or bootstrap to construct the confidence interval for hazard ratio. If bootstrapping is used, the confidence interval and corresponding p-value are calculated based on a t-distribution with
n_boot - 1
degrees of freedom.
Value
A list with the following components:
-
psi
: The estimated causal parameter. -
psi_CI
: The confidence interval forpsi
. -
psi_CI_type
: The type of confidence interval forpsi
, i.e., "grid search", "root finding", or "bootstrap". -
logrank_pvalue
: The two-sided p-value of the log-rank test for the ITT analysis. -
cox_pvalue
: The two-sided p-value for treatment effect based on the Cox model applied to counterfactual unswitched survival times. Ifboot
isTRUE
, this value represents the bootstrap p-value. -
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". -
eval_z
: A data frame containing the Z-statistics for treatment effect evaluated at a sequence ofpsi
values. Used to plot and check if the range ofpsi
values to search for the solution and limits of confidence interval ofpsi
need be modified. -
Sstar
: A data frame containing the counterfactual untreated survival times and event indicators for each treatment group. The variables includeid
,stratum
,"t_star"
,"d_star"
,"treated"
,base_cov
, andtreat
. -
kmstar
: A data frame containing the Kaplan-Meier estimates based on the counterfactual untreated survival times by treatment arm. -
data_outcome
: The input data for the outcome Cox model of counterfactual unswitched survival times. The variables includeid
,stratum
,"t_star"
,"d_star"
,"treated"
,base_cov
, andtreat
. -
fit_outcome
: The fitted outcome Cox model. -
fail
: Whether a model fails to converge. -
settings
: A list with the following components:-
psi_test
: The survival function to calculate the Z-statistic. -
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. -
low_psi
: The lower limit of the causal parameter. -
hi_psi
: The upper limit of the causal parameter. -
n_eval_z
: The number of points betweenlow_psi
andhi_psi
(inclusive) at which to evaluate the Z-statistics. -
treat_modifier
: The sensitivity parameter for the constant treatment effect assumption. -
recensor
: Whether to apply recensoring to counterfactual survival times. -
admin_recensor_only
: Whether to apply recensoring to administrative censoring times only. -
autoswitch
: Whether to exclude recensoring for treatment arms with no switching. -
gridsearch
: Whether to use grid search to estimate the causal parameterpsi
. -
alpha
: The significance level to calculate confidence intervals. -
ties
: The method for handling ties in the Cox model. -
tol
: The desired accuracy (convergence tolerance) forpsi
. -
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.
-
-
fail_boots
: The indicators for failed bootstrap samples ifboot
isTRUE
. -
hr_boots
: The bootstrap hazard ratio estimates ifboot
isTRUE
. -
psi_boots
: The bootstrappsi
estimates ifboot
isTRUE
.
Author(s)
Kaifeng Lu, kaifenglu@gmail.com
References
James M. Robins and Anastasios A. Tsiatis. Correcting for non-compliance in randomized trials using rank preserving structural failure time models. Communications in Statistics. 1991;20(8):2609-2631.
Ian R. White, Adbel G. Babiker, Sarah Walker, and Janet H. Darbyshire. Randomization-based methods for correcting for treatment changes: Examples from the CONCORDE trial. Statistics in Medicine. 1999;18(19):2617-2634.
Examples
library(dplyr)
# Example 1: one-way treatment switching (control to active)
data <- immdef %>% mutate(rx = 1-xoyrs/progyrs)
fit1 <- rpsftm(
data, id = "id", time = "progyrs", event = "prog", treat = "imm",
rx = "rx", censor_time = "censyrs", 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) %>%
slice(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 <- rpsftm(
shilong2, id = "id", 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"),
low_psi = -3, hi_psi = 3, boot = FALSE)
c(fit2$hr, fit2$hr_CI)