H24 Group by broker
Use your current course session. Preparation and course runner · R script ↓
H24 Group by broker
Goal: Reuse a metric with a different grouping.
Prerequisites: H23.
dimensions permits a dimension; by selects it for this measurement.
training_step(
"H24",
{
broker_rates <- dataraft.metrics::dr_measure(
cohort_run,
cancellation_metric,
by = "broker_id"
)
print(broker_rates)
stopifnot(nrow(broker_rates) == 2L)
stopifnot(isTRUE(all.equal(sort(broker_rates$value), c(0, 1 / 3))))
},
needs = c("H23")
)Expected result: Broker 1 has a rate of 1/3; broker 2 has 0.
Task: Can subgroup rates always be averaged directly?
Show solution
No. Different populations require denominator weighting or reaggregation of numerator and denominator.