Appendix: the maths, worked
Each section states a formula, its source, and works it on the casebook numbers, computed by script and re-derived by hand (unrounded value first). Notation: n items, p a proportion, and a 2×2 table with cells a, b, c, d left to right, top to bottom.
The casebook has three groups of numbers. A two-judge table of 100 items for agreement, rated by interviewers Ana and Benmanagers Carla and Devjudges Elodie and FemiDr Gale and Dr Hart, double readingumpires Ivo and June, calling the same pitches on video; a three-judge version of 100 items; and a judge-versus-truth table of 200 items, 60 of them truly YES, where the truth is how the hire did a year later (an idealised study: only hires get an outcome)a calibration committee's consensus rating, since reviews have no outside trutha reference panel's verdict, since wine quality has no outside truthbiopsy or a year of clean follow-upthe pitch-tracking camera and the rulebook zone. The YES label is “hire”“exceeds expectations”“medal”“recall the patient”“strike”; for an LLM judge it is “passes the policy”.
Agreement beyond chance: percent agreement, Cohen's kappa, Scott's pi
Each of 100 items is judged by both judges; the table counts the four pairs of verdicts.
| Judge B says YES | Judge B says NO | Row total | |
|---|---|---|---|
| Judge A says YES | 45 (a) | 15 (b) | 60 |
| Judge A says NO | 10 (c) | 30 (d) | 40 |
| Column total | 55 | 45 | 100 |
Here judge A is AnaCarlaElodieDr GaleIvo and judge B is BenDevFemiDr HartJune. For an LLM judge, A and B are two human labelers, or one labeler and the model.
Percent agreement is the share on the diagonal:
po = (45 + 30) / 100 = 0.75.
But judges who never looked would still agree sometimes. If A says YES 60% of the time and B 55%, independently, both say YES on 0.60 × 0.55 of items and both NO on 0.40 × 0.45. The sum is chance agreement, built from the marginal totals:
pA,yes = 60/100 = 0.60, pB,yes = 55/100 = 0.55.
pe = 0.60 × 0.55 + 0.40 × 0.45 = 0.33 + 0.18 = 0.51.
Cohen's kappa (Cohen 1960) is the share of the room above chance the judges used: agreement beyond chance over the most that was possible.
κ = (0.75 − 0.51) / (1 − 0.51) = 0.24 / 0.49 = 0.4898 ≈ 0.49.
The judges closed about half the gap between chance and perfect agreement: “moderate” on the widely quoted, admittedly arbitrary Landis and Koch bands (0.41–0.60; Landis and Koch 1977).
Kappa is 1 for perfect agreement, 0 at chance, negative below it. It is not a percentage: 0.49 does not mean “they agree 49% of the time”.
Scott's pi (Scott 1955) uses the same formula but takes chance from the pooled YES rate, as if both judges drew from one distribution; kappa lets each keep their own.
p̄ = (0.60 + 0.55) / 2 = 0.575. pe,π = 0.575² + 0.425² = 0.330625 + 0.180625 = 0.51125.
π = (0.75 − 0.51125) / (1 − 0.51125) = 0.23875 / 0.48875 = 0.4885 ≈ 0.489.
Pi is never larger than kappa, since pooling can only raise chance agreement; 60% against 55% moves only the third decimal. The choice is what “chance” means: kappa credits different thresholds to the judges, pi counts them as disagreement.
Why pi ≤ kappa: pe,π − pe = (pA,yes − pB,yes)² / 2 ≥ 0. Here (0.05)² / 2 = 0.00125 = 0.51125 − 0.51.
Ana says hire on 60 of 100 and Ben on 55. Weighted coins would agree on 51; they agree on 75, capturing 24 of the 49 agreements chance left open. Usable, but neither can stand in for the other.
Carla rates 60 of 100 “exceeds” and Dev 55. Rating blind at those rates would match on 51; they match on 75. Half the possible agreement above chance, so calibration still has plenty to argue about.
Elodie medals 60 of 100 wines and Femi 55. Random medals at those rates would agree on 51; they agree on 75. Something real is tasted, but swapping judges changes about one verdict in four.
Dr Gale recalls 60 of 100 and Dr Hart 55 (an enriched test set). Independent readers at those rates would agree on 51; they agree on 75. Double reading exploits the gap: each catches what the other misses.
Ivo calls 60 of 100 borderline pitches strikes and June 55. Blind calls at those rates would agree on 51; they agree on 75. Moderate agreement on borderline pitches is why the camera exists.
The kappa paradoxes: high agreement, low kappa
Now make YES rare: both say NO on 90 of 100 items, both YES on 2, and they split 4 and 4.
| B YES | B NO | Total | |
|---|---|---|---|
| A YES | 2 | 4 | 6 |
| A NO | 4 | 90 | 94 |
| Total | 6 | 94 | 100 |
po = (2 + 90) / 100 = 0.92.
Each judge says YES on 6%. pe = 0.06 × 0.06 + 0.94 × 0.94 = 0.0036 + 0.8836 = 0.8872.
κ = (0.92 − 0.8872) / (1 − 0.8872) = 0.0328 / 0.1128 = 0.2908 ≈ 0.29.
92% agreement, poor-looking kappa, and nothing broken. When nearly everything is NO, chance agreement is already 0.887, leaving 0.113 to earn; of the 10 items where either judge said YES, they agreed on 2. Kappa reports that correctly.
Feinstein and Cicchetti named two kappa paradoxes (Feinstein and Cicchetti 1990). First, the one above: unbalanced marginals drag a high po down. Second, kappa comes out higher when the judges' marginals are unbalanced in opposite directions. On the casebook: keep po = 0.75 but put all 25 disagreements in one cell (A YES, B NO), so YES rates become 70% and 45%. Chance falls to 0.70 × 0.45 + 0.30 × 0.55 = 0.48 and kappa rises to (0.75 − 0.48) / 0.52 = 0.519, though the judges now disagree more systematically.
Try thisCasebook, then one-sided disagreement: agreement stays at 75% while kappa rises from 0.49 to 0.52. Then the kappa paradox: 92% agreement, kappa 0.29. Drag prevalence toward 0% to watch the chance bar swallow the room.
Byrt, Bishop and Carlin made it bookkeeping (Byrt et al. 1993): a prevalence index, a bias index and PABAK, with kappa a function of the three:
| Table | po | PI | BI | PABAK | κ from the identity |
|---|---|---|---|---|---|
| Casebook two judges (45, 15, 10, 30) | 0.75 | 0.15 | 0.05 | 0.50 | (0.50 − 0.0225 + 0.0025) / (1 − 0.0225 + 0.0025) = 0.49 |
| Rare YES (2, 4, 4, 90) | 0.92 | −0.88 | 0 | 0.84 | (0.84 − 0.7744) / (1 − 0.7744) = 0.29 |
| Lopsided disagreement (45, 25, 0, 30) | 0.75 | 0.15 | 0.25 | 0.50 | (0.50 − 0.0225 + 0.0625) / (1 − 0.0225 + 0.0625) = 0.519 |
The identity makes both paradoxes mechanical: a large prevalence index is squared and subtracted, dragging kappa down; a bias index is squared and added, so one-directional disagreement gets a bump. The companion paper says always report agreement on positives and on negatives beside kappa (Cicchetti and Feinstein 1990).
Rare YES: ppos = 4 / 12 = 0.333; pneg = 180 / 188 = 0.957. They agree on NO and barely on YES, which explains the 0.29 better than the 0.29 does.
Casebook two judges: ppos = 90 / 115 = 0.783; pneg = 60 / 85 = 0.706.
A senior role with 6 hires per 100. Ana and Ben agree on 92 verdicts, but of the 10 people either wanted, they agreed on 2. The 92% is mostly agreeing who is not a fit.
“Exceeds” goes to about 6%. Carla and Dev match on 92 of 100 ratings but on only 2 of the 10 either put forward: calibrated-looking, split on almost everyone who matters.
A strict show medals about 6%. Elodie and Femi agree on 92 of 100 glasses, nearly all “no medal”, and on 2 of the 10 either wanted to medal: weakest where people read.
The textbook case. Dr Gale and Dr Hart agree on 92 of 100 reads, nearly all “clear”, but on 2 of the 10 patients either wanted recalled.
On pitches well outside the zone, Ivo and June agree on 92 of 100, mostly obvious balls, but on 2 of the 10 either called a strike. Pitches nobody would miss inflate the number.
For LLM judges this is the common case: a safety or hallucination judge hunts a failure in a few percent of outputs, so “95% agreement with humans” can sit beside kappa 0.3. Report ppos and pneg, or use the confusion matrix below. See Igor's notes on agreement, kappa and friends.
Fleiss' kappa: three or more judges
With three judges there is no single 2×2 table. Fleiss' kappa (Fleiss 1971) asks, item by item, what fraction of judge pairs agree, and compares the average with chance from pooled category rates; pooling makes it a generalised Scott's pi, not Cohen's kappa. The casebook's 100 items, by YES votes:
| YES votes on the item | Items | Agreeing pairs of 3 | Pi | YES votes cast |
|---|---|---|---|---|
| 3 (unanimous YES) | 35 | 3 | 1 | 105 |
| 2 | 15 | 1 | 1/3 | 30 |
| 1 | 12 | 1 | 1/3 | 12 |
| 0 (unanimous NO) | 38 | 3 | 1 | 0 |
| Total | 100 | 246 of 300 | 147 of 300 |
With m judges and nij votes for category j, item agreement is the matching share of the m(m − 1) ordered pairs:
Unanimous item: (3·2 + 0) / 6 = 1. Split item (2 YES, 1 NO): (2·1 + 1·0) / 6 = 1/3.
P̄ = (73 × 1 + 27 × 1/3) / 100 = (73 + 9) / 100 = 0.82. That is the mean pairwise agreement: 246 of the 300 judge pairs agree.
pyes = 147 / 300 = 0.49. Pe = 0.49² + 0.51² = 0.2401 + 0.2601 = 0.5002.
κF = (0.82 − 0.5002) / (1 − 0.5002) = 0.3198 / 0.4998 = 0.6399 ≈ 0.64.
73 items are unanimous; the 27 others split 2–1, the only split three judges and two labels allow. The single number hides which items split, and those are the useful output: the ones worth a human read.
Three interviewers per candidate: 35 unanimous hires, 38 unanimous no-hires, 27 splits. The debrief belongs to the 27; the 0.64 says unanimity means something.
Three managers per employee: 73 unanimous, 27 split. Equal time on all 100 wastes most of the meeting; the 27 show where the definitions fail.
Three judges per wine: 35 unanimous medals, 38 unanimous no-medals, 27 splits, which go to discussion or a fourth taster.
Three readers per image: 73 unanimous, 27 split. Arbitration exists for the 27; at 0.64 the unanimous reads can mostly be trusted.
Three umpires on the same video: 73 unanimous, 27 split 2–1, near the edge of the zone, where the camera decides anyway.
Krippendorff's alpha: the coincidence matrix
Krippendorff's alpha (Hayes and Krippendorff 2007) is written in disagreement and handles any number of judges, missing ratings and ordered or numeric scales in one formula:
The device is the coincidence matrix. Forget which judge said what. For each item, add every ordered pair of values from different judges to a values-by-values table, weighted 1/(mu − 1), where mu judges rated the item. Each rating then contributes one unit, so the table sums to the n ratings; it is symmetric, matches sit on the diagonal, and row totals nv count each value's use. For any distance δ:
This is the form in the Krippendorff's alpha article's worked example; (n − 1) is the small-sample correction for drawing two values without replacement.
Each item has m = 2 ratings, so each item contributes its two ordered pairs with weight 1/(2 − 1) = 1. The 45 both-YES items give 90 YES-YES entries; the 30 both-NO items give 60 NO-NO; the 15 + 10 = 25 split items give 25 YES-NO and 25 NO-YES. Totals: nyes = 90 + 25 = 115, nno = 60 + 25 = 85, n = 200.
Nominal distance: δ = 1 for different values, 0 for the same. Σ o δ = 25 + 25 = 50. Σ nvnv'δ = 115·85 + 85·115 = 19,550.
α = 1 − 199 × 50 / 19,550 = 1 − 9,950 / 19,550 = 1 − 0.5090 = 0.4910 ≈ 0.491.
Equivalently Do = 50/200 = 0.25 and De = 19,550 / (200 × 199) = 0.4912, so α = 1 − 0.25/0.4912.
Now m = 3, so each item has 3 × 2 = 6 ordered pairs, each weighted 1/2. A unanimous YES item puts 6 × ½ = 3 into YES-YES; 35 of them give 105. A 2–1 YES item has 2 YES-YES pairs (1 entry), and 4 mixed pairs (2 entries, split 1 YES-NO and 1 NO-YES); 15 of them give 15 YES-YES and 15 in each mixed cell. A 1–2 item gives 1 NO-NO entry and 1 in each mixed cell; 12 of them give 12 NO-NO and 12 per mixed cell. Unanimous NO: 38 × 3 = 114 NO-NO.
oyes,yes = 105 + 15 = 120; ono,no = 114 + 12 = 126; oyes,no = ono,yes = 15 + 12 = 27. nyes = 147, nno = 153, n = 300.
α = 1 − 299 × 54 / (2 × 147 × 153) = 1 − 16,146 / 44,982 = 1 − 0.3589 = 0.6411 ≈ 0.641.
Alpha lands just above pi and Fleiss (0.491 against 0.489; 0.641 against 0.640): the (n − 1) correction, negligible at 200 ratings, real at 20. All three pool value frequencies for chance, so on complete binary data they nearly coincide; alpha earns its keep on missing ratings (a skipped item just contributes fewer pairs) and ordered scales.
For ordered scales only δ changes. Nominal: 1 if the values differ. Interval: (v − v')², so two points off costs four times one. Ordinal: a rank distance based on how many ratings fall between the values, respecting order without equal steps. On the next section's 3×3 table, nominal alpha is 0.535 and interval alpha 0.657 (from that table's coincidence matrix), close to unweighted and quadratic-weighted kappa.
Weighted kappa: partial credit for near misses
Plain kappa treats every disagreement alike, but “partial” against “pass” is smaller than “fail” against “pass”. Weighted kappa (Cohen 1968) weights each cell. In agreement-weight form, categories 1 to k:
Off-diagonal weights of 0 give plain kappa. Quadratic-weighted kappa is equivalent to an intraclass correlation, so it behaves like a correlation on numeric scores (Fleiss and Cohen 1973).
An example built for this page, not the casebook: two judges grade 100 outputs on three levels: no hire / lean hire / hirebelow / meets / exceedsno medal / bronze / goldclear / short follow-up / recallball / too close / strike; for the LLM judge, fail / partial / pass.
| A \ B | 1 (low) | 2 (mid) | 3 (high) | Row |
|---|---|---|---|---|
| 1 (low) | 20 | 8 | 2 | 30 |
| 2 (mid) | 6 | 24 | 6 | 36 |
| 3 (high) | 2 | 7 | 25 | 34 |
| Column | 28 | 39 | 33 | 100 |
Linear: diagonal 1, one step off 1 − 1/2 = 0.5, two steps off 0. Quadratic: diagonal 1, one step off 1 − 1/4 = 0.75, two steps off 1 − 4/4 = 0.
Observed. Diagonal = 20 + 24 + 25 = 69. One step off = 8 + 6 + 6 + 7 = 27. Two steps off = 2 + 2 = 4.
Unweighted po = 0.69. Linear po,w = (69 + 0.5 × 27) / 100 = 0.825. Quadratic po,w = (69 + 0.75 × 27) / 100 = 0.8925.
Chance. Expected counts are row × column / 100. Diagonal: 30·28 + 36·39 + 34·33 = 840 + 1,404 + 1,122 = 3,366, so 0.3366. One step off: 30·39 + 36·28 + 36·33 + 34·39 = 1,170 + 1,008 + 1,188 + 1,326 = 4,692, so 0.4692. Two steps off: 30·33 + 34·28 = 990 + 952 = 1,942, so 0.1942.
Unweighted pe = 0.3366. Linear pe,w = 0.3366 + 0.5 × 0.4692 = 0.5712. Quadratic pe,w = 0.3366 + 0.75 × 0.4692 = 0.6885.
Kappas. Unweighted: (0.69 − 0.3366) / 0.6634 = 0.533. Linear: (0.825 − 0.5712) / 0.4288 = 0.592. Quadratic: (0.8925 − 0.6885) / 0.3115 = 0.655.
One table, three kappas from 0.53 to 0.65, none wrong: most misses are one step, so more partial credit scores higher. The weighting is a policy choice to state up front, not a knob to turn after seeing results, and quadratic and unweighted kappas from different studies are not comparable.
The confusion matrix: judge against truth
Validity statistics compare a judge with the truth, starting from the confusion matrix. The casebook: 200 items, 60 truly YES.
TP = 48 truly YES, called YES; FN = 12 truly YES, called NO; FP = 21 truly NO, called YES; TN = 119 truly NO, called NO. Every validity statistic is a ratio of these.
| Statistic | Formula | Worked | Value |
|---|---|---|---|
| Sensitivity (recall, TPR) | TP / (TP + FN) | 48 / 60 | 0.80 |
| Specificity (TNR) | TN / (TN + FP) | 119 / 140 | 0.85 |
| Precision (PPV) | TP / (TP + FP) | 48 / 69 | 0.696 |
| Negative predictive value | TN / (TN + FN) | 119 / 131 | 0.908 |
| Accuracy | (TP + TN) / n | 167 / 200 | 0.835 |
| F1 | 2·P·R / (P + R) = 2TP / (2TP + FP + FN) | 96 / 129 | 0.744 |
| Judge's YES rate | (TP + FP) / n | 69 / 200 | 0.345 |
| Prevalence | (TP + FN) / n | 60 / 200 | 0.30 |
Sensitivity and specificity divide by the truth (rows): they describe the judge and ignore prevalence. Precision and NPV divide by the verdict (columns): they describe a verdict's worth in this population and move with prevalence (base rates). Accuracy mixes both, so it is easy to game: always-NO scores 140/200 = 0.70 here with sensitivity 0. F1 ignores true negatives, so it suits tasks where only YES matters.
Treat the truth as a second judge and kappa follows from the same table: po = 0.835, pe = 0.345 × 0.30 + 0.655 × 0.70 = 0.1035 + 0.4585 = 0.562, κ = (0.835 − 0.562) / 0.438 = 0.623. Igor's notes on the confusion matrix walk the same cells from the testing side.
Youden's J: one number for a yes/no judge
Youden's single index for a diagnostic test (Youden 1950):
J = 0.80 + 0.85 − 1 = 0.65. Equivalently TPR − FPR = 0.80 − 0.15 = 0.65, since FPR = 1 − specificity = 21/140 = 0.15.
Always-YES judge: 1 + 0 − 1 = 0. Always-NO judge: 0 + 1 − 1 = 0. A coin flip at any bias: TPR = FPR, so J = 0.
The second form is the useful one: how much more often the judge says YES to truly-YES items than to truly-NO ones. A judge that ignores the item, however biased, scores 0; a perfect one 1; below 0 is informative but inverted. J does not reward matching the majority class and, being two row ratios, ignores prevalence.
Geometry. As a point (FPR, TPR) in ROC space, J is the height above the chance diagonal TPR = FPR: (0.15, 0.80) sits 0.65 above it. With a threshold to choose, J's best cut is the curve point farthest above the diagonal; Peirce published the same formula in 1884 (Youden's J).
Balanced accuracy is J in other units:
(0.80 + 0.85) / 2 = 0.825 = (0.65 + 1) / 2. Chance is 0.5 on this scale and 0 on J's.
J weighs a missed YES and a false YES equally per item of each class. With unequal costs, as in most domains, the best cut is the cost-weighted one, not J's maximum. J is a summary, not a decision rule.
Base rates: precision from sensitivity, specificity and prevalence
Precision is what people ask of a verdict: “it said YES; how likely is that right?” Bayes' rule gives it from the two row rates and the base rate π of truly-YES items:
Numerator 0.80 × 0.30 = 0.24. False-YES mass 0.15 × 0.70 = 0.105.
precision = 0.24 / (0.24 + 0.105) = 0.24 / 0.345 = 0.696, matching 48/69 from the table. NPV = 0.595 / (0.595 + 0.06) = 0.908.
50 truly YES, 950 truly NO. TP = 0.80 × 50 = 40. FP = 0.15 × 950 = 142.5.
precision = 40 / (40 + 142.5) = 40 / 182.5 = 0.219. NPV = 807.5 / (807.5 + 10) = 0.988.
For comparison (same formula): at π = 1%, precision = 0.008 / (0.008 + 0.1485) = 0.051; at π = 50%, 0.40 / 0.475 = 0.842.
Odds form: posterior odds = prior odds × LR+, with LR+ = sens / (1 − spec) = 0.80 / 0.15 = 5.33. At π = 30%: (0.3/0.7) × 5.33 = 2.29, so precision = 2.29 / 3.29 = 0.696. At 5%: (0.05/0.95) × 5.33 = 0.281, precision 0.219.
Only the mix of items changed, and precision fell from 0.70 to 0.22: nearly four YES verdicts in five wrong. That is why a judge validated on a balanced set disappoints on production traffic, where its target is rare.
In a pool where 30% would do well, this interviewer's hires are right 70% of the time. In an open pool where 5% would, most people they pass are false positives, which is why a cheap screen comes before costlier rounds.
If 30% truly exceed, this manager's “exceeds” is right about 70% of the time; if 5% do, it is wrong four times in five. One reason to calibrate against a distribution.
In a strong flight where 30% merit a medal, this judge's medals are right about 70% of the time. In an open show where 5% do, most go to wines the panel would not medal.
The screening problem in miniature: a reader good on a 30%-cancer study set sees precision collapse in screening, where cancer is far rarer than 5%. Most recalls are false alarms, accepted as the price of catches, which is why recall leads to more imaging, not treatment.
On borderline pitches, 30% in the zone, this umpire's strike calls are right 70% of the time; where 5% are strikes, most are wrong. The pitch mix matters as much as the umpire.
Building the ROC curve, threshold by threshold
Many judges emit a score (a 1–5 rating, a probability, a log-prob), and a threshold turns it into a verdict, each with its own confusion matrix. The ROC curve plots all of them (the “rating method” of Hanley and McNeil 1982). The casebook judge scores each of the 200 items 1 to 5, read as the interviewer's 1–5 scorecard ratingthe manager's 1–5 ratingthe judge's score sheet collapsed into five bandsthe radiologist's 1–5 suspicion rating, the classic reader-study designthe umpire's 1–5 confidence that it was a strike, in a video study:
| Score | 1 | 2 | 3 | 4 | 5 | Total |
|---|---|---|---|---|---|---|
| Truly YES items | 2 | 4 | 6 | 20 | 28 | 60 |
| Truly NO items | 50 | 38 | 31 | 14 | 7 | 140 |
Sweep from strict to lenient. At “YES if score ≥ t”, TP and FP count YES and NO items at or above t; divide by 60 and 140.
| Rule | TP | FP | TPR = TP/60 | FPR = FP/140 | J |
|---|---|---|---|---|---|
| never YES | 0 | 0 | 0 | 0 | 0 |
| score ≥ 5 | 28 | 7 | 0.467 | 0.050 | 0.417 |
| score ≥ 4 | 28 + 20 = 48 | 7 + 14 = 21 | 0.800 | 0.150 | 0.650 |
| score ≥ 3 | 54 | 52 | 0.900 | 0.371 | 0.529 |
| score ≥ 2 | 58 | 90 | 0.967 | 0.643 | 0.324 |
| score ≥ 1 (always YES) | 60 | 140 | 1 | 1 | 0 |
The ≥ 4 row is the earlier confusion matrix (TP 48, FP 21) and maximises J: the Youden-optimal threshold. Joining the six points from (0, 0) to (1, 1) gives the empirical ROC curve.
Five score levels give straight segments, and ties make them diagonal rather than steps: items sharing a score fall on the same side of every threshold, and the line averages breaking the tie either way.
AUC: the trapezoids, and the Mann–Whitney reading
The area under the curve sums the trapezoids between consecutive points:
(0 → 0.05): 0.05 × (0 + 0.4667) / 2 = 0.0117
(0.05 → 0.15): 0.10 × (0.4667 + 0.80) / 2 = 0.0633
(0.15 → 0.3714): 0.2214 × (0.80 + 0.90) / 2 = 0.1882
(0.3714 → 0.6429): 0.2714 × (0.90 + 0.9667) / 2 = 0.2533
(0.6429 → 1): 0.3571 × (0.9667 + 1) / 2 = 0.3512
Sum = 0.8677, exactly 7,289 / 8,400, so AUC ≈ 0.868.
Hanley and McNeil's point: the area is a probability, that a random truly-YES item outscores a random truly-NO one, ties half (Hanley and McNeil 1982), which is what the Wilcoxon–Mann–Whitney statistic estimates. Check by counting all 60 × 140 = 8,400 (YES, NO) pairs.
For each YES score, count NO items strictly below it (wins) and at the same score (ties):
score 1: 2 YES × (0 below, 50 tied) → 0 wins, 100 ties
score 2: 4 × (50 below, 38 tied) → 200 wins, 152 ties
score 3: 6 × (88 below, 31 tied) → 528 wins, 186 ties
score 4: 20 × (119 below, 14 tied) → 2,380 wins, 280 ties
score 5: 28 × (133 below, 7 tied) → 3,724 wins, 196 ties
Wins = 6,832; ties = 914. AUC = (6,832 + 914 / 2) / 8,400 = 7,289 / 8,400 = 0.8677. Same number, to the last digit.
Keep the pair reading: shown one truly-YES and one truly-NO item, the judge ranks them right about 87% of the time. AUC is threshold-free, a strength (ranking quality before any cut) and a weakness (you deploy a cut, and equal-AUC judges can differ sharply there). It is blind to calibration: multiply every score by ten and nothing changes.
Hanley and McNeil also gave a closed-form standard error, using Q1 = A/(2 − A) and Q2 = 2A²/(1 + A) (form as given in GraphPad's calculation notes):
A = 0.8677, n1 = 60 YES, n2 = 140 NO. Q1 = 0.8677 / 1.1323 = 0.7664. Q2 = 2 × 0.7530 / 1.8677 = 0.8063.
Numerator = 0.1148 + 59 × (0.7664 − 0.7530) + 139 × (0.8063 − 0.7530) = 0.1148 + 0.791 + 7.412 ≈ 8.32. SE = √(8.32 / 8,400) = 0.031.
Approximate 95% interval: 0.868 ± 1.96 × 0.031 = 0.81 to 0.93. (This SE is not in the shared casebook; it is computed for this page.)
Confidence intervals: Wilson, kappa's standard error, the bootstrap
Another 60 truly-YES items would give another sensitivity; a confidence interval says how far it could plausibly move. The textbook Wald interval, p̂ ± z√(p̂(1 − p̂)/n), has erratic coverage even at large n; Brown, Cai and DasGupta recommend Wilson (or Jeffreys) for small samples (Brown et al. 2001). The Wilson score interval (Wilson 1927) inverts the score test:
p̂ = 0.80, n = 60, z² = 3.8416. Denominator 1 + 3.8416/60 = 1.06403.
Centre = (0.80 + 3.8416/120) / 1.06403 = (0.80 + 0.03201) / 1.06403 = 0.78195.
Inside the root: 0.80 × 0.20 / 60 + 3.8416 / 14,400 = 0.0026667 + 0.0002668 = 0.0029334; root 0.054161. Half-width = 1.96 × 0.054161 / 1.06403 = 0.09977.
Interval 0.78195 ± 0.09977 = 0.682 to 0.882. (Wald would give 0.699 to 0.901, centred on 0.80; Wilson pulls the centre toward 0.5.) Specificity 119/140 by the same steps: 0.782 to 0.900.
p̂ = 0.75, n = 100. Denominator 1.038416. Centre = (0.75 + 0.019208) / 1.038416 = 0.74075.
Root of 0.001875 + 0.00009604 = 0.0019710 → 0.044397. Half-width = 1.96 × 0.044397 / 1.038416 = 0.08380.
Interval = 0.657 to 0.825, so “0.66–0.83”.
Where Wilson comes from: keep every p with |p̂ − p| ≤ z√(p(1 − p)/n). Squaring gives (1 + z²/n)p² − (2p̂ + z²/n)p + p̂² ≤ 0, a quadratic whose two roots are the centre ± half-width above. The standard error uses the unknown p, not p̂, which is why the interval never leaves [0, 1].
Try thisThe first three presets are the worked examples above. Then drag items down to 20 and the rate toward 95%: the normal approximation runs past 1 while Wilson stays inside and pulls its centre toward 0.5.
Kappa's standard error. A common large-sample approximation, from Cohen's paper and written out in McHugh 2012, treats the chance term as fixed:
po(1 − po) = 0.75 × 0.25 = 0.1875. (1 − pe)² = 0.49² = 0.2401. SE = √(0.1875 / 24.01) = √0.0078093 = 0.0884.
Interval = 0.4898 ± 1.96 × 0.0884 = 0.4898 ± 0.1732 = 0.32 to 0.66.
It ignores the noise in pe; Fleiss, Cohen and Everitt derived the fuller variance (Fleiss, Cohen and Everitt 1969). The formula-free route is the bootstrap (Efron 1979): resample the 100 items with replacement, recompute kappa thousands of times, keep the middle 95%.
The casebook script draws 5,000 resamples of the 100 (A, B) pairs (random seed 1), computes kappa on each, sorts them, and takes the 126th and 4,875th values: 0.31 to 0.66. It matches the formula within 0.01 because n = 100 and kappa is mid-range; near 0 or 1, or with rare categories, trust the bootstrap.
So on another 100 items the same judges could plausibly score anywhere from 0.32 (“fair”) to 0.66 (“substantial”), and kappas of 0.49 and 0.58 on 100 items each cannot be told apart. A comparison without an interval cannot be acted on: Igor's error bars step.
“Ana's hires do well 80% of the time” on 60 hires means 68% to 88%; against a 75% interviewer on a similar sample, the intervals almost coincide.
75% manager agreement on 100 employees means 66% to 83%; a new rating definition must move it more than that to show.
Agreeing with the reference panel on 75 of 100 wines fits a 66% judge or an 83% one; telling judges apart takes many wines each.
48 of 60 cancers caught means sensitivity 68% to 88%. Reader studies use enriched sets because a narrow interval needs many cancers, and screening has few.
75 of 100 borderline pitches right means 66% to 83%. Tracking settles it by volume: thousands of pitches a season shrink the interval to a point or two.
Sample size: how many items to label
Turn it around: choose the half-width h you can live with and solve for n. For a proportion, by the normal approximation (Wilson agrees once n is in the hundreds):
±0.10: 3.8416 × 0.16 / 0.01 = 61.5, so about 62 items (the casebook's 60 YES items give roughly this).
±0.05: 3.8416 × 0.16 / 0.0025 = 246. ±0.03: 683.
Worst case, p = 0.5, ±0.05: 3.8416 × 0.25 / 0.0025 = 385.
For a sensitivity, n counts only the truly-YES items. At 5% prevalence, 246 YES items means about 4,900 items labelled.
For kappa, solve the approximate SE for n, with po and pe from a pilot:
±0.17 (what the casebook has): 3.8416 × 0.1875 / (0.0289 × 0.2401) = 104, about the 100 items it used.
±0.10: 0.72030 / (0.01 × 0.2401) = 300. ±0.05: 1,200.
This is rough: it inherits the approximate SE, and with rare YES (large pe) the factor 1/(1 − pe)² blows up, so a rare-event judge needs far more items for the same kappa precision.
The 1/√n intuition. Every width here has n under a square root, so quadrupling the items halves it: 25 → 100 → 400 → 1,600 items take a proportion near 0.8 from ±0.16 to ±0.078 to ±0.039 to ±0.020. The first hundred labels buy most of the certainty; ±0.04 to ±0.02 costs another 1,200. Label enough to separate the decisions you face, then stop.
What you can say now
- On the casebook, percent agreement 0.75 becomes kappa 0.49 once chance agreement of 0.51 is removed; Scott's pi (0.489) and Krippendorff's alpha (0.491) differ only in how chance is computed.
- 92% agreement with kappa 0.29 is not a contradiction: rare YES makes chance agreement 0.887, and the identity κ = (PABAK − PI² + BI²)/(1 − PI² + BI²) shows exactly how prevalence and bias move kappa.
- Fleiss' kappa and Krippendorff's alpha extend this to three judges (0.64 and 0.641); the coincidence matrix makes alpha a two-line calculation and handles missing ratings and ordered scales.
- Weighted kappa on one 3×3 table can be 0.53, 0.59 or 0.65 depending on the weights, so the weights are part of the policy.
- Sensitivity 0.80 and specificity 0.85 give J = 0.65 and balanced accuracy 0.825 at any prevalence, but precision is 0.70 at 30% prevalence and 0.22 at 5%.
- The ROC curve is built by sweeping the threshold over the score table; its trapezoid area, 0.868, equals the probability that a truly-YES item outscores a truly-NO one, checked by counting all 8,400 pairs.
- Wilson intervals (48/60 → 0.68–0.88; 75/100 → 0.66–0.83) and the kappa interval (0.32–0.66) show how little 100 items pin down, and why each halving of the interval costs four times the labels.
Sources
- Cohen 1960, A coefficient of agreement for nominal scales · kappa.
- Scott 1955, Reliability of content analysis: the case of nominal scale coding · pi, with pooled chance agreement.
- Cohen 1968, Weighted kappa · partial credit for scaled disagreement.
- Fleiss and Cohen 1973, The equivalence of weighted kappa and the intraclass correlation coefficient · quadratic weights and the ICC.
- Fleiss 1971, Measuring nominal scale agreement among many raters · Fleiss' kappa.
- Fleiss, Cohen and Everitt 1969, Large sample standard errors of kappa and weighted kappa · the fuller variance.
- McHugh 2012, Interrater reliability: the kappa statistic · the simple SE formula, worked.
- Hayes and Krippendorff 2007, Answering the call for a standard reliability measure for coding data · Krippendorff's alpha.
- Krippendorff's alpha (Wikipedia) · the coincidence-matrix formula and distance functions.
- Landis and Koch 1977, The measurement of observer agreement for categorical data · the descriptive kappa bands, which they offered without evidence.
- Feinstein and Cicchetti 1990, High agreement but low kappa: I. The problems of two paradoxes.
- Cicchetti and Feinstein 1990, High agreement but low kappa: II. Resolving the paradoxes · ppos and pneg.
- Byrt, Bishop and Carlin 1993, Bias, prevalence and kappa · PI, BI, PABAK and the identity linking them.
- Youden 1950, Index for rating diagnostic tests · J.
- Youden's J statistic (Wikipedia) · height above the chance line; Peirce's 1884 precursor.
- Hanley and McNeil 1982, The meaning and use of the area under a ROC curve · AUC as a ranking probability, the Wilcoxon link, the SE.
- GraphPad, Details of calculations for ROC curves · the Hanley–McNeil SE written out.
- Wilson 1927, Probable inference, the law of succession, and statistical inference · the score interval.
- Brown, Cai and DasGupta 2001, Interval estimation for a binomial proportion · why not Wald.
- Efron 1979, Bootstrap methods: another look at the jackknife · the bootstrap.
- Igor Dvorkin, Evals with no right answer: agreement, kappa and friends and error bars · where these numbers fit in the recipe.
- Igor Dvorkin, AI testing: confusion matrix, precision and recall.