Where we start
A pay gap is a difference in averages. A pay equity question is narrower: do two people in the same job, at the same grade, with the same tenure, get paid the same? The filing cannot answer it, because the filing sees four bands and nothing inside them. A salary table with a grade and a join date on every row can, and the tool is an ordinary regression. Every salary tonight is constructed: generated by a seeded script on the page, with a small coefficient on sex planted inside it so that the method has a known answer to find. On a real table nobody planted anything, and that is the whole difficulty.
★ What you walk out with tonight. A seeded salary generator whose planted coefficient you can change, a least-squares fit of log pay on grade, tenure and sex in six lines of numpy, an Oaxaca-Blinder split that reconciles to the raw gap by an assert, a demonstration of what a bad control does to the coefficient, and the one sentence that reports the result without claiming more than it measured.
Log pay on grade, tenure and sex
5 min livePay is multiplicative: a grade step adds a percentage, not a fixed sum, and a year of tenure adds a smaller percentage. Taking the log turns those percentages into additions, so a straight-line model fits: log pay equals a constant, plus a grade effect, plus a tenure effect, plus a coefficient on sex, plus whatever is left. Least squares finds the rungs and the slope that leave the least behind. The coefficient on sex is then the average difference in log pay between women and men at the same grade and tenure, which is the within-band question the filing could not ask.
LiveWhy log, why least squares, and what the coefficient on sex means3 min▶
Why log. A grade step at Apex Digital and a grade step at Apex Retail are different sums of money but similar percentages, and a model in percentages is one model rather than four. On the log scale a coefficient of -0.04 on sex reads as "about 4 percent less, other things in the model held equal", and the conversion back is one minus e to the coefficient.
Why least squares. It is the fit that leaves the smallest sum of squared residuals, it has a closed form that numpy solves in one call, and its coefficients have the interpretation everybody wants: the change in log pay for a one-unit change in the variable, holding the others in the model fixed. The statistics course teaches it from scratch; here it is a tool, and the tool's limits matter more than its mechanics.
What the coefficient on sex means. It is the average gap between women and men who share the same grade and tenure values. It is not the raw gap, which is bigger whenever women sit lower on the ladder, and it is not "discrimination", because a coefficient is a difference that the other variables in the model did not account for, and the model only contains what somebody chose to put in it. Change the variables and the coefficient changes. Part 3 is about that choice.
Self-studyReading a coefficient table without being fooled by it2 min▶
Three habits. Print the unit. A coefficient on tenure is per year; a coefficient on grade is per band, and only if the bands are evenly spaced does one number describe the ladder, which is why the build-along treats grade as four separate rungs in the homework. Print the raw and the adjusted gap side by side, because the distance between them is the part the measured variables absorbed, and that distance is the finding, not the adjusted number alone. Print the residual spread. A within-band coefficient of 4 percent with a residual standard deviation of 12 percent means the individual variation dwarfs the average difference, and any single pair of colleagues is a poor test of the average.
The filing that said 9.8 and the table that said something else. Deep-dive session 5 showed that on 11,301 UK filings the band composition alone would report a median gap of 9.8 percent against a reported median of 11.0, leaving a median 2.3 points that the pyramid does not account for. A regression on a salary table is what turns that residual into a number an employer can act on: it says whether the 2.3 points sit inside the bands, and at which grade. The filing cannot; it was never designed to. Real filings, constructed salaries, same question at two resolutions.
Explained and unexplained, and why explained is not justified
5 min liveBlinder 1973 (Journal of Human Resources 8(4) 436-455) and Oaxaca 1973 (International Economic Review 14(3) 693-709) published the same idea in the same year: fit the pay model separately for men and for women, then write the gap between the two average pays as two pieces. One piece is the difference in the averages of the variables, priced at one group's coefficients: men sit at higher grades and longer tenures, and that alone would produce a gap. The other piece is the difference in the coefficients, applied to one group's averages: the same grade and tenure, paid differently. The first is called explained, the second unexplained, and the names have done a great deal of damage.
LiveThe arithmetic of the split, and the choice hidden in it3 min▶
Fit log pay on grade and tenure for men, giving coefficients bm, and for women, giving bw. Least squares passes through the means, so each group's mean log pay is its mean variables times its coefficients. The gap between the means is then (xm minus xw) times bm, plus xw times (bm minus bw). The first term prices the difference in average grade and tenure at men's coefficients; the second applies the difference in coefficients to women's averages. They add to the gap exactly, and an assert in the code says so.
The hidden choice is which group's coefficients price the first term. Priced at women's coefficients, the same data give a different explained share, and the difference between the two versions is a measure of how far the two pay structures diverge. Report both, or report one and say which; a decomposition that names only "explained 70 percent" without the reference group is not reproducible. On the constructed table the two versions sit close, because the generator used one structure with a shift; on a real table they may not.
Self-studyGoldin on hours, and what a filing cannot see2 min▶
Goldin 2014 (American Economic Review 104(4) 1091-1119) argued that the remaining gap is driven by occupations that reward long and particular hours: jobs where being available at specific times pays disproportionately, and where the penalty for flexibility falls more often on women. Hours is therefore a variable that belongs in a pay model when it is measured, and a variable the UK filing cannot see at all. Nor can the filing see occupation, tenure or part-time status. That is why the filing's 2.3-point residual and a regression's coefficient on sex are not the same number and should never be compared as if they were: the first is a gap the pyramid did not account for; the second is a gap that a specific list of variables did not account for. Neither is a measure of intent, and both move when the list changes.
"Seventy percent of the gap is explained." A reward team, constructed setting, ran the split and presented the explained share as reassurance. The explained share was mostly grade. A second question, who gets promoted to the higher grades and at what tenure, was not asked, because the model had already "explained" the gap. The split had done exactly what it does: priced a difference in grade mix at the going rate. Whether the grade mix is itself fair is a question the split cannot answer and did not claim to. Explained means measured. It never meant justified.
The control that absorbs the gap
5 min liveEvery variable added to the right-hand side takes some of the gap for itself. That is the point of a control, and it is also the trap: add a variable that was itself shaped by the thing you are measuring, and the coefficient on sex shrinks not because the gap closed but because it was relabelled. The test is one question about time and independence: was this variable set before the pay decision under examination, and by a process that did not know the answer?
LivePrior salary, and the demonstration in the build-along3 min▶
The clearest bad control is what the person was paid before: last year's salary, or the salary at the previous employer. It predicts current pay almost perfectly, so the fit improves, and it already contains whatever gap existed last year, so the coefficient on sex falls toward zero. Nothing was fixed. The gap was moved from the variable you were watching to a variable you were not. Step 7 of the build-along plants exactly that: a "prior pay" column that carries the same shift, then refits, and the coefficient on sex shrinks while the pay itself has not changed by a cent.
Grade is the honest borderline. For the question "are two people in the same band paid the same", grade is the right control and the coefficient on sex answers it. For the question "is the whole pay system fair", grade cannot be a control, because who reaches each grade is part of what is being asked. The same table, the same code, two questions; the analyst's job is to say which one was asked. A pay equity report that answers the first and is read as answering the second is the most common way a true number misleads.
Self-studySmall groups, and the coefficient that is not there2 min▶
Fit the model on Apex HR, 76 people, and the coefficient on sex will have a standard error wide enough that almost any value is consistent with the data. That is not a finding of no gap; it is a finding of not enough people to say. The statistics course covers the standard error properly; the habit here is to print the count under every coefficient the way foundations session 2 printed the base under every rate, and to refuse a sentence about a group whose count would not support it. The anonymity threshold that deep-dive session 7 applies to survey groups applies here too, for a second reason: with five people in a band, the coefficient on sex identifies individuals.
Least squares and the split on a seeded, constructed salary table
★ 22 min · everyone buildsSeven steps. Apex has no salary column, so step 1 generates one: a thousand invented rows with a planted ladder, a planted tenure slope, a planted shift on sex and noise, from numpy.random.default_rng with a stated seed. Every parameter in it is invented; the only borrowed number is the female share by band, which copies the median UK filing's pyramid from deep-dive session 5 so that the explained piece is not zero. No output is printed on the page, because the point is to run it: your numbers will differ, and with a different seed they will differ again.
Generate the constructed table. A seed, a ladder, a slope, a shift and noise. The female share by band is the only borrowed number, from the median UK filing. Everything else is invented and says so.
The design matrix and the fit. A column of ones for the constant, then grade, tenure and sex. One call to least squares returns the four coefficients.
Raw gap and adjusted gap, side by side. The raw gap is the difference in mean log pay. The adjusted gap is the coefficient on sex. The distance between them is what grade and tenure absorbed.
Residuals, and how much the model leaves. The R2 says how much of the variation the three variables account for; the residual spread says how far any one person sits from the rung.
Two fits, one per sex. The split needs each group's own coefficients and each group's mean variables. Least squares passes through the means, which is what makes the arithmetic exact.
The Oaxaca-Blinder split, with the assert. Explained prices the difference in mean variables at men's coefficients; unexplained applies the difference in coefficients to women's mean variables. The two must add to the raw gap.
The bad control, planted, and the sentence. An invented "prior pay" column that already carries the shift. Add it, refit, and watch the coefficient on sex move toward zero while nobody's pay changed.
Change the seed, then change the planted shift to zero. With the shift at zero the coefficient on sex should sit near zero and the explained share near a hundred percent, and the raw gap will still be positive, because women sit lower on the borrowed pyramid. That is the cleanest demonstration of the whole session: a raw gap with no within-band gap at all, produced by composition alone, exactly as the filings in deep-dive session 5 suggested for a third of employers.
Before deep-dive session 7
30 min- Run the seven steps with the seed as written, then with two other seeds. Record the coefficient on sex each time and write one line on how far it moved from the planted -0.04.
- Replace grade as one number with four rungs: three indicator columns for grades 2, 3 and 4. Compare the fitted rungs with the planted ladder and say whether the top step is bigger.
- Set the planted shift to zero and re-run the split. Write the sentence the result supports, and the sentence it does not.
- List the controls for a pay table you own: for each, when it was set and by whom. Mark the ones that fail the test in Part 3.
Three questions
Clear all three and deep-dive session 6 gets stamped in your passport.
1 · The regression returns a coefficient of -0.04 on sex, with grade and tenure in the model. What does the number mean?
The raw gap is the difference in means; the coefficient is the difference holding the model's variables fixed. The distance between them is what grade and tenure absorbed. Neither is a finding about fairness on its own.
2 · The Oaxaca-Blinder split reports 70 percent of the gap as explained by grade and tenure. A colleague says the gap is therefore mostly justified. What is wrong?
The split prices a measured difference. It says nothing about how the difference arose. Report the reference group too, since the explained share changes with it.
3 · Adding last year's salary to the model makes the coefficient on sex fall from -0.04 to nearly zero. What happened?
A control that was shaped by the thing being measured relabels the gap as explained. Step 7 plants exactly this and shows the coefficient shrink while the table is unchanged.
What this session teaches, and where it came from
Every fact on this page, and its verification tier, is recorded in the course's source map.
Deep-dive session 6 cheat sheet · pin this
Pay is a number somebody recorded. Deep-dive session 7 turns to numbers people volunteer: a constructed survey of 600 responses to 12 five-point items, one of which was planted to be unreliable. Cronbach's alpha is computed by the formula with and without the bad item, the response funnel shows who answered and who did not, an anonymity threshold becomes a minimum group size in code, and the Gallup engagement figure is read by edition, 23 percent in the 2024 edition, 21 and 20 in the two after it, without the folk claim that usually travels with it.