R parity for the Python morie.fairness.temporal module. The four
disparity metrics — Disparate Impact Ratio, Demographic Parity Gap,
Gini coefficient, and Bias Amplification Score — are computed for
each (city, period) cell and aggregated per city, so temporal
instability and cross-city divergence become visible.
Value
The module's audit callable returns a named list with the
worst per-city Disparate Impact Ratio range, per-city and per-cell
breakdowns, and a plain-language interpretation.
Details
Reimplements the longitudinal, multi-city audit of Barman & Barman, arXiv:2603.18987. Its central lesson: bias metrics are not stable from one deployment cycle to the next and must be recomputed per period and per city.
Examples
period <- c(rep("p1", 10), rep("p2", 10))
city <- rep("A", 20)
pred <- rep(c(1, 1, 1, 1, 1, 1, 1, 1, 0, 0), 2)
grp <- rep(c(rep("X", 5), rep("Y", 5)), 2)
morie_predpol_temporal_audit(period, city, pred, grp, privileged = "X")
#> $value
#> [1] 0
#>
#> $worst_dir_range
#> [1] 0
#>
#> $cross_city_dir_spread
#> [1] 0
#>
#> $per_city
#> $per_city$A
#> $per_city$A$n_periods
#> [1] 2
#>
#> $per_city$A$mean_dir
#> [1] 0.6
#>
#> $per_city$A$mean_parity_gap
#> [1] -0.4
#>
#> $per_city$A$mean_gini
#> [1] 0.125
#>
#> $per_city$A$mean_bas
#> [1] -0.05
#>
#> $per_city$A$dir_min
#> [1] 0.6
#>
#> $per_city$A$dir_max
#> [1] 0.6
#>
#> $per_city$A$dir_range
#> [1] 0
#>
#> $per_city$A$periods_dir_gt1
#> [1] 0
#>
#>
#>
#> $cells
#> $cells[[1]]
#> $cells[[1]]$city
#> [1] "A"
#>
#> $cells[[1]]$period
#> [1] "p1"
#>
#> $cells[[1]]$n
#> [1] 10
#>
#> $cells[[1]]$dir
#> [1] 0.6
#>
#> $cells[[1]]$parity_gap
#> Y
#> -0.4
#>
#> $cells[[1]]$gini
#> [1] 0.125
#>
#> $cells[[1]]$bas
#> Y
#> -0.05
#>
#>
#> $cells[[2]]
#> $cells[[2]]$city
#> [1] "A"
#>
#> $cells[[2]]$period
#> [1] "p2"
#>
#> $cells[[2]]$n
#> [1] 10
#>
#> $cells[[2]]$dir
#> [1] 0.6
#>
#> $cells[[2]]$parity_gap
#> Y
#> -0.4
#>
#> $cells[[2]]$gini
#> [1] 0.125
#>
#> $cells[[2]]$bas
#> Y
#> -0.05
#>
#>
#>
#> $privileged
#> [1] "X"
#>
#> $warnings
#> character(0)
#>
#> $interpretation
#> [1] "The Disparate Impact Ratio is reasonably stable across periods."
#>