Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace desctools::Quantile with matrixStats::weightedMedian #181

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- plumber
- shiny
- lubridate
- DescTools
- matrixStats
- lmtest
- sandwich
# codemeta must be above use-tidy-description when both are used
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -51,7 +51,7 @@ Imports:
stats,
survival,
lubridate,
DescTools,
matrixStats,
MASS,
boot,
stringr,
Expand All @@ -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
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# maicplus 0.1.2

# maicplus 0.1.1

- bug fixes
Expand Down
1 change: 0 additions & 1 deletion R/maicplus-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ NULL
#' @importFrom grDevices col2rgb rgb
#' @import stats
#' @import survival
#' @import DescTools
#' @import MASS
#' @import boot
#' @import stringr
Expand Down
13 changes: 5 additions & 8 deletions R/matching.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion man/check_weights.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.