Skip to content

Commit

Permalink
patch on covariate balance computing function
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan Bu committed Mar 26, 2024
1 parent 439ffa2 commit 9d4e10c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/CovariateBalance.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,16 @@ computeBalance <- function(subset,
stratifiedPop <- CohortMethod::stratifyByPs(population = studyPop,
numberOfStrata = stratifyByPsArgs$numberOfStrata,
baseSelection = stratifyByPsArgs$baseSelection)

## Patch: what if PS model is degenerated so stratification is ill-behaved?

fileName <- file.path(balanceFolder, paste0("bal_t",
subset$targetId[1],
"_c",
subset$comparatorId[1],
"_a6.rds")) # analysisId == ITT stratification
if (!file.exists(fileName)) {
## check to make sure the population table is workable
if (!file.exists(fileName) && nrow(stratifiedPop) > 0 && "stratumId" %in% names(stratifiedPop)) {
ParallelLogger::logTrace("Creating stratified balance file " , fileName)
balance <- CohortMethod::computeCovariateBalance(population = stratifiedPop,
cohortMethodData = cmData)
Expand Down

0 comments on commit 9d4e10c

Please sign in to comment.