ipcw | R Documentation |
Uses the inverse probability of censoring weights (IPCW) method to obtain the hazard ratio estimate of the Cox model to adjust for treatment switching.
ipcw(
data,
id = "id",
stratum = "",
tstart = "tstart",
tstop = "tstop",
event = "event",
treat = "treat",
swtrt = "swtrt",
swtrt_time = "swtrt_time",
swtrt_time_lower = "",
swtrt_time_upper = "",
base_cov = "",
numerator = "",
denominator = "",
logistic_switching_model = FALSE,
strata_main_effect_only = TRUE,
firth = FALSE,
flic = FALSE,
ns_df = 3,
relative_time = TRUE,
stabilized_weights = TRUE,
trunc = 0,
trunc_upper_only = TRUE,
swtrt_control_only = TRUE,
alpha = 0.05,
ties = "efron",
boot = TRUE,
n_boot = 1000,
seed = NA
)
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. |
swtrt_time_lower |
The name of the swtrt_time_lower variable in the input data. |
swtrt_time_upper |
The name of the swtrt_time_upper 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 and time-dependent covariates (excluding treat) in the input data for the denominator switching model. |
logistic_switching_model |
Whether a pooled logistic regression switching model is used. |
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. The default is |
flic |
Whether to apply intercept correction to obtain more
accurate predicted probabilities. The default is |
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. |
relative_time |
Whether to use the time relative to
|
stabilized_weights |
Whether to use the stabilized weights. |
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. |
alpha |
The significance level to calculate confidence intervals. |
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 seed from the environment will be used if left unspecified. |
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.
Set up the crossover and event indicators for the last time interval for each subject.
For time-dependent covariates Cox switching models, replicate unique event times across treatment arms within each subject.
Fit the denominator switching model (and the numerator switching model for stabilized weights) to obtain the inverse probability of censoring weights. This can be a Cox model with time-dependent covariates or a pooled logistic regression model. For pooled logistic regression switching model, the probability of remaining uncensored (i.e., not switching) will be calculated by subtracting the predicted probability of switching from 1 and then multiplied over time up to the current time point.
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.
A list with the following components:
logrank_pvalue
: The two-sided p-value of the log-rank test
for an intention-to-treat (ITT) analysis.
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 "Cox model" or "bootstrap".
data_switch
: A list of input data for the switching models by
treatment group.
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.
fit_outcome
: The fitted outcome Cox model.
settings
: A list with the following components:
logistic_switching_model
: Whether a pooled logistic
regression switching model is used.
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.
relative_time
: Whether to use the relative time as the
intercepts.
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.
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.
hr_boots
: The bootstrap hazard ratio estimates if boot
is
TRUE
.
Kaifeng Lu, kaifenglu@gmail.com
James M. Robins and Dianne M. Finkelstein. Correcting for noncompliance and dependent censoring in an AIDS clinical trial with inverse probability of censoring weighted (IPCW) log-rank tests. Biometrics. 2000;56:779-788.
# Example 1: pooled logistic regression switching model
sim1 <- tsegestsim(
n = 500, allocation1 = 2, allocation2 = 1, pbprog = 0.5,
trtlghr = -0.5, bprogsl = 0.3, shape1 = 1.8,
scale1 = 0.000025, shape2 = 1.7, scale2 = 0.000015,
pmix = 0.5, admin = 5000, pcatnotrtbprog = 0.5,
pcattrtbprog = 0.25, pcatnotrt = 0.2, pcattrt = 0.1,
catmult = 0.5, tdxo = 1, ppoor = 0.1, pgood = 0.04,
ppoormet = 0.4, pgoodmet = 0.2, xomult = 1.4188308,
milestone = 546, swtrt_control_only = TRUE,
outputRawDataset = 1, seed = 2000)
fit1 <- ipcw(
sim1$paneldata, id = "id", tstart = "tstart",
tstop = "tstop", event = "died", treat = "trtrand",
swtrt = "xo", swtrt_time = "xotime",
swtrt_time_lower = "timePFSobs",
swtrt_time_upper = "xotime_upper", base_cov = "bprog",
numerator = "bprog", denominator = "bprog*catlag",
logistic_switching_model = TRUE, ns_df = 3,
relative_time = TRUE, swtrt_control_only = TRUE,
boot = FALSE)
c(fit1$hr, fit1$hr_CI)
# Example 2: time-dependent covariates Cox switching model
fit2 <- ipcw(
shilong, id = "id", tstart = "tstart", tstop = "tstop",
event = "event", treat = "bras.f", swtrt = "co",
swtrt_time = "dco",
base_cov = c("agerand", "sex.f", "tt_Lnum", "rmh_alea.c",
"pathway.f"),
numerator = c("agerand", "sex.f", "tt_Lnum", "rmh_alea.c",
"pathway.f"),
denominator = c("agerand", "sex.f", "tt_Lnum", "rmh_alea.c",
"pathway.f", "ps", "ttc", "tran"),
swtrt_control_only = FALSE, boot = FALSE)
c(fit2$hr, fit2$hr_CI)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.