## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, message = FALSE, fig.width = 6, fig.height = 4, comment = "#>" ) ## ----setup, include = FALSE--------------------------------------------------- library(tipse) library(survival) library(dplyr) library(ggplot2) ## ----data--------------------------------------------------------------------- knitr::kable(codebreak200[1:5, ]) ## ----data-censor-------------------------------------------------------------- codebreak200 %>% count(TRT01P, CNSRRS) ## ----cox-fit------------------------------------------------------------------ cox1 <- coxph(Surv(AVAL, EVENT) ~ TRT01P, data = codebreak200) ## ----tipping-point-percentile, cache=TRUE------------------------------------- tp_percentile <- tipping_point_model_free( dat = codebreak200, reason = "Early dropout", impute = "docetaxel", J = 100, tipping_range = seq(5, 95, by = 5), cox_fit = cox1, method = "percentile sampling", seed = 12345 ) ## ----tipping-point-landmark, cache=TRUE--------------------------------------- tp_landmark <- tipping_point_model_free( dat = codebreak200, reason = "Early dropout", impute = "docetaxel", J = 100, tipping_range = 1:20, cox_fit = cox1, method = "landmark sampling", seed = 12345 ) ## ----plot-percentile-km, cache=TRUE------------------------------------------- plot(tp_percentile, type = "Kaplan-Meier") ## ----plot-landmark-km, cache=TRUE--------------------------------------------- plot(tp_landmark, type = "Kaplan-Meier") ## ----plot-percentile-tp, cache=TRUE------------------------------------------- plot(tp_percentile, type = "Tipping Point") ## ----plot-landmark-tp, cache=TRUE--------------------------------------------- plot(tp_landmark, type = "Tipping Point") ## ----summary-model-free, cache=TRUE------------------------------------------- summary(tp_percentile) summary(tp_landmark) ## ----assess-model-bree-------------------------------------------------------- assess_plausibility(tp_percentile) assess_plausibility(tp_landmark) ## ----tipping-point-hazard-deflation, cache=TRUE------------------------------- tp_model_based <- tipping_point_model_based( dat = codebreak200, reason = "Early dropout", impute = "docetaxel", imputation_model = "weibull", J = 100, tipping_range = seq(0.1, 1, by = 0.1), cox_fit = cox1, seed = 12345 ) ## ----plot-model-based-KM, cache=TRUE------------------------------------------ plot(tp_model_based, type = "Kaplan-Meier") ## ----plot-model-based-hazard-inflation, cache=TRUE---------------------------- plot(tp_model_based, type = "Tipping Point") + scale_x_reverse() ## ----summary-model-based, cache=TRUE------------------------------------------ summary(tp_model_based) ## ----assess-model-based, cache=TRUE------------------------------------------- assess_plausibility(tp_model_based) ## ----------------------------------------------------------------------------- knitr::kable(extenet[seq(1, 2000, by = 400), ]) ## ----------------------------------------------------------------------------- cox2 <- coxph(Surv(AVAL, EVENT) ~ TRT01P, data = extenet) summary_cox2 <- summary(cox2) ## Extract HR for treatment vs reference orig_HR <- summary_cox2$coefficients[, "exp(coef)"] orig_HR ## ----------------------------------------------------------------------------- j2r_inflation <- 1 / orig_HR j2r_inflation ## ----cache = TRUE------------------------------------------------------------- j2r <- tipping_point_model_based( dat = extenet, reason = "Lost to follow-up", impute = "neratinib", # treatment arm with dropouts imputation_model = "weibull", J = 100, tipping_range = j2r_inflation, # J2R through hazard inflation cox_fit = cox2, seed = 12345 ) ## ----------------------------------------------------------------------------- j2r$imputation_results