Skip to contents

Applies a fitted greedy CI tree to validation data, assigns each validation observation to a terminal node, and computes the reduction from root concentration-index impurity to weighted within-terminal-node impurity.

A larger value means that the fitted partition leaves less within-node socioeconomic inequality in the held-out data.

Usage

ci_tree_validation_gain(
  fit,
  new_data,
  rank_name,
  outcome_name,
  weights = NULL,
  type = c("CI", "CIg", "CIc", "L"),
  root_impurity = NULL
)

Arguments

fit

A fitted ci_tree or other object inheriting from party.

new_data

Validation data.

rank_name

Name of the socioeconomic ranking column.

outcome_name

Name of the outcome column.

weights

Optional non-negative validation weights.

type

One of "CI", "CIg", "CIc", or "L" selecting the inequality index used for validation scoring. "L" uses observed socioeconomic levels in the first response column rather than fractional ranks.

root_impurity

Optional pre-computed root impurity for the validation sample under the selected concentration-index criterion. If NULL, the root impurity is computed from new_data.

Value

A numeric validation gain.

Examples

toy_data <- data.frame(
  rank = c(10, 20, 30, 40, 50, 60),
  outcome = c(1, 0, 1, 0, 1, 1),
  income = c(2, 4, 6, 8, 10, 12)
)
fit <- ci_tree(
  cbind(rank, outcome) ~ income,
  data = toy_data,
  rank_name = "rank",
  outcome_name = "outcome",
  control = ci_tree_control(minsplit = 1, minbucket = 1, maxdepth = 1)
)
ci_tree_validation_gain(fit, toy_data, "rank", "outcome")
#> [1] 0.08333333