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.

The additive difference in favourable-outcome rates, rate(group) - rate(privileged). Demographic parity holds when every group receives favourable outcomes at the same rate.

Usage

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

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

Arguments

y_pred

Vector of decisions/assignments, one per individual.

group

Vector of protected-attribute values (e.g. race).

privileged

The reference group. If NULL (default) the highest-rate group is used and a warning is attached.

favorable

The value of y_pred counted as the favourable outcome (default 1).

Value

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

A named list: value (largest absolute gap), gaps, rates, privileged, warnings, interpretation.

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
#>    B 
#> -0.6 
pred <- c(1, 1, 1, 1, 0, 0, 0, 1, 0, 0)
race <- c(rep("A", 5), rep("B", 5))
res <- morie_fairness_demographic_parity(pred, race, privileged = "A")
res$value # -0.6  (group B rate 0.2 minus group A rate 0.8)
#>    B 
#> -0.6