From ad8546a249cb31cc1d349ad5743f887e0f884b8f Mon Sep 17 00:00:00 2001 From: Isaac Gravestock Date: Fri, 21 Feb 2025 15:22:30 +0100 Subject: [PATCH 1/2] fix CRAN notes --- DESCRIPTION | 3 +- NEWS.md | 7 ++++ R/maic_anchored.R | 14 +++---- R/maic_unanchored.R | 12 +++--- inst/WORDLIST | 53 ++---------------------- tests/testthat/_snaps/maic_anchored.md | 40 +++++++++++------- tests/testthat/_snaps/maic_unanchored.md | 28 +++++++------ 7 files changed, 65 insertions(+), 92 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c36bf25f..0b0c1f22 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,6 @@ Title: Matching Adjusted Indirect Comparison Package: maicplus Version: 0.1.2 -Date: 2024-10-29 Authors@R: c( person( given = "Gregory", @@ -75,5 +74,5 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2.9000 +RoxygenNote: 7.3.2 Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index cd2d19c7..fb28282c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # maicplus 0.1.2 +- Changed the link function to binomial for RD and RR in binary analysis +- Updated vignette to recommend against bootstrap in unanchored analysis with citation +- Fix events percentage to properly incorporate weights in the report table for binary analysis +- Replace quantile function to use matrixStats package instead of desctools package +- Added testing PH assumptions vignette +- Fixed the issues with merging weights using match function + # maicplus 0.1.1 - bug fixes diff --git a/R/maic_anchored.R b/R/maic_anchored.R index 27f8db8c..cdd3cedd 100644 --- a/R/maic_anchored.R +++ b/R/maic_anchored.R @@ -485,9 +485,9 @@ maic_anchored_binary <- function(res, # ~~~ Analysis table # : set up proper link glm_link <- switch(eff_measure, - "RD" = binomial(link = "identity"), - "RR" = binomial(link = "log"), - "OR" = binomial(link = "logit") + "RD" = "identity", + "RR" = "log", + "OR" = "logit" ) res_template <- list( est = NA, @@ -498,9 +498,9 @@ maic_anchored_binary <- function(res, ) # : fit glm for binary outcome and robust estimate with weights - binobj_ipd <- glm(RESPONSE ~ ARM, ipd, family = glm_link) - binobj_ipd_adj <- suppressWarnings(glm(RESPONSE ~ ARM, ipd, weights = weights, family = glm_link)) - binobj_agd <- glm(RESPONSE ~ ARM, pseudo_ipd, family = glm_link) + binobj_ipd <- glm(RESPONSE ~ ARM, ipd, family = binomial(link = glm_link)) + binobj_ipd_adj <- suppressWarnings(glm(RESPONSE ~ ARM, ipd, weights = weights, family = binomial(link = glm_link))) + binobj_agd <- glm(RESPONSE ~ ARM, pseudo_ipd, family = binomial(link = glm_link)) bin_robust_cov <- sandwich::vcovHC(binobj_ipd_adj, type = binary_robust_cov_type) bin_robust_coef <- lmtest::coeftest(binobj_ipd_adj, vcov. = bin_robust_cov) @@ -571,7 +571,7 @@ maic_anchored_binary <- function(res, } boot_binobj_dat_adj <- suppressWarnings( - glm(RESPONSE ~ ARM, boot_ipd, weights = boot_ipd$weights, family = glm_link) + glm(RESPONSE ~ ARM, boot_ipd, weights = boot_ipd$weights, family = binomial(link = glm_link)) ) boot_AC_est <- coef(boot_binobj_dat_adj)[2] boot_AC_var <- vcov(boot_binobj_dat_adj)[2, 2] diff --git a/R/maic_unanchored.R b/R/maic_unanchored.R index a69ee788..292e3390 100644 --- a/R/maic_unanchored.R +++ b/R/maic_unanchored.R @@ -355,9 +355,9 @@ maic_unanchored_binary <- function(res, # ~~~ Analysis table # : set up proper link glm_link <- switch(eff_measure, - "RD" = binomial(link = "identity"), - "RR" = binomial(link = "log"), - "OR" = binomial(link = "logit") + "RD" = "identity", + "RR" = "log", + "OR" = "logit" ) transform_estimate <- switch(eff_measure, "RD" = function(x) x * 100, @@ -366,8 +366,8 @@ maic_unanchored_binary <- function(res, ) # : fit glm for binary outcome and robust estimate with weights - binobj_dat <- glm(RESPONSE ~ ARM, dat, family = glm_link) - binobj_dat_adj <- suppressWarnings(glm(RESPONSE ~ ARM, dat, weights = weights, family = glm_link)) + binobj_dat <- glm(RESPONSE ~ ARM, dat, family = binomial(link = glm_link)) + binobj_dat_adj <- suppressWarnings(glm(RESPONSE ~ ARM, dat, weights = weights, family = binomial(link = glm_link))) bin_robust_cov <- sandwich::vcovHC(binobj_dat_adj, type = binary_robust_cov_type) bin_robust_coef <- lmtest::coeftest(binobj_dat_adj, vcov. = bin_robust_cov) @@ -424,7 +424,7 @@ maic_unanchored_binary <- function(res, } boot_dat <- rbind(boot_ipd, pseudo_ipd) boot_dat$ARM <- factor(boot_dat$ARM, levels = c(trt_agd, trt_ipd)) - boot_binobj_dat_adj <- suppressWarnings(glm(RESPONSE ~ ARM, boot_dat, weights = weights, family = glm_link)) + boot_binobj_dat_adj <- suppressWarnings(glm(RESPONSE ~ ARM, boot_dat, weights = weights, family = binomial(link = glm_link))) c(est = coef(boot_binobj_dat_adj)[2], var = vcov(boot_binobj_dat_adj)[2, 2]) } diff --git a/inst/WORDLIST b/inst/WORDLIST index 7c9bde76..21c83c49 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,26 +1,17 @@ ADaM Ades -adrs -adsl ADTTE -adtte +AGD AgD -agd agg al -Antoniou -Azocar Belleli binarize -bootswatch Bucher -bucher -Chrysostomos Comparator comparator confounders -csv -diagplot +desctools doi DSU dummize @@ -28,79 +19,43 @@ dummized ECOG ESS et -ffffff frac funder -GBB ggplot github glm -Gravestock Guyot Hoffmann -href +HTA hta -https -initializer io IPD ipd -JCC jval -Kalyvas Kaplan -kaplan -kmplot -lch -LFF Liu MAIC maic maicplus -medSurv -meier -MGG -Miranta +matrixStats MSD -multivariable -navbar -optim Paramater -ph pharma Phillippo -phillippo -png Pre pre preprocessed -Remiro -reproducibility rmean -rr Schoenfeld -schoenfeld -sd -Seo Signorovitch -signorovitch -src -ss -survfit Texp -THER TSD TTE tte -twt Unanchored unanchored -Univariable unscaled unstacked USUBJID -vcovHC Welton -ww XXXX -yy diff --git a/tests/testthat/_snaps/maic_anchored.md b/tests/testthat/_snaps/maic_anchored.md index a33106c6..819db6d8 100644 --- a/tests/testthat/_snaps/maic_anchored.md +++ b/tests/testthat/_snaps/maic_anchored.md @@ -414,7 +414,8 @@ Output $model_before_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd) Coefficients: (Intercept) ARMA @@ -426,8 +427,8 @@ $model_after_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd, weights = weights) Coefficients: (Intercept) ARMA @@ -439,7 +440,8 @@ $model_agd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = pseudo_ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = pseudo_ipd) Coefficients: (Intercept) ARMB @@ -553,7 +555,8 @@ Output $model_before_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd) Coefficients: (Intercept) ARMA @@ -565,8 +568,8 @@ $model_after_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd, weights = weights) Coefficients: (Intercept) ARMA @@ -578,7 +581,8 @@ $model_agd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = pseudo_ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = pseudo_ipd) Coefficients: (Intercept) ARMB @@ -692,7 +696,8 @@ Output $model_before_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd) Coefficients: (Intercept) ARMA @@ -704,8 +709,8 @@ $model_after_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd, weights = weights) Coefficients: (Intercept) ARMA @@ -717,7 +722,8 @@ $model_agd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = pseudo_ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = pseudo_ipd) Coefficients: (Intercept) ARMB @@ -831,7 +837,8 @@ Output $model_before_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd) Coefficients: (Intercept) ARMA @@ -843,8 +850,8 @@ $model_after_ipd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = ipd, weights = weights) Coefficients: (Intercept) ARMA @@ -856,7 +863,8 @@ $model_agd - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = pseudo_ipd) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = pseudo_ipd) Coefficients: (Intercept) ARMB diff --git a/tests/testthat/_snaps/maic_unanchored.md b/tests/testthat/_snaps/maic_unanchored.md index 5c2b9f66..5dba9eb8 100644 --- a/tests/testthat/_snaps/maic_unanchored.md +++ b/tests/testthat/_snaps/maic_unanchored.md @@ -25,7 +25,8 @@ Output $model_before - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat) Coefficients: (Intercept) ARMA @@ -37,8 +38,8 @@ $model_after - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat, weights = weights) Coefficients: (Intercept) ARMA @@ -116,7 +117,8 @@ Output $model_before - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat) Coefficients: (Intercept) ARMA @@ -128,8 +130,8 @@ $model_after - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat, weights = weights) Coefficients: (Intercept) ARMA @@ -207,7 +209,8 @@ Output $model_before - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat) Coefficients: (Intercept) ARMA @@ -219,8 +222,8 @@ $model_after - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat, weights = weights) Coefficients: (Intercept) ARMA @@ -298,7 +301,8 @@ Output $model_before - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat) Coefficients: (Intercept) ARMA @@ -310,8 +314,8 @@ $model_after - Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat, - weights = weights) + Call: glm(formula = RESPONSE ~ ARM, family = binomial(link = glm_link), + data = dat, weights = weights) Coefficients: (Intercept) ARMA From 6013e9195aaecb1ad180f243a18a666d84677306 Mon Sep 17 00:00:00 2001 From: Isaac Gravestock Date: Fri, 21 Feb 2025 15:31:16 +0100 Subject: [PATCH 2/2] checks --- .lintr | 1 - R/maic_unanchored.R | 4 +++- R/matching.R | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.lintr b/.lintr index d549a9d1..b21e005a 100644 --- a/.lintr +++ b/.lintr @@ -1,6 +1,5 @@ linters: linters_with_defaults( line_length_linter = line_length_linter(120), - cyclocomp_linter = NULL, object_usage_linter = NULL, commented_code_linter = NULL, object_name_linter = NULL diff --git a/R/maic_unanchored.R b/R/maic_unanchored.R index 292e3390..a5a5614d 100644 --- a/R/maic_unanchored.R +++ b/R/maic_unanchored.R @@ -424,7 +424,9 @@ maic_unanchored_binary <- function(res, } boot_dat <- rbind(boot_ipd, pseudo_ipd) boot_dat$ARM <- factor(boot_dat$ARM, levels = c(trt_agd, trt_ipd)) - boot_binobj_dat_adj <- suppressWarnings(glm(RESPONSE ~ ARM, boot_dat, weights = weights, family = binomial(link = glm_link))) + boot_binobj_dat_adj <- suppressWarnings( + glm(RESPONSE ~ ARM, boot_dat, weights = weights, family = binomial(link = glm_link)) + ) c(est = coef(boot_binobj_dat_adj)[2], var = vcov(boot_binobj_dat_adj)[2, 2]) } diff --git a/R/matching.R b/R/matching.R index 932f17a3..d861b894 100644 --- a/R/matching.R +++ b/R/matching.R @@ -374,7 +374,7 @@ plot_weights_ggplot <- function(weighted_data, bin_col, vline_col, ggplot2::ylab("Frequency") + ggplot2::xlab("Weight") - return(hist_plot) + hist_plot }