Skip to contents

Weighted ranks and concentration-index scoring

rank_wt(c(10, 20, 30), c(1, 1, 2))
#> [1] 0.125 0.375 0.750
rank_wt(c(1, 2, NA, 3), c(1, 0, 1, 2))
#> [1] 0.1666667 0.6666667
ci <- ci_factory("CI")
y <- cbind(c(10, 20, 30), c(1, 0, 1))
ci(y, c(1, 1, 2))
#> [1] 0.08333333
cig <- ci_factory("CIg")
cig(y, c(1, 1, 2))
#> [1] 0.0625
cic <- ci_factory("CIc")
cic(y, c(1, 1, 2))
#> [1] 0.25
l_index <- ci_factory("L")
l_index(y, c(1, 1, 2))
#> [1] 0.02777778
y <- cbind(
  ses = c(10, 20, 30, 40, 50, 60),
  health = c(1, 0, 1, 0, 1, 1)
)
wt <- rep(1, 6)

# A candidate split evaluated outside any tree-fitting routine
left <- c(TRUE, TRUE, TRUE, FALSE, FALSE, FALSE)

weighted_ci_gain(y, wt, left, ci_factory("CI"))
#> [1] -0.08333333