MBdelayed | R Documentation |
Magirr and Burman (2019) considered several scenarios for their modestly weighted logrank test.
One of these had a delayed treatment effect with a hazard ratio of 1 for 6 months followed by a hazard ratio of 1/2
thereafter.
The scenario enrolled 200 patients uniformly over 12 months and
cut data for analysis 36 months after enrollment was opened.
This dataset was generated by the simtrial::sim_pw_surv()
function under the above scenario.
MBdelayed
A tibble with 200 rows and xx columns
time to event
Magirr, Dominic, and CarlāFredrik Burman. "Modestly weighted logrank tests." Statistics in Medicine 38.20 (2019): 3782-3790.
library(tidyr)
library(dplyr)
library(survival)
library(mvtnorm)
fit <- survfit(Surv(tte, event) ~ Treatment, data = MBdelayed)
# Plot survival
plot(fit, lty=1:2)
legend("topright", legend = c("Control", "Experimental"), lty = 1:2)
# Set up time, event, number of event dataset for testing
# with arbitrary weights
ten <- MBdelayed %>% counting_process(arm = "Experimental")
head(ten)
# MaxCombo with logrank, FH(0,1), FH(1,1)
ten %>% tenFHcorr(rg = tibble(rho=c(0, 0, 1), gamma = c(0, 1, 1))) %>%
pvalue_maxcombo()
# Magirr-Burman modestly down-weighted rank test with 6 month delay
# First, add weights
ten <- ten %>% mb_weight(6)
head(ten)
# Now compute test based on these weights
ten %>% summarise(S = sum(o_minus_e*mb_weight),
V = sum(var_o_minus_e*mb_weight^2),
Z = S/sqrt(V)) %>%
mutate(p = pnorm(Z))
# Create 0 weights for first 6 months
ten <- ten %>% mutate(w6 = 1 * (tte >= 6))
ten %>% summarise(S = sum(o_minus_e*w6),
V = sum(var_o_minus_e*w6^2),
Z = S/sqrt(V)) %>%
mutate(p=pnorm(Z))
# Generate another dataset
ds <- sim_pw_surv(n = 200,
enroll_rate = tibble(rate = 200 / 12, duration = 12),
fail_rate = tribble(
~Stratum, ~Period, ~Treatment, ~duration, ~rate,
"All", 1, "Control", 42, log(2) / 15,
"All", 1, "Experimental", 6, log(2) / 15,
"All", 2, "Experimental", 36, log(2) / 15 * 0.6),
dropoutRates = tribble(
~Stratum, ~Period, ~Treatment, ~duration, ~rate,
"All", 1, "Control", 42, 0,
"All", 1, "Experimental", 42, 0)
)
# Cut data at 24 months after final enrollment
MBdelayed2 <- ds %>% cut_data_by_date(max(ds$enroll_time) + 24)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.