Skip to content

Commit

Permalink
fix covariate balance type
Browse files Browse the repository at this point in the history
  • Loading branch information
Naeemkh committed Mar 5, 2024
1 parent d23c661 commit 53c8498
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 0 additions & 6 deletions R/check_covar_balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ check_covar_balance <- function(w,
post_process_abs <- function(abs_cor) {

covar_bl_t <- paste0(covar_bl_trs_type, "_absolute_corr")
logger::log_debug(paste0(covar_bl_trs_type,
" absolute correlation: ",
getElement(abs_cor, covar_bl_t)))
message(paste0(covar_bl_trs_type, " absolute correlation: ",
getElement(abs_cor, covar_bl_t),
"| Covariate balance threshold: ", covar_bl_trs))

output <- list(corr_results = abs_cor)

Expand Down
14 changes: 9 additions & 5 deletions R/generate_pseudo_pop.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ generate_pseudo_pop <- function(.data,
covar_bl_trs = covar_bl_trs,
covar_bl_trs_type = covar_bl_trs_type)

covar_bl_t <- paste0(covar_bl_trs_type, "_absolute_corr")
message(paste0(covar_bl_trs_type, " absolute correlation (original): ",
getElement(original_corr_obj$corr_results, covar_bl_t),
"| Covariate balance threshold: ", covar_bl_trs))

# Check covariate balance for weighted/matched data, and trimmed if any
adjusted_corr_obj <- check_covar_balance(
w = merged_data[, c(exposure_col)],
Expand All @@ -130,6 +135,10 @@ generate_pseudo_pop <- function(.data,
covar_bl_trs = covar_bl_trs,
covar_bl_trs_type = covar_bl_trs_type)

message(paste0(covar_bl_trs_type, " absolute correlation (adjusted): ",
getElement(adjusted_corr_obj$corr_results, covar_bl_t),
"| Covariate balance threshold: ", covar_bl_trs))

# check Kolmogorov-Smirnov statistics
ks_stats <- check_kolmogorov_smirnov(w = merged_data[, c(exposure_col)],
c = merged_data[, covariate_cols],
Expand Down Expand Up @@ -181,11 +190,6 @@ generate_pseudo_pop <- function(.data,

end_time_gpp <- proc.time()

# logger::log_debug("Wall clock time to run generate_pseudo_pop:",
# " {(end_time_gpp - st_time_gpp)[[3]]} seconds.")
# logger::log_debug("Covariate balance condition has been met (TRUE/FALSE):",
# " {adjusted_corr_obj$pass}, (iteration:",
# " {counter} / {max_attempt})")
invisible(result)
}

0 comments on commit 53c8498

Please sign in to comment.