From 8ab47726cde9325d17e8b9784a2550609215c7d3 Mon Sep 17 00:00:00 2001 From: Kuenzel Date: Mon, 5 Feb 2024 17:22:14 +0100 Subject: [PATCH 01/11] initial commit, doesnt work yet: issues with incidence proportion (returns 1,0 always) --- vignettes/savvyr_example.Rmd | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 vignettes/savvyr_example.Rmd diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd new file mode 100644 index 0000000..9bf78d7 --- /dev/null +++ b/vignettes/savvyr_example.Rmd @@ -0,0 +1,111 @@ +--- +title: "SAVVY: estimation of AE probabilities" +package: savvyr +output: + rmarkdown::html_vignette: + toc: true +vignette: | + %\VignetteEncoding{UTF-8} + %\VignetteIndexEntry{SAVVY: estimation of AE probabilities} + %\VignetteEngine{knitr::rmarkdown} +editor_options: + chunk_output_type: console +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + + +```{r, include=TRUE, echo=TRUE} +# packages +packs <- c("data.table", "etm", "survival", "mvna", "knitr", "kableExtra") +for (i in 1:length(packs)){library(packs[i], character.only = TRUE)} +``` + +# Estimation of AE probabilities + +We generate the dataset $S1$ in @stegherr_20_sap using the parameter values for Arm A: + +```{r, include=TRUE, echo=TRUE} + +# sample size +N <- 200 + +# support of uniform censoring distribution +min.cens <- 0 +max.cens <- 1000 + +# hazards for the three event types +haz.AE <- 0.00265 +haz.death <- 0.00151 +haz.soft <- 0.00227 + + + +# generate dataset +set.seed(2020) +dat1 <- generate_data(N, cens = c(min.cens, max.cens), haz.AE, haz.death, haz.soft) + + +# compute tau +tau <- max(dat1[, "time_to_event"]) +``` + +The structure of the dataset looks as follows: + +```{r, include=TRUE, echo=TRUE} +kable(head(dat1, 10), align = c("crcr")) +``` + +For this dataset we then compute all the estimators that enter the comparison in our papers: + +```{r, include=TRUE, echo=TRUE} + +# compute each estimator +IP <- inc_prop(dat1, tau) +ID <- prop_trans_inc_dens(dat1, tau) +KM <- one_minus_kaplan_meier(dat1, tau) + +# competing event "death only" +IDCE2 <- prop_trans_inc_dens_ce(dat1, ce = 2, tau) +AJ2 <- aalen_johansen(dat1, ce = 2, tau) + +# account for all competing events +IDCE3 <- prop_trans_inc_dens_ce(dat1, ce = 3, tau) +AJ3 <- aalen_johansen(dat1, ce = 3, tau) + +# display +tab <- rbind(IP, ID, KM, IDCE2, AJ2[1:2], IDCE3, AJ3[1:2]) +colnames(tab) <- c("estimated AE probability", "variance of estimation") +rownames(tab) <- c("incidence proportion", "probability transform incidence density ignoring competing event", + "1 - Kaplan-Meier", "probability transform incidence density (death only)", + "Aalen-Johansen (death only), AE risk", "probability transform incidence density (all CEs)", + "Aalen-Johansen (all CEs), AE risk") + +# probability of AE +kable(tab, digits = c(3, 5)) +``` + +Finally, the estimated probabilities of competing events based on the Aalen-Johansen estimators: + +```{r, include=TRUE, echo=TRUE} +# display +tab <- rbind(AJ2[3:4 ], AJ3[3:4 ]) +colnames(tab) <- c("estimated probability", "variance of estimation") +rownames(tab) <- c("Aalen-Johansen (death only), CE risk", + "Aalen-Johansen (all CEs), CE risk") + +# probability of AE +kable(tab, digits = c(3, 5)) +``` + +# References + +Rufibach, Kaspar, Regina Stegherr, Claudia Schmoor, Valentine Jehl, Arthur Allignol, Annette Boeckenhoff, Cornelia Dunger-Baldauf, et al. 2022. “Survival analysis for AdVerse events with VarYing follow-up times (SAVVY) – comparison of adverse event risks in randomized controlled trials.” Statistics in Biopharmaceutical Research, Accepted. +Stegherr, Regina, Jan Beyersmann, Valentine Jehl, Kaspar Rufibach, Friedhelm Leverkus, Claudia Schmoor, and Tim Friede. 2021. “Survival Analysis for AdVerse Events with VarYing Follow-up Times (SAVVY): Rationale and Statistical Concept of a Meta-Analytic Study.” Biometrical Journal 63 (March): 650–70. +Stegherr, R., C. Schmoor, J. Beyersmann, K. Rufibach, V. Jehl, A. Brückner, L. Eisele, et al. 2021. “Survival analysis for AdVerse events with VarYing follow-up times (SAVVY)-estimation of adverse event risks.” Trials 22 (1): 420. +Stegherr, R., C. Schmoor, M. Lübbert, T. Friede, and J. Beyersmann. 2021. “Estimating and comparing adverse event probabilities in the presence of varying follow-up times and competing events.” Pharmaceutical Statistics 20 (6): 1125–46 From de7e1696225312e7e4277fa08176d1783d762770 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:26:16 +0000 Subject: [PATCH 02/11] [skip actions] Restyle files --- vignettes/savvyr_example.Rmd | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 9bf78d7..99a6601 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -22,8 +22,10 @@ knitr::opts_chunk$set( ```{r, include=TRUE, echo=TRUE} # packages -packs <- c("data.table", "etm", "survival", "mvna", "knitr", "kableExtra") -for (i in 1:length(packs)){library(packs[i], character.only = TRUE)} +packs <- c("data.table", "etm", "survival", "mvna", "knitr", "kableExtra") +for (i in 1:length(packs)) { + library(packs[i], character.only = TRUE) +} ``` # Estimation of AE probabilities @@ -31,7 +33,6 @@ for (i in 1:length(packs)){library(packs[i], character.only = TRUE)} We generate the dataset $S1$ in @stegherr_20_sap using the parameter values for Arm A: ```{r, include=TRUE, echo=TRUE} - # sample size N <- 200 @@ -64,7 +65,6 @@ kable(head(dat1, 10), align = c("crcr")) For this dataset we then compute all the estimators that enter the comparison in our papers: ```{r, include=TRUE, echo=TRUE} - # compute each estimator IP <- inc_prop(dat1, tau) ID <- prop_trans_inc_dens(dat1, tau) @@ -81,10 +81,12 @@ AJ3 <- aalen_johansen(dat1, ce = 3, tau) # display tab <- rbind(IP, ID, KM, IDCE2, AJ2[1:2], IDCE3, AJ3[1:2]) colnames(tab) <- c("estimated AE probability", "variance of estimation") -rownames(tab) <- c("incidence proportion", "probability transform incidence density ignoring competing event", - "1 - Kaplan-Meier", "probability transform incidence density (death only)", - "Aalen-Johansen (death only), AE risk", "probability transform incidence density (all CEs)", - "Aalen-Johansen (all CEs), AE risk") +rownames(tab) <- c( + "incidence proportion", "probability transform incidence density ignoring competing event", + "1 - Kaplan-Meier", "probability transform incidence density (death only)", + "Aalen-Johansen (death only), AE risk", "probability transform incidence density (all CEs)", + "Aalen-Johansen (all CEs), AE risk" +) # probability of AE kable(tab, digits = c(3, 5)) @@ -94,10 +96,12 @@ Finally, the estimated probabilities of competing events based on the Aalen-Joha ```{r, include=TRUE, echo=TRUE} # display -tab <- rbind(AJ2[3:4 ], AJ3[3:4 ]) +tab <- rbind(AJ2[3:4], AJ3[3:4]) colnames(tab) <- c("estimated probability", "variance of estimation") -rownames(tab) <- c("Aalen-Johansen (death only), CE risk", - "Aalen-Johansen (all CEs), CE risk") +rownames(tab) <- c( + "Aalen-Johansen (death only), CE risk", + "Aalen-Johansen (all CEs), CE risk" +) # probability of AE kable(tab, digits = c(3, 5)) From 1b801c72e693e0c3b882e8b243ffc67801ddbf19 Mon Sep 17 00:00:00 2001 From: Kuenzel Date: Wed, 7 Feb 2024 08:42:29 +0100 Subject: [PATCH 03/11] removed packages --- vignettes/savvyr_example.Rmd | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 9bf78d7..5f89544 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -17,14 +17,10 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) +library(savvyr) ``` -```{r, include=TRUE, echo=TRUE} -# packages -packs <- c("data.table", "etm", "survival", "mvna", "knitr", "kableExtra") -for (i in 1:length(packs)){library(packs[i], character.only = TRUE)} -``` # Estimation of AE probabilities From 57dae496b3574e805583d7476dfb7549974f325b Mon Sep 17 00:00:00 2001 From: Kuenzel Date: Wed, 7 Feb 2024 09:57:31 +0100 Subject: [PATCH 04/11] added kable package --- vignettes/savvyr_example.Rmd | 1 + 1 file changed, 1 insertion(+) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index adf4949..084ce0c 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -18,6 +18,7 @@ knitr::opts_chunk$set( comment = "#>" ) library(savvyr) +library(kableExtra) ``` From 4fc6d28e2f9426f128e07a3d8398bc956de8ab39 Mon Sep 17 00:00:00 2001 From: Kuenzel Date: Wed, 7 Feb 2024 12:21:44 +0100 Subject: [PATCH 05/11] updated references --- vignettes/savvyr_example.Rmd | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 084ce0c..7947a4d 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -1,12 +1,13 @@ --- -title: "SAVVY: estimation of AE probabilities" +title: "Estimation of AE probabilities with savvyr" package: savvyr +bibliography: "../inst/REFERENCES.bib" output: rmarkdown::html_vignette: toc: true vignette: | %\VignetteEncoding{UTF-8} - %\VignetteIndexEntry{SAVVY: estimation of AE probabilities} + %\VignetteIndexEntry{Estimation of AE probabilities with savvyr} %\VignetteEngine{knitr::rmarkdown} editor_options: chunk_output_type: console @@ -24,9 +25,10 @@ library(kableExtra) -# Estimation of AE probabilities +# Example with dummy data -We generate the dataset $S1$ in @stegherr_20_sap using the parameter values for Arm A: + +We generate the dataset $S1$ in @stegherr_meta_analytic_2021 using the parameter values for Arm A: ```{r, include=TRUE, echo=TRUE} # sample size @@ -106,6 +108,9 @@ kable(tab, digits = c(3, 5)) # References Rufibach, Kaspar, Regina Stegherr, Claudia Schmoor, Valentine Jehl, Arthur Allignol, Annette Boeckenhoff, Cornelia Dunger-Baldauf, et al. 2022. “Survival analysis for AdVerse events with VarYing follow-up times (SAVVY) – comparison of adverse event risks in randomized controlled trials.” Statistics in Biopharmaceutical Research, Accepted. -Stegherr, Regina, Jan Beyersmann, Valentine Jehl, Kaspar Rufibach, Friedhelm Leverkus, Claudia Schmoor, and Tim Friede. 2021. “Survival Analysis for AdVerse Events with VarYing Follow-up Times (SAVVY): Rationale and Statistical Concept of a Meta-Analytic Study.” Biometrical Journal 63 (March): 650–70. -Stegherr, R., C. Schmoor, J. Beyersmann, K. Rufibach, V. Jehl, A. Brückner, L. Eisele, et al. 2021. “Survival analysis for AdVerse events with VarYing follow-up times (SAVVY)-estimation of adverse event risks.” Trials 22 (1): 420. -Stegherr, R., C. Schmoor, M. Lübbert, T. Friede, and J. Beyersmann. 2021. “Estimating and comparing adverse event probabilities in the presence of varying follow-up times and competing events.” Pharmaceutical Statistics 20 (6): 1125–46 + + + + + + From 146e6b7311095d6bebab2c937ea985ba902bf31d Mon Sep 17 00:00:00 2001 From: Kuenzel Date: Thu, 8 Feb 2024 17:28:27 +0100 Subject: [PATCH 06/11] removed comments in code and added as text. --- vignettes/savvyr_example.Rmd | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 6bd8d7a..f1f7ba6 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -28,7 +28,8 @@ library(kableExtra) # Example using dummy data We generate the dataset $S1$ in @stegherr_meta_analytic_2021 using the parameter -values for Arm A: +values for Arm A. +First we define sample size and range of censoring times. Then we set the hazard of the three event types (adverse event, death/hard competing event and soft competing event). After the dataset has been generated we set $\tau$ as the maximum event time. ```{r, include=TRUE, echo=TRUE} # sample size @@ -43,13 +44,10 @@ haz_ae <- 0.00265 haz_death <- 0.00151 haz_soft <- 0.00227 - - # generate dataset set.seed(2020) dat1 <- generate_data(n, cens = c(min_cens, max_cens), haz_ae, haz_death, haz_soft) - # compute tau tau <- max(dat1[, "time_to_event"]) ``` @@ -61,23 +59,25 @@ kable(head(dat1, 10), align = c("crcr")) ``` For this dataset we then compute all the estimators used in the comparisons -in @stegherr_survival_2021 and @stegherr_estimating_2021: +in @stegherr_survival_2021 and @stegherr_estimating_2021. +We start with the estimators that do not account for competing events (incidence proportion, incidence density, 1- Kaplan Meier), then incidence proportion accounting for competing events and Aalen-Johansen (both first with death only as hard competing event, then using all competing events): ```{r, include=TRUE, echo=TRUE} -# compute each estimator + ip <- inc_prop(dat1, tau) id <- prop_trans_inc_dens(dat1, tau) km <- one_minus_kaplan_meier(dat1, tau) -# competing event "death only" idce_2 <- prop_trans_inc_dens_ce(dat1, ce = 2, tau) aj_2 <- aalen_johansen(dat1, ce = 2, tau) -# account for all competing events idce_3 <- prop_trans_inc_dens_ce(dat1, ce = 3, tau) aj_3 <- aalen_johansen(dat1, ce = 3, tau) +``` + +The AE risks look as follows: -# display +```{r, include=TRUE, echo=TRUE} tab <- rbind(ip, id, km, idce_2, aj_2[1:2], idce_3, aj_3[1:2]) colnames(tab) <- c( "estimated AE probability", @@ -91,7 +91,6 @@ rownames(tab) <- c( "Aalen-Johansen (all CEs), AE risk" ) -# probability of AE kable(tab, digits = c(3, 5)) ``` @@ -99,7 +98,7 @@ Finally, the estimated probabilities of competing events based on the Aalen-Johansen estimators: ```{r, include=TRUE, echo=TRUE} -# display + tab <- rbind(aj_2[3:4], aj_3[3:4]) colnames(tab) <- c("estimated probability", "variance of estimation" @@ -109,7 +108,6 @@ rownames(tab) <- c( "Aalen-Johansen (all CEs), CE risk" ) -# probability of AE kable(tab, digits = c(3, 5)) ``` From 9ef9d67d00ea0644b62f88d1f4cbec9d05d281c2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 08:06:52 +0000 Subject: [PATCH 07/11] [skip actions] Restyle files --- vignettes/savvyr_example.Rmd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 0db878c..639cb4b 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -32,7 +32,6 @@ values for Arm A. First we define sample size and range of censoring times. Then we set the hazard of the three event types (adverse event, death/hard competing event and soft competing event). After the dataset has been generated we set $\tau$ as the maximum event time. ```{r, include=TRUE, echo=TRUE} - n <- 200 min_cens <- 0 @@ -59,7 +58,6 @@ in @stegherr_survival_2021 and @stegherr_estimating_2021. We start with the estimators that do not account for competing events (incidence proportion, incidence density, 1- Kaplan Meier), then incidence proportion accounting for competing events and Aalen-Johansen (both first with death only as hard competing event, then using all competing events): ```{r, include=TRUE, echo=TRUE} - ip <- inc_prop(dat1, tau) id <- prop_trans_inc_dens(dat1, tau) km <- one_minus_kaplan_meier(dat1, tau) @@ -94,10 +92,10 @@ Finally, the estimated probabilities of competing events based on the Aalen-Johansen estimators: ```{r, include=TRUE, echo=TRUE} - tab <- rbind(aj_2[3:4], aj_3[3:4]) -colnames(tab) <- c("estimated probability", - "variance of estimation" +colnames(tab) <- c( + "estimated probability", + "variance of estimation" ) rownames(tab) <- c( "Aalen-Johansen (death only), CE risk", From d7e99c020efc34054807724bb82d7f3d0af74b6a Mon Sep 17 00:00:00 2001 From: Kuenzel Date: Fri, 9 Feb 2024 09:55:32 +0100 Subject: [PATCH 08/11] considered line length --- vignettes/savvyr_example.Rmd | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 639cb4b..56cef11 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -29,7 +29,10 @@ library(kableExtra) We generate the dataset $S1$ in @stegherr_meta_analytic_2021 using the parameter values for Arm A. -First we define sample size and range of censoring times. Then we set the hazard of the three event types (adverse event, death/hard competing event and soft competing event). After the dataset has been generated we set $\tau$ as the maximum event time. +First we define sample size and range of censoring times. Then we set the hazard +of the three event types (adverse event, death/hard competing event and soft +competing event). After the dataset has been generated we set $\tau$ as the +maximum event time. ```{r, include=TRUE, echo=TRUE} n <- 200 @@ -55,7 +58,10 @@ kable(head(dat1, 10), align = c("crcr")) For this dataset we then compute all the estimators used in the comparisons in @stegherr_survival_2021 and @stegherr_estimating_2021. -We start with the estimators that do not account for competing events (incidence proportion, incidence density, 1- Kaplan Meier), then incidence proportion accounting for competing events and Aalen-Johansen (both first with death only as hard competing event, then using all competing events): +We start with the estimators that do not account for competing events (incidence +proportion, incidence density, 1- Kaplan Meier), then incidence proportion +accounting for competing events and Aalen-Johansen (both first with death only +as hard competing event, then using all competing events): ```{r, include=TRUE, echo=TRUE} ip <- inc_prop(dat1, tau) From 8902b1a358d4a35332d11b45560b829f42ea3e77 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Fri, 9 Feb 2024 14:07:24 +0100 Subject: [PATCH 09/11] minor updates --- vignettes/savvyr_example.Rmd | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/vignettes/savvyr_example.Rmd b/vignettes/savvyr_example.Rmd index 639cb4b..88a614c 100644 --- a/vignettes/savvyr_example.Rmd +++ b/vignettes/savvyr_example.Rmd @@ -22,12 +22,9 @@ library(savvyr) library(kableExtra) ``` - - - # Example using dummy data -We generate the dataset $S1$ in @stegherr_meta_analytic_2021 using the parameter +We generate the dataset $S1$ in @stegherr_meta_analytic_2021 using the parameter values for Arm A. First we define sample size and range of censoring times. Then we set the hazard of the three event types (adverse event, death/hard competing event and soft competing event). After the dataset has been generated we set $\tau$ as the maximum event time. @@ -55,7 +52,7 @@ kable(head(dat1, 10), align = c("crcr")) For this dataset we then compute all the estimators used in the comparisons in @stegherr_survival_2021 and @stegherr_estimating_2021. -We start with the estimators that do not account for competing events (incidence proportion, incidence density, 1- Kaplan Meier), then incidence proportion accounting for competing events and Aalen-Johansen (both first with death only as hard competing event, then using all competing events): +We start with the estimators that do not account for competing events (incidence proportion, incidence density, Inverse Kaplan Meier), then incidence proportion accounting for competing events and Aalen-Johansen (both first with death only as hard competing event, then using all competing events): ```{r, include=TRUE, echo=TRUE} ip <- inc_prop(dat1, tau) @@ -105,11 +102,4 @@ rownames(tab) <- c( kable(tab, digits = c(3, 5)) ``` - # References - - - - - - From e0f8e8b44b1ed5124a431216f4013367d2fea355 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Fri, 9 Feb 2024 14:46:58 +0100 Subject: [PATCH 10/11] add rmarkdown --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index ec596a5..697c5e9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,6 +31,7 @@ Imports: Rdpack Suggests: knitr, + rmarkdown, testthat (>= 2.0), roxytypes, roxylint From 41357f4f1de8544d49ab10e513be35b8de785e48 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Fri, 9 Feb 2024 14:53:42 +0100 Subject: [PATCH 11/11] one more pkg missing --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 697c5e9..35c7d8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,6 +30,7 @@ Imports: etm, Rdpack Suggests: + kableExtra, knitr, rmarkdown, testthat (>= 2.0),