The kappa paradox and its alternatives
Raters can agree 90% of the time and get a low kappa. See why, then compare PABAK, Brennan–Prediger and Gwet's AC1 on the same data.
What runs in CodeSplash
- Cohen's kappa (two raters) Verified in Python and R
- Gwet's AC1/AC2 and other agreement coefficients Verified in Python and R
You will be able to
- Explain why rare categories depress kappa
- Compare kappa, PABAK, Brennan–Prediger and Gwet's AC1
- Report agreement in a way that survives unbalanced categories
Read first
When chance is already high
ReadSuppose nearly every item is "yes". Two raters who both say "yes" almost always will agree on most items, and most of that isn't skill. Chance agreement is already close to 1, so the denominator gets very small.
Tiny differences in a few rare cases then move a long way. That's the kappa paradox: high agreement, low kappa. It isn't a bug in the arithmetic.
Reach the paradox
ExploreKeep observed agreement at 90% and move the share rated "yes" toward the edge. Watch what chance agreement and do. Then find a setting with at least 90% agreement and below 0.3.
GExplorable · The kappa paradox
How can two raters agree 90% of the time and still get a low kappa?
Guess Cohen's κ for this table.
| Rater 2: yes | Rater 2: no | |
|---|---|---|
| Rater 1: yes | 87 | 5 |
| Rater 1: no | 5 | 3 |
Green cells: agreement. κ = (agreement − chance) / (1 − chance), with chance = 85%.
Commit your prediction above to see the result
Make your prediction to see the result.
One dataset, four coefficients
PredictPredict first
Two raters flag items yes or no, and "yes" is more common. Raw agreement is 76.7%. CodeSplash reports four coefficients, each with its own model of chance agreement.
How do you expect them to rank?
Reveal
Fleiss' κ is lowest at 0.49. Brennan–Prediger, which assumes equal use of categories, gives 0.53. Gwet's AC1 gives 0.57. Same ratings: only the assumed chance agreement differs, at 0.55, 0.50 and 0.46.
Which should you trust?
Read- PABAKPABAKKappa recomputed as if the categories were equally common and the raters' margins equal. For two categories, it's 2·po − 1. is . It rescales raw agreement and assumes balanced categories.
- Brennan–Prediger assumes chance is uniform across categories.
- Gwet's AC1Gwet's AC1An agreement coefficient with a chance term that stays small when one category dominates, so it avoids the kappa paradox. is built to stay stable when one category dominates.
- Cohen's or Fleiss' κ use the observed margins, which is where the paradox comes from.
None of these is the correct answer to the question. They disagree because they assume different things about chance. A prevalence-robust coefficient doesn't make a rare positive category easy to rate: two raters may still rarely agree on the positives.
See it
In the appThe Gwet method reports all of them side by side.
AC1 = .57, 95% CI [0.35, 0.79], p < .001
- AC1
- 0.5719
- 95% CI
- [0.3538, 0.7899]
- p (one-sided)
- < .001
- Percent agreement
- 0.7667
Effect size
- Gwet's AC1 0.5719 95% CI [0.3538, 0.7899]
Plots
View data
| Estimate | Upper | Coefficient | Lower |
|---|---|---|---|
| 0.5719 | 0.7899 | Gwet's AC1 | 0.3538 |
| 0.7667 | 0.8768 | Percent agreement | 0.6565 |
| 0.5333 | 0.7537 | Brennan–Prediger | 0.3130 |
| 0.4872 | 0.7256 | Fleiss' κ (Scott's π) | 0.2488 |
Assumptions
- Sample size — 60 subjects (60 rated at least twice) by 2 raters.
- Category prevalence — The most common category holds 65% of the ratings.
Agreement coefficients (unweighted)
| Coefficient | Estimate | SE | 95% CI low | 95% CI high | p | Chance agreement |
|---|---|---|---|---|---|---|
| Gwet's AC1 | 0.5719 | 0.1090 | 0.3538 | 0.7899 | < .001 | 0.4550 |
| Percent agreement | 0.7667 | 0.0551 | 0.6565 | 0.8768 | — | 0 |
| Brennan–Prediger | 0.5333 | 0.1101 | 0.3130 | 0.7537 | < .001 | 0.5000 |
| Fleiss' κ (Scott's π) | 0.4872 | 0.1191 | 0.2488 | 0.7256 | < .001 | 0.5450 |
Category use
| Category | Share of ratings |
|---|---|
| false | 35.0% |
| true | 65.0% |
- Gwet (2008) linearization variance with n − 1 = 59 df; one-sided p for agreement > 0. Categories: false, true.
The exact R script · R R version 4.5.1 (2025-06-13)
# Gwet's AC1/AC2 and other agreement coefficients
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.gwet 1.0.1 · spec d19cdd3ea5f0c8dc
# Dataset: s3_ratings (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr)
# irrCAC computes the same coefficients: gwet.ac1.raw, pa.coeff.raw, bp.coeff.raw and
# fleiss.kappa.raw (it rounds the printed estimates; cs_agree_gwet keeps full precision).
# %% Data (missing ratings are kept; subjects nobody rated are left out)
raters <- c("flag_a", "flag_b")
kinds <- c(
"flag_a" = "boolean",
"flag_b" = "boolean"
)
stored <- list(
"flag_a" = c("false", "true"),
"flag_b" = c("false", "true")
)
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/s3_ratings.parquet", col_select = raters))
warnings <- list()
cs_check_finite_columns(df, raters) # infinite ratings stop the run (registry/errors.yaml)
if (length(unique(kinds)) > 1) stop("All raters must use the same kind of value (all numbers or all categories)")
numeric <- kinds[[1]] == "numeric"
if (numeric) {
raw <- matrix(sapply(raters, function(r) as.double(df[[r]])), ncol = length(raters))
cat_values <- sort(unique(raw[!is.na(raw)]))
cats <- vapply(cat_values, function(v) if (v == round(v)) sprintf("%.0f", v) else formatC(v, digits = 15, format = "g"), character(1))
codes <- matrix(match(raw, cat_values) - 1, nrow(raw))
} else {
text <- function(v) ifelse(is.na(v), NA_character_, if (is.logical(v)) tolower(as.character(v)) else as.character(v))
cols <- lapply(raters, function(r) text(df[[r]]))
names(cols) <- raters
cats <- character(0)
for (r in raters) {
lv <- if (!is.null(stored[[r]])) stored[[r]] else sort(unique(stats::na.omit(cols[[r]])), method = "radix")
for (v in lv) if (!(v %in% cats)) cats <- c(cats, v) # stored order across raters
}
codes <- matrix(as.double(sapply(raters, function(r) match(cols[[r]], cats) - 1)), ncol = length(raters))
cat_values <- as.double(seq_along(cats))
}
rated <- rowSums(!is.na(codes)) > 0
if (any(!rated)) warnings <- c(warnings, sprintf("%d subjects without any rating were left out.", sum(!rated)))
codes <- codes[rated, , drop = FALSE]
q <- length(cats)
if (q < 2) stop("The raters used only one category; chance-corrected agreement is undefined")
# %% Coefficients
conf <- 0.95
weights <- "identity"
w <- cs_agree_weights(weights, cat_values, numeric)
res <- cs_agree_gwet(codes, q, w, conf)
weighted <- weights != "identity"
name <- if (weighted) "AC2" else "AC1"
fin <- function(v) if (is.null(v) || !is.finite(v)) NA else unname(v)
values <- list()
for (k in c("ac", "bp", "fleiss")) {
r <- res[[k]]
values[[k]] <- r$coeff
values[[paste0(k, "_se")]] <- fin(r$se)
values[[paste0(k, "_low")]] <- fin(r$ci_low)
values[[paste0(k, "_high")]] <- fin(r$ci_high)
values[[paste0(k, "_p")]] <- fin(r$p)
values[[paste0(k, "_pe")]] <- r$pe
}
pr <- res$percent
values$pa <- pr$coeff
values$pa_se <- fin(pr$se)
values$pa_low <- fin(pr$ci_low)
values$pa_high <- fin(pr$ci_high)
values$n <- res$n
values$n_rated <- res$n2
values$q <- q
values$raters <- length(raters)
values$weighted <- if (weighted) 1 else 0
for (i in seq_along(cats)) values[[sprintf("prop[%s]", cats[i])]] <- res$pi[i]
# %% Assumptions
top <- max(res$pi)
assumptions <- list(
list(key = "sample_size", label = "Sample size", status = if (res$n < 30) "warn" else "pass",
detail = paste0(sprintf("%d subjects (%d rated at least twice) by %d raters", res$n, res$n2, length(raters)),
if (res$n < 30) " — the interval is approximate." else ".")),
list(key = "prevalence", label = "Category prevalence", status = if (top > 0.8) "info" else "pass",
detail = if (top > 0.8) sprintf("One category holds %.0f%% of the ratings: κ and π can be low despite high agreement (the kappa paradox); AC1 is designed for this case.", 100 * top)
else sprintf("The most common category holds %.0f%% of the ratings.", 100 * top))
)
# %% Result
pct <- sprintf("%.0f%%", conf * 100)
labels <- c(percent = "Percent agreement", ac = paste("Gwet's", name), bp = "Brennan–Prediger", fleiss = "Fleiss' κ (Scott's π)")
rows <- lapply(c("ac", "percent", "bp", "fleiss"), function(k) {
r <- res[[k]]
list(coefficient = unname(labels[k]), value = r$coeff, se = fin(r$se), ci_low = fin(r$ci_low), ci_high = fin(r$ci_high),
p = if (k != "percent") fin(r$p) else NA, pe = r$pe)
})
ac <- res$ac
coef_labels <- vapply(rows, function(r) r$coefficient, character(1))
cs_publish(list(
method = "agreement.gwet",
methodVersion = "1.0.1",
title = paste("Gwet's", name),
engine = cs_engine_info("stats", "codesplashr"),
n = res$n,
summary = sprintf("Gwet's %s = %.3f, %s CI [%.3f, %.3f] for %d raters and %d subjects (percent agreement %.3f, Fleiss' κ %.3f).",
name, ac$coeff, pct, ac$ci_low, ac$ci_high, length(raters), res$n, pr$coeff, res$fleiss$coeff),
apa = sprintf("%s = %s, %s CI [%s, %s], %s", name, cs_fmt_num(ac$coeff, 2, leading_zero = FALSE), pct, cs_fmt_num(ac$ci_low),
cs_fmt_num(ac$ci_high), cs_fmt_p(ac$p)),
statistics = list(list(key = "ac", label = name, value = ac$coeff), list(key = "ci", label = paste(pct, "CI"), value = c(ac$ci_low, ac$ci_high)),
list(key = "p", label = "p (one-sided)", value = ac$p, format = "p"), list(key = "pa", label = "Percent agreement", value = pr$coeff)),
tables = list(
list(key = "coefficients", title = sprintf("Agreement coefficients (%s)", if (weighted) paste("weights:", weights) else "unweighted"), columns = list(
list(key = "coefficient", label = "Coefficient", type = "string"), list(key = "value", label = "Estimate", type = "number"),
list(key = "se", label = "SE", type = "number"), list(key = "ci_low", label = paste(pct, "CI low"), type = "number"),
list(key = "ci_high", label = paste(pct, "CI high"), type = "number"), list(key = "p", label = "p", type = "pvalue"),
list(key = "pe", label = "Chance agreement", type = "number")
), rows = rows),
list(key = "categories", title = "Category use", columns = list(
list(key = "category", label = "Category", type = "string"), list(key = "prop", label = "Share of ratings", type = "percent")),
rows = lapply(seq_along(cats), function(i) list(category = cats[i], prop = res$pi[i])))
),
effectSizes = list(list(key = "ac", label = paste("Gwet's", name), value = ac$coeff, ciLow = ac$ci_low, ciHigh = ac$ci_high,
ciLevel = conf, method = "Gwet's linearization variance, t interval (upper bound capped at 1)")),
assumptions = assumptions,
warnings = warnings,
notes = list(sprintf("Gwet (2008) linearization variance with n − 1 = %d df; one-sided p for agreement > 0. Categories: %s.", res$n - 1, paste(cats, collapse = ", "))),
charts = list(cs_chart("coefficients", "forest", sprintf("Agreement coefficients (%s CI)", pct), list(
label = cs_col("Coefficient", coef_labels, "categorical", levels = coef_labels),
estimate = cs_col("Estimate", vapply(rows, function(r) r$value, numeric(1)), "numeric"),
low = cs_col("Lower", vapply(rows, function(r) r$ci_low, numeric(1)), "numeric"),
high = cs_col("Upper", vapply(rows, function(r) r$ci_high, numeric(1)), "numeric")
), controls = list(reference = 0))),
values = values
))
AC1 = .57, 95% CI [0.35, 0.79], p < .001
- AC1
- 0.5719
- 95% CI
- [0.3538, 0.7899]
- p (one-sided)
- < .001
- Percent agreement
- 0.7667
Effect size
- Gwet's AC1 0.5719 95% CI [0.3538, 0.7899]
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- Sample size — 60 subjects (60 rated at least twice) by 2 raters.
- Category prevalence — The most common category holds 65% of the ratings.
Agreement coefficients (unweighted)
| Coefficient | Estimate | SE | 95% CI low | 95% CI high | p | Chance agreement |
|---|---|---|---|---|---|---|
| Gwet's AC1 | 0.5719 | 0.1090 | 0.3538 | 0.7899 | < .001 | 0.4550 |
| Percent agreement | 0.7667 | 0.0551 | 0.6565 | 0.8768 | — | 0 |
| Brennan–Prediger | 0.5333 | 0.1101 | 0.3130 | 0.7537 | < .001 | 0.5000 |
| Fleiss' κ (Scott's π) | 0.4872 | 0.1191 | 0.2488 | 0.7256 | < .001 | 0.5450 |
Category use
| Category | Share of ratings |
|---|---|
| false | 35.0% |
| true | 65.0% |
- Gwet (2008) linearization variance with n − 1 = 59 df; one-sided p for agreement > 0. Categories: false, true.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Gwet's AC1/AC2 and other agreement coefficients
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.gwet 1.0.1 · spec d19cdd3ea5f0c8dc
# Dataset: s3_ratings (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import json
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash.stats import agreement_adv as ag # Gwet's coefficients (twin of R's cs_agree_gwet)
# irrCAC (R) computes the same coefficients: gwet.ac1.raw, pa.coeff.raw, bp.coeff.raw and
# fleiss.kappa.raw (it rounds the printed estimates; the twin keeps full precision).
# %% Data (missing ratings are kept; subjects nobody rated are left out)
raters = ["flag_a", "flag_b"]
kinds = {"flag_a":"boolean","flag_b":"boolean"}
stored = json.loads("{\"flag_a\":[\"false\",\"true\"],\"flag_b\":[\"false\",\"true\"]}")
df = pd.read_parquet("tests/parity/fixtures/s3_ratings.parquet", columns=raters)
warnings = []
cs.check_finite_columns(df, raters) # infinite ratings stop the run (registry/errors.yaml)
if len({kinds[r] for r in raters}) > 1:
raise ValueError("All raters must use the same kind of value (all numbers or all categories)")
numeric = kinds[raters[0]] == "numeric"
if numeric:
raw = df[raters].to_numpy(dtype=float)
cat_values = np.unique(raw[~np.isnan(raw)])
cats = [f"{v:.0f}" if float(v).is_integer() else f"{v:.15g}" for v in cat_values]
codes = np.where(np.isnan(raw), np.nan, np.searchsorted(cat_values, np.nan_to_num(raw)))
else:
def text(s):
return [None if pd.isna(v) else (str(v).lower() if isinstance(v, (bool, np.bool_)) else str(v)) for v in s]
cols = {r: text(df[r]) for r in raters}
cats = []
for r in raters:
for v in stored[r] or sorted({v for v in cols[r] if v is not None}):
if v not in cats:
cats.append(v) # stored order across raters
pos = {c: i for i, c in enumerate(cats)}
codes = np.column_stack([[pos[v] if v is not None else np.nan for v in cols[r]] for r in raters]).astype(float)
cat_values = np.arange(1, len(cats) + 1, dtype=float)
rated = np.sum(~np.isnan(codes), axis=1) > 0
if (~rated).any():
warnings.append(f"{int((~rated).sum())} subjects without any rating were left out.")
codes = codes[rated]
q = len(cats)
if q < 2:
raise ValueError("The raters used only one category; chance-corrected agreement is undefined")
# %% Coefficients
conf = 0.95
weights = "identity"
w = ag.weights_matrix(weights, cat_values, numeric)
res = ag.gwet_coefficients(codes, q, w, conf)
weighted = weights != "identity"
name = "AC2" if weighted else "AC1"
nan = lambda v: None if v is None or not np.isfinite(v) else float(v) # noqa: E731
values = {}
for key, prefix in (("ac", "ac"), ("bp", "bp"), ("fleiss", "fleiss")):
r = res[key]
values.update({prefix: r["coeff"], f"{prefix}_se": nan(r["se"]), f"{prefix}_low": nan(r["ci_low"]), f"{prefix}_high": nan(r["ci_high"]),
f"{prefix}_p": nan(r["p"]), f"{prefix}_pe": r["pe"]})
pr = res["percent"]
values.update({"pa": pr["coeff"], "pa_se": nan(pr["se"]), "pa_low": nan(pr["ci_low"]), "pa_high": nan(pr["ci_high"]),
"n": float(res["n"]), "n_rated": float(res["n2"]), "q": float(q), "raters": float(len(raters)), "weighted": 1.0 if weighted else 0.0})
for c, p_c in zip(cats, res["pi"]):
values[f"prop[{c}]"] = float(p_c)
# %% Assumptions
top = float(np.max(res["pi"]))
assumptions = [
{"key": "sample_size", "label": "Sample size", "status": "warn" if res["n"] < 30 else "pass",
"detail": f"{res['n']} subjects ({res['n2']} rated at least twice) by {len(raters)} raters" + (" — the interval is approximate." if res["n"] < 30 else ".")},
{"key": "prevalence", "label": "Category prevalence", "status": "info" if top > 0.8 else "pass",
"detail": (f"One category holds {top:.0%} of the ratings: κ and π can be low despite high agreement (the kappa paradox); AC1 is designed for this case."
if top > 0.8 else f"The most common category holds {top:.0%} of the ratings.")},
]
# %% Result
pct = f"{conf:.0%}"
labels = {"percent": "Percent agreement", "ac": f"Gwet's {name}", "bp": "Brennan–Prediger", "fleiss": "Fleiss' κ (Scott's π)"}
rows = [{"coefficient": labels[k], "value": res[k]["coeff"], "se": nan(res[k]["se"]), "ci_low": nan(res[k]["ci_low"]), "ci_high": nan(res[k]["ci_high"]),
"p": nan(res[k]["p"]) if k != "percent" else None, "pe": res[k]["pe"]} for k in ("ac", "percent", "bp", "fleiss")]
ac = res["ac"]
cs.publish({
"method": "agreement.gwet",
"methodVersion": "1.0.1",
"title": f"Gwet's {name}",
"engine": cs.engine_info("numpy", "scipy", "codesplash"),
"n": int(res["n"]),
"summary": f"Gwet's {name} = {ac['coeff']:.3f}, {pct} CI [{ac['ci_low']:.3f}, {ac['ci_high']:.3f}] for {len(raters)} raters and {res['n']} subjects "
f"(percent agreement {pr['coeff']:.3f}, Fleiss' κ {res['fleiss']['coeff']:.3f}).",
"apa": f"{name} = {cs.fmt_num(ac['coeff'], 2, leading_zero=False)}, {pct} CI [{cs.fmt_num(ac['ci_low'])}, {cs.fmt_num(ac['ci_high'])}], {cs.fmt_p(ac['p'])}",
"statistics": [{"key": "ac", "label": name, "value": ac["coeff"]}, {"key": "ci", "label": f"{pct} CI", "value": [ac["ci_low"], ac["ci_high"]]},
{"key": "p", "label": "p (one-sided)", "value": ac["p"], "format": "p"}, {"key": "pa", "label": "Percent agreement", "value": pr["coeff"]}],
"tables": [{"key": "coefficients", "title": f"Agreement coefficients ({'weights: ' + weights if weighted else 'unweighted'})", "columns": [
{"key": "coefficient", "label": "Coefficient", "type": "string"}, {"key": "value", "label": "Estimate", "type": "number"},
{"key": "se", "label": "SE", "type": "number"}, {"key": "ci_low", "label": f"{pct} CI low", "type": "number"},
{"key": "ci_high", "label": f"{pct} CI high", "type": "number"}, {"key": "p", "label": "p", "type": "pvalue"},
{"key": "pe", "label": "Chance agreement", "type": "number"},
], "rows": rows},
{"key": "categories", "title": "Category use", "columns": [
{"key": "category", "label": "Category", "type": "string"}, {"key": "prop", "label": "Share of ratings", "type": "percent"}],
"rows": [{"category": c, "prop": float(p_c)} for c, p_c in zip(cats, res["pi"])]}],
"effectSizes": [{"key": "ac", "label": f"Gwet's {name}", "value": ac["coeff"], "ciLow": ac["ci_low"], "ciHigh": ac["ci_high"],
"ciLevel": conf, "method": "Gwet's linearization variance, t interval (upper bound capped at 1)"}],
"assumptions": assumptions,
"warnings": warnings,
"notes": [f"Gwet (2008) linearization variance with n − 1 = {res['n'] - 1} df; one-sided p for agreement > 0. Categories: {', '.join(cats)}."],
"charts": [cs.chart("coefficients", "forest", f"Agreement coefficients ({pct} CI)", {
"label": cs.col("Coefficient", [r["coefficient"] for r in rows], "categorical", levels=[r["coefficient"] for r in rows]),
"estimate": cs.col("Estimate", [r["value"] for r in rows], "numeric"),
"low": cs.col("Lower", [r["ci_low"] for r in rows], "numeric"),
"high": cs.col("Upper", [r["ci_high"] for r in rows], "numeric"),
}, controls={"reference": 0})],
"values": values,
})
Cohen's κ on a boolean flag also reports PABAK. In this other example, = 0.77 and PABAK = 0.80.
Report the table
ReflectFor a rare yes/no category, the most honest report includes the 2×2 table, agreement among positives and among negatives, and more than one coefficient.
Think of a rating task you know where one category is rare. What share of "yes" would you expect? Which is worse there, disagreeing on a positive or on a negative?
Check your understanding
CheckpointCheck yourself
Two raters agree on 90% of items. What is PABAK?
Show the answer
Answer: 0.8
.
Check yourself
Why does kappa fall when nearly all items are in one category, with raw agreement held constant?
Show the answer
Answer: a
. As approaches , the numerator shrinks toward zero.
Check yourself
A team reports κ = 0.35, then switches to AC1 = 0.80 "because kappa has problems". What's the honest way to report this?
Show the answer
Answer: c
Switching to the larger number after seeing both is a forking path. Show the raw table so readers can judge.
Recap
Recap- A rare category raises chance agreement and can push κ down despite high raw agreement.
- PABAK, Brennan–Prediger and AC1 model chance differently, and their answers differ for that reason.
- Show the table and pre-specify the primary coefficient.
Concepts in this lesson