Skip to content

Commit aa5534a

Browse files
committed
Update calc_bal_stats.R
omitting bal_stats_histories that are all 1s for balance stats weighting
1 parent 0feb0de commit aa5534a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

R/calc_bal_stats.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ calc_bal_stats <- function(data, obj, weights = NULL, balance_thresh = NULL, imp
123123
)
124124
} # ends hist exc
125125

126-
# added by IS 4/8/26 to skip histories for which exposures are all 0s (cannot calc bal stats)
126+
# added by IS 4/8/26 to skip histories for which exposures are all 0s or all 1s (cannot calc bal stats)
127127
omitted_histories <- Filter(
128128
function(h) {
129129
which_idx <- (history == h)
130-
sum(data[[exposure_name]][which_idx]) == 0
130+
vals <- data[[exposure_name]][which_idx]
131+
all(vals == 0) || all(vals == 1)
131132
},
132133
setdiff(prop_sum$history, omitted_histories)
133134
)

0 commit comments

Comments
 (0)