Skip to content

Commit

Permalink
add overallW object back in
Browse files Browse the repository at this point in the history
  • Loading branch information
fanbu1995 committed Dec 6, 2023
1 parent 0864621 commit 18634a3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/Balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ computeMeansPerGroup <- function(cohorts, cohortMethodData) {
# Variable strata sizes detected: weigh by size of strata set
w <- stratumSize %>%
mutate(weight = 1/.data$n) %>%
inner_join(cohorts, by = c("stratumId", "treatment")) %>%
select(.data$rowId, .data$treatment, .data$weight)
inner_join(cohorts, by = c("stratumId", "treatment"), copy = TRUE) %>%
select("rowId", "treatment", "weight")

# Overall weight is for computing mean and SD across T and C
overallW <- stratumSize %>%
group_by(.data$stratumId) %>%
summarise(weight = 1 / sum(.data$n, na.rm = TRUE)) %>%
ungroup() %>%
inner_join(cohorts, by = c("stratumId"), copy = TRUE) %>%
select("rowId", "weight")

# Normalize so sum(weight) == 1 per treatment arm:
wSum <- w %>%
Expand Down

0 comments on commit 18634a3

Please sign in to comment.