msm {trtswitch} | R Documentation |
Marginal Structural Model (MSM) Method for Treatment Switching
Description
Uses the marginal structural model (MSM) method to obtain the hazard ratio estimate of the Cox model to adjust for treatment switching.
Usage
msm(
data,
id = "id",
stratum = "",
tstart = "tstart",
tstop = "tstop",
event = "event",
treat = "treat",
swtrt = "swtrt",
swtrt_time = "swtrt_time",
base_cov = "",
numerator = "",
denominator = "",
strata_main_effect_only = TRUE,
firth = FALSE,
flic = FALSE,
ns_df = 3,
stabilized_weights = TRUE,
trunc = 0,
trunc_upper_only = TRUE,
swtrt_control_only = TRUE,
treat_alt_interaction = FALSE,
alpha = 0.05,
ties = "efron",
boot = TRUE,
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. |
tstart |
The name of the tstart variable in the input data. |
tstop |
The name of the tstop 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. |
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 names of baseline covariates (excluding treat) in the input data for the Cox model. |
numerator |
The names of baseline covariates (excluding treat) in the input data for the numerator switching model for stabilized weights. |
denominator |
The names of baseline (excluding treat) and time-dependent covariates in the input data for the denominator switching model. |
strata_main_effect_only |
Whether to only include the strata main
effects in the logistic regression switching model. Defaults to
|
firth |
Whether the Firth's bias reducing penalized likelihood should be used. |
flic |
Whether to apply intercept correction to obtain more accurate predicted probabilities. |
ns_df |
Degrees of freedom for the natural cubic spline for visit-specific intercepts of the pooled logistic regression model. Defaults to 3 for two internal knots at the 33 and 67 percentiles of the artificial censoring times due to treatment switching. |
stabilized_weights |
Whether to use the stabilized weights.
The default is |
trunc |
The truncation fraction of the weight distribution. Defaults to 0 for no truncation in weights. |
trunc_upper_only |
Whether to truncate the weights from the upper
end of the weight distribution only. Defaults to |
swtrt_control_only |
Whether treatment switching occurred only in
the control group. The default is |
treat_alt_interaction |
Whether to include an interaction between randomized and alternative treatment in the outcome model when both randomized arms can switch to alternative treatment. |
alpha |
The significance level to calculate confidence intervals. The default value is 0.05. |
ties |
The method for handling ties in the Cox model, either "breslow" or "efron" (default). |
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:
Exclude observations after treatment switch for the switch model.
Set up the crossover indicators for the last time interval for each subject.
Fit the denominator switching model (and the numerator switching model for stabilized weights) to obtain the inverse probability of censoring weights using a pooled logistic regression model. The probability of remaining uncensored (i.e., not switching) will be calculated by subtracting the predicted probability of switching from 1. The probabilities of remaining unswitched will be multiplied over time before treatment switching, at which time point, it will be multiplied by the probability of treatment switching. The inverse probability of treatment weighting will not change after treatment switching.
Fit the weighted Cox model to the censored outcome survival times to obtain the hazard ratio estimate.
Use either robust sandwich variance or bootstrapping to construct the p-value and confidence interval for the 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:
-
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 "Cox model" or "bootstrap". -
data_switch
: A list of input data for the switching models by treatment group. The variables includeid
,stratum
,"tstart"
,"tstop"
,"cross"
,denominator
,swtrt
, andswtrt_time
. -
fit_switch
: A list of fitted switching models for the denominator and numerator by treatment group. -
data_outcome
: The input data for the outcome Cox model including the inverse probability of censoring weights. The variables includeid
,stratum
,"tstart"
,"tstop"
,"event"
,"treated"
,"unstablized_weight"
,"stabilized_weight"
,base_cov
, andtreat
. -
fit_outcome
: The fitted outcome Cox model. -
fail
: Whether a model fails to converge. -
settings
: A list with the following components:-
strata_main_effect_only
: Whether to only include the strata main effects in the logistic regression switching model. -
firth
: Whether the Firth's bias reducing penalized likelihood should be used. -
flic
: Whether to apply intercept correction to obtain more accurate predicted probabilities. -
ns_df
: Degrees of freedom for the natural cubic spline. -
stabilized_weights
: Whether to use the stabilized weights. -
trunc
: The truncation fraction of the weight distribution. -
trunc_upper_only
: Whether to truncate the weights from the upper end of the distribution only. -
swtrt_control_only
Whether treatment switching occurred only in the control group. -
treat_alt_interaction
Whether to include an interaction between randomized and alternative treatment in the outcome model. -
alpa
: The significance level to calculate confidence intervals. -
ties
: The method for handling ties in the Cox model. -
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
.
Author(s)
Kaifeng Lu, kaifenglu@gmail.com
References
James M. Robins, Miguel Angel Hernan, and Babette Brumback. Marginal structural models and causal inference in epidemiology. Epidemiology. 2000;11(5):550-560.
Miguel Angel Hernan, Babette Brumback, and James M. Robins. Marginal structural modesl to estimate the causual effect of zidovudine on the survival of HIV-positive men. Epidemiology. 2000;11(5):561-570.
Jing Xu, Guohui Liu, and Bingxia Wang. Bias and Type I error control in correcting treatment effect for treatment switching using marginal structural models in Phase III oncology trials. Journal of Biopharmaceutical Statistics. 2022;32(6):897-914.
Examples
sim1 <- tssim(
tdxo = 0, coxo = 0, p_R = 0.5, p_X_1 = 0.3, p_X_0 = 0.3,
rate_T = 0.002, beta1 = -0.5, beta2 = 0.3,
gamma0 = 0.3, gamma1 = -0.9, gamma2 = 0.7, gamma3 = 1.1, gamma4 = -0.8,
zeta0 = -3.5, zeta1 = 0.5, zeta2 = 0.2, zeta3 = -0.4,
alpha0 = 0.5, alpha1 = 0.5, alpha2 = 0.4,
theta1_1 = -0.4, theta1_0 = -0.4, theta2 = 0.2,
rate_C = 0.0000855, followup = 20, days = 30,
n = 500, NSim = 100, seed = 314159)
fit1 <- msm(
sim1[[1]], id = "id", tstart = "tstart",
tstop = "tstop", event = "Y", treat = "trtrand",
swtrt = "xo", swtrt_time = "xotime", base_cov = "bprog",
numerator = "bprog", denominator = c("bprog", "L"),
ns_df = 3, swtrt_control_only = TRUE, boot = FALSE)
c(fit1$hr, fit1$hr_CI)