Skip to contents

The gap is rate(group) - rate(privileged). Demographic parity holds when every group receives favourable outcomes at the same rate, i.e. all gaps are zero. Unlike the disparate-impact ratio this additive form is well defined even when the privileged rate is zero.

Usage

morie_fairness_demographic_parity(
  y_pred,
  group,
  privileged = NULL,
  favorable = 1
)

Arguments

y_pred

Vector of decisions / assignments per individual.

group

Protected-attribute vector aligned with y_pred.

privileged

Reference group. If NULL, the highest-rate group is inferred and a warning is emitted.

favorable

Value of y_pred that counts as favourable (default 1).

Value

A morie_fairness_result; headline value is the largest absolute gap across groups.

Examples

pred <- c(1, 1, 1, 1, 0, 0, 0, 1, 0, 0)
race <- c("A","A","A","A","A","B","B","B","B","B")
morie_fairness_demographic_parity(pred, race, privileged = "A")$value
#> [1] -0.6