Skip to content

Commit 68afe5e

Browse files
committed
compute pooled cov rank mahalanobis: scale after handling ties; not quite matching reference yet
1 parent b756046 commit 68afe5e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

R/match_on.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,17 +570,17 @@ compute_pooled_cov_rank_mahalanobis <- function(index, data, z) {
570570
} else {
571571
treated <- data[z, ,drop = FALSE]
572572
nt <- nrow(treated)
573-
mt <- cov(treated) * (sum(z) - 1) / (length(z) - 2)
574-
mt <- scale_addressing_ties(nt, mt)
573+
mt <- scale_addressing_ties(nt, cov(treated))
574+
mt <- mt * (sum(z) - 1) / (length(z) - 2)
575575
}
576576

577577
if (sum(!z) == 1) {
578578
mc <- 0 # Addressing #168
579579
} else {
580580
control <- data[!z, ,drop = FALSE]
581581
nc <- nrow(control)
582-
mc <- cov(control) * (sum(!z) - 1) / (length(!z) - 2)
583-
mc <- scale_addressing_ties(nc, mc)
582+
mc <- scale_addressing_ties(nc, cov(control))
583+
mc <- mc * (sum(!z) - 1) / (length(!z) - 2)
584584
}
585585

586586
cv <- mt + mc

0 commit comments

Comments
 (0)