Skip to content

About

A pay-equity audit that reports pay-transparency gap metrics, splits the gap with Oaxaca-Blinder, and refuses to let a biased control such as performance rating explain the gap away.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

taintedgap

CI

taintedgap

taintedgap is a pay-equity audit for a workforce table. It reports the gender pay gap metrics the EU Pay Transparency Directive asks for, splits the raw gap into composition and unexplained parts with an Oaxaca-Blinder decomposition, estimates the adjusted gap per job family, and screens every control that could itself carry bias (performance rating is the usual suspect) before it is allowed to explain pay. It then costs two remediation plans and re-audits the result. All data is synthetic and generated from a seed.

The problem

A European hospital group with about 3,800 employees must report its gender pay gap under the EU Pay Transparency Directive (transposition due June 2026) and run a joint pay assessment for any category of workers where the gap is at least 5% and is not justified by objective, gender-neutral criteria. A single raw gap mixes two things: nursing is mostly female and IT mostly male, so much of the gap is who works where, and a smaller part is a real difference between comparable people. The usual fix is one regression with every available control. If one of those controls is the performance rating, and the ratings are themselves lower for women, the regression credits the rating with the gap and reports that the pay difference is "explained". taintedgap tests each candidate control for a gender difference, holding the legitimate factors fixed, before it may enter the adjusted model.

How it works

flowchart LR
    A["employees.csv<br/>+ config/audit.yaml"] --> B["Directive metrics<br/>mean/median gap, quartiles,<br/>categories with 5% flag"]
    A --> C["Taint screen<br/>does a control differ by gender<br/>given legitimate factors?"]
    C -->|"clean controls only"| D["Adjusted gap<br/>OLS on log pay, HC3,<br/>BH across families"]
    A --> E["Oaxaca-Blinder<br/>composition vs unexplained"]
    D --> F["Remediation plan<br/>uniform or band"]
    F -->|"new pay"| G["Re-audit<br/>metrics + adjusted gap"]
    G --> D
    B --> H["report.md<br/>aggregates only"]
    D --> H
    E --> H
    C --> H
    G --> H
Loading

Conventions. Pay means total hourly pay (base plus shift allowance). The directive metrics report (men - women) / men, so a positive gap means women are paid less. The adjusted gap is women's pay relative to comparable men, so a negative value means women are paid less. The decomposition works on mean log pay, which is why its raw gap differs from the mean gap on pay.

  • metrics: mean and median gap overall, the gap in the shift-allowance component, the share of each gender in four pay quartile bands (ties broken by employee id), and the gap per category of workers (job family x level). Categories with fewer than 5 of either gender are suppressed; the rest are flagged when the absolute mean gap is at least 5%. The terminal shows flagged and suppressed categories (--all adds the rest); the report lists every category.
  • adjust: OLS of log hourly pay on the legitimate factors plus a female indicator with HC3 standard errors, overall and per job family, with Benjamini-Hochberg across families.
  • decompose: twofold Oaxaca-Blinder using pooled reference coefficients from a regression that includes the group indicator. Explained plus unexplained equals the raw log gap, and the detailed contributions sum to the explained part.
  • taint: for each candidate control, regress it on the legitimate factors plus the female indicator within each family, flag it where the female coefficient is significant after BH (q = 0.05), and report the adjusted gap with and without it.
  • remediate --plan uniform|band [--budget USD]: raises pay in the families whose adjusted gap is significant after BH (rating excluded), costs it as hourly raise x contracted hours x 52, and re-runs metrics and adjust on the new pay.
  • report --out out/: report.md with all of the above and no individual pay values.

Quick start

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"

taintedgap generate --seed 19 --out data/   # employees.csv, config/audit.yaml, truth.json
taintedgap metrics                          # add --all to list every category
taintedgap adjust
taintedgap taint --flagged
taintedgap decompose
taintedgap remediate --plan uniform
taintedgap remediate --plan band --budget 300000
taintedgap report --out out/

Every command reads data/ by default; pass --data DIR to point elsewhere. The audit rules (which factors are legitimate, which controls are suspect, the 5% threshold, the minimum group size, q) live in config/audit.yaml next to the data.

Example output

From taintedgap generate --seed 19 and the commands above. The workforce is synthetic; the planted patterns are listed in truth.json: pharmacy women paid 6% less at equal legitimate factors, women's ratings 0.8 points lower in facilities and IT (so rating carries about a 4% gap into pay), and women at laboratory level 3 paid 9% more. The sampled pharmacy gap comes out at -7.57% against the planted -6%; that is sampling error with 94 women and 56 men.

taintedgap metrics

Directive metrics on total hourly pay (gap = (men - women) / men)
metric                             value
---------------------------  -----------
employees (women / men)      2659 / 1141
mean gap                         +15.82%
median gap                       +12.47%
shift allowance, mean gap        -10.45%
shift allowance, median gap          n/a

Pay quartile bands (1 = lowest paid)
band  employees  women    men
----  ---------  -----  -----
1           950  72.7%  27.3%
2           950  76.9%  23.1%
3           950  73.1%  26.9%
4           950  57.2%  42.8%

Categories of workers (job family / level)
category                     women/men    mean gap  median gap  flag
---------------------------  ---------  ----------  ----------  ----
laboratory / L3                  57/28     -11.95%     -12.66%   yes
information technology / L3      10/41     +11.79%     +11.65%   yes
pharmacy / L4                    19/11     +11.12%     +10.02%   yes
pharmacy / L5                    13/10     +10.44%      +7.95%   yes
allied health / L6                21/9      -9.43%      -6.00%   yes
patient access / L3               31/9      +8.93%     +12.69%   yes
imaging / L1                       9/5      +8.84%     +11.99%   yes
pharmacy / L6                     16/6      +8.47%     +12.08%   yes
food services / L5                13/6      +7.54%     +10.53%   yes
nursing assistants / L6           10/7      +7.37%     +12.78%   yes
information technology / L5       8/28      +7.03%      +6.28%   yes
pharmacy / L3                    24/18      +6.87%      +8.18%   yes
laboratory / L6                    5/5      +6.63%      +5.35%   yes
laboratory / L5                   14/6      -5.67%      -8.05%   yes
facilities engineering / L2      15/49      +5.32%      +5.23%   yes
environmental services / L5        6/2  suppressed  suppressed
environmental services / L6        4/6  suppressed  suppressed
facilities engineering / L5        1/4  suppressed  suppressed
facilities engineering / L6        1/5  suppressed  suppressed
finance / L1                       5/4  suppressed  suppressed
finance / L6                       6/2  suppressed  suppressed
food services / L6                 4/1  suppressed  suppressed
human resources / L1               5/0  suppressed  suppressed
human resources / L2              12/3  suppressed  suppressed
human resources / L3              14/4  suppressed  suppressed
human resources / L4              17/3  suppressed  suppressed
human resources / L6               7/1  suppressed  suppressed
information technology / L6       4/19  suppressed  suppressed
laboratory / L1                   14/2  suppressed  suppressed
nursing assistants / L5           28/4  suppressed  suppressed
patient access / L6               10/0  suppressed  suppressed
pharmacy / L1                     10/3  suppressed  suppressed
15 of 84 categories have an absolute mean gap of at least the threshold; 17 are suppressed (fewer than the minimum of either gender) and show no gap.

taintedgap adjust

Adjusted gap: women's pay relative to comparable men (HC3 errors; negative = women paid less)
job family                   women/men  adjusted gap        p   q (BH)  sig  with rating  p with rating
---------------------------  ---------  ------------  -------  -------  ---  -----------  -------------
advanced practice providers      98/52        +0.10%   0.9388   0.9388            +0.28%         0.7968
allied health                   225/75        +0.79%   0.4290   0.7508            +0.63%         0.4656
environmental services         148/102        -0.89%   0.3474   0.6949            -1.12%         0.1658
facilities engineering          56/144        -3.23%   0.0059   0.0206  yes     withheld        tainted
finance                          70/50        +0.15%   0.9030   0.9388            -0.05%         0.9649
food services                   110/70        -0.49%   0.6637   0.9292            -0.47%         0.6175
human resources                  63/17        +0.43%   0.8421   0.9388            -0.11%         0.9533
imaging                          82/68        +1.34%   0.2764   0.6449            +1.23%         0.2957
information technology          52/168        -3.44%   0.0030   0.0141  yes     withheld        tainted
laboratory                      134/66        +4.81%  <0.0001   0.0004  yes       +5.12%        <0.0001
nursing assistants              374/76        +0.53%   0.5447   0.8473            +0.68%         0.3631
patient access                  193/57        -0.39%   0.7641   0.9388            -0.59%         0.5832
pharmacy                         94/56        -7.57%  <0.0001  <0.0001  yes       -7.41%        <0.0001
registered nursing             960/140        -1.24%   0.0429   0.1201            -0.77%         0.1623
all employees                2659/1141        -0.79%   0.0044                   withheld        tainted

taintedgap taint --flagged

Taint screen: does the control differ by gender with legitimate factors held fixed?
control                         job family  female coef        p   q (BH)  verdict  gap without  gap with  shrinks
------------------  ----------------------  -----------  -------  -------  -------  -----------  --------  -------
performance rating  facilities engineering       -0.766  <0.0001  <0.0001  TAINTED       -3.23%    +0.38%      88%
performance rating  information technology       -0.804  <0.0001  <0.0001  TAINTED       -3.44%    +0.24%      93%
Rows shown: tainted controls only.

taintedgap decompose (overall part; the per-family table follows in the real output)

Oaxaca-Blinder, all employees (log points x 100; men minus women)
component                    value
--------------------------  ------
raw gap                     +13.34
explained (composition)     +12.54
unexplained                  +0.79
explained share of raw gap   94.1%

Explained part by factor
factor            contribution
----------------  ------------
job family              +13.06
shift pattern            -0.67
years experience         +0.18
site                     -0.01
level                     0.00

taintedgap remediate --plan uniform

Remediation plan: uniform (budget: none)
measure                                             value
-------------------------------------  ------------------
employees raised                                      268
annual cost                                     1,897,892
overall mean gap, before -> after      +15.82% -> +15.41%
overall median gap, before -> after    +12.47% -> +12.77%
overall adjusted gap, before -> after    -0.79% -> -0.27%
largest remaining family gap                        0.00%

Treated families (significant adjusted gap, rating excluded)
job family              raised  employees  annual cost  gap before  gap after
----------------------  ------  ---------  -----------  ----------  ---------
facilities engineering   women         56      166,604      -3.23%      0.00%
information technology   women         52      301,798      -3.44%      0.00%
laboratory                 men         66      270,828      +4.81%      0.00%
pharmacy                 women         94    1,158,661      -7.57%      0.00%

taintedgap remediate --plan band

Remediation plan: band (budget: none)
measure                                             value
-------------------------------------  ------------------
employees raised                                      122
annual cost                                       739,144
overall mean gap, before -> after      +15.82% -> +15.68%
overall median gap, before -> after    +12.47% -> +12.45%
overall adjusted gap, before -> after    -0.79% -> -0.56%
largest remaining family gap                        5.32%

Treated families (significant adjusted gap, rating excluded)
job family              raised  employees  annual cost  gap before  gap after
----------------------  ------  ---------  -----------  ----------  ---------
facilities engineering   women         25      106,540      -3.23%     -0.98%
information technology   women         26      195,047      -3.44%     -1.06%
laboratory                 men         25      125,297      +4.81%     +2.14%
pharmacy                 women         46      312,260      -7.57%     -5.32%

The band plan is cheaper but does not zero the gaps, and --budget spends the same money on the largest shortfalls first (see remediate --plan band --budget 300000). The raw gap barely moves under either plan because it is mostly composition.

Design decisions

  1. A control must pass a taint screen to explain pay. The screen is run within each job family, because the planted bias differs by family, and corrected with BH across families per control. The cost is power: with 56 women in facilities the screen is only decisive because the rating gap is large. adjust enforces the verdict: its headline gaps, remediate and the decomposition use legitimate factors only, and the with rating comparison column is filled only where the screen clears the control (it is withheld in the two tainted families and, because the pooled model spans them, overall). The taint table keeps the gap with column, so the biased figure is still visible next to its verdict, and adjust_by_family(..., screen=False) fits the control unconditionally.
  2. Pooled reference coefficients with the group indicator. Using one group's coefficients as the reference makes the split depend on an arbitrary choice. The pooled fit with the indicator keeps the indicator out of the explained part. Categorical factors use sum-to-zero coding so detailed contributions do not depend on which category is omitted. The unexplained part is computed from the two separate group regressions, not as raw - explained, so the identity in the tests is a real check.
  3. Sparse categories are merged before fitting. A category with fewer than 5 employees is merged into its nearest level (ordinal) or the most frequent category (nominal). A category owned by one person has leverage 1, which makes HC3 standard errors undefined.
  4. Uniform remediation is exact; band remediation is a policy. Multiplying the disadvantaged gender's pay (base and allowance) by exp(|coef|) shifts the female coefficient to zero by OLS algebra, and a test refits to confirm. The band plan fits a gender-neutral model per treated family and raises each disadvantaged employee below prediction minus 0.5 residual SD up to that floor, which costs less but leaves a gap. With a budget, raises go to the largest relative shortfalls first (ties by employee id) and stop at the first raise that does not fit, so budgets give nested sets of raises.
  5. Remediation follows the statistics, not the story. Laboratory shows a significant adjusted gap in women's favour (the planted retention allowance at level 3), so both plans raise laboratory men. A real assessment would first ask whether the allowance is justified; the tool only reports what the model sees.
  6. Binary gender and no individual output. The directive metrics and the generator use two genders, and reports contain aggregates only, with small cells suppressed.

Testing

pytest -q

83 tests, all offline. They cover the hand-computed directive, quartile and Oaxaca fixtures, BH against SciPy, the recovery of every planted pattern on the seeded workforce (pharmacy gap, the significant family set after BH, the taint screen, the laboratory flag, the composition share), the exactness of uniform remediation, monotonic gaps under increasing budgets, deterministic output, clean errors for bad options and config, and the absence of individual pay values from the report.

Project layout

src/taintedgap/
  cli.py          typer commands
  config.py       audit configuration and its YAML form
  data.py         loading, total pay, female indicator
  generate.py     seeded workforce with planted patterns
  design.py       design matrices, rare-category merging, effects coding
  stats.py        Benjamini-Hochberg
  metrics.py      directive metrics
  adjust.py       adjusted gap, HC3, BH across families
  decompose.py    Oaxaca-Blinder
  taint.py        taint screen
  remediate.py    uniform and band plans, budget, re-audit
  render.py       text and Markdown tables
  report.py       report.md
tests/            pytest suite
.github/workflows/ci.yml

License

MIT. See LICENSE.

About

A pay-equity audit that reports pay-transparency gap metrics, splits the gap with Oaxaca-Blinder, and refuses to let a biased control such as performance rating explain the gap away.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages