diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7ee949c..077837b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - plumber - shiny - lubridate - - DescTools + - matrixStats - lmtest - sandwich # codemeta must be above use-tidy-description when both are used diff --git a/DESCRIPTION b/DESCRIPTION index 58901d05..c36bf25f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Title: Matching Adjusted Indirect Comparison Package: maicplus -Version: 0.1.1 +Version: 0.1.2 Date: 2024-10-29 Authors@R: c( person( @@ -51,7 +51,7 @@ Imports: stats, survival, lubridate, - DescTools, + matrixStats, MASS, boot, stringr, @@ -75,5 +75,5 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.2.9000 Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index d70bff0d..8f374580 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -29,7 +29,6 @@ export(plot_weights_ggplot) export(process_agd) export(set_time_conversion) export(survfit_makeup) -import(DescTools) import(MASS) import(boot) import(graphics) @@ -43,6 +42,7 @@ importFrom(grDevices,col2rgb) importFrom(grDevices,rgb) importFrom(lmtest,coefci) importFrom(lmtest,coeftest) +importFrom(matrixStats,weightedMedian) importFrom(sandwich,vcovHC) importFrom(survival,Surv) importFrom(survival,coxph) diff --git a/NEWS.md b/NEWS.md index b17b852d..cd2d19c7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# maicplus 0.1.2 + # maicplus 0.1.1 - bug fixes diff --git a/R/maicplus-package.R b/R/maicplus-package.R index 47cf8d2e..92e88d84 100644 --- a/R/maicplus-package.R +++ b/R/maicplus-package.R @@ -11,7 +11,6 @@ NULL #' @importFrom grDevices col2rgb rgb #' @import stats #' @import survival -#' @import DescTools #' @import MASS #' @import boot #' @import stringr diff --git a/R/matching.R b/R/matching.R index 10907e19..85294ff3 100644 --- a/R/matching.R +++ b/R/matching.R @@ -432,8 +432,7 @@ plot.maicplus_estimate_weights <- function(x, ggplot = FALSE, #' data(weighted_sat) #' data(agd) #' check_weights(weighted_sat, process_agd(agd)) -#' -#' @import DescTools +#' @importFrom matrixStats weightedMedian #' #' @return data.frame of weighted and unweighted covariate averages of the IPD, #' average of aggregate data, and sum of inner products of covariate \eqn{x_i} and the weights (\eqn{exp(x_i\beta)}) @@ -485,12 +484,10 @@ check_weights <- function(weighted_data, processed_agd) { type = 2, names = FALSE ) # SAS default - outdata$internal_trial_after_weighted[ii] <- DescTools::Quantile(ipd_with_weights[[covname]], - weights = ipd_with_weights$weights, - probs = 0.5, - na.rm = TRUE, - type = 5, - names = FALSE + outdata$internal_trial_after_weighted[ii] <- weightedMedian( + x = ipd_with_weights[[covname]], + w = ipd_with_weights$weights, + na.rm = TRUE ) # no IPD equals to reported AgD median msg_ind <- !any(ipd_with_weights[[covname]] == outdata$external_trial[ii], na.rm = TRUE) diff --git a/man/check_weights.Rd b/man/check_weights.Rd index e52b516b..6da46394 100644 --- a/man/check_weights.Rd +++ b/man/check_weights.Rd @@ -51,5 +51,4 @@ before and after adjustment. data(weighted_sat) data(agd) check_weights(weighted_sat, process_agd(agd)) - }