Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 7 additions & 2 deletions R/matching.R
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,11 @@ plot.maicplus_estimate_weights <- function(x, ggplot = FALSE,

#' Check to see if weights are optimized correctly
#'
#' This function checks to see if the optimization is done properly by checking the covariate averages
#' before and after adjustment.
#' This function checks to see if the optimization is done properly
#' by checking the covariate averages before and after adjustment.
#' In case of ties when calculating median,
#' we return the mean of the two numbers. For more details,
#' see [ties] parameter in [matrixStats::weightedMedian].
#'
#' @param weighted_data object returned after calculating weights using \code{\link{estimate_weights}}
#' @param processed_agd a data frame, object returned after using \code{\link{process_agd}} or
Expand Down Expand Up @@ -487,6 +490,8 @@ check_weights <- function(weighted_data, processed_agd) {
outdata$internal_trial_after_weighted[ii] <- weightedMedian(
x = ipd_with_weights[[covname]],
w = ipd_with_weights$weights,
interpolate = FALSE,
ties = "mean",
na.rm = TRUE
)
# no IPD equals to reported AgD median
Expand Down
7 changes: 5 additions & 2 deletions man/check_weights.Rd

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