Skip to content

Many raters and missing ratings: Fleiss and Krippendorff

Beyond two raters, use Fleiss' kappa when every subject has every rater, and Krippendorff's alpha when ratings are missing or the scale isn't nominal.

Applied ~11 min7 steps

What runs in CodeSplash

You will be able to

  • Choose between Fleiss' kappa and Krippendorff's alpha
  • Set the level of measurement for Krippendorff's alpha
  • Read alpha's bootstrap interval and its threshold probabilities

Read first

01

Beyond two raters

In the app

Fleiss' kappaFleiss' kappaChance-corrected agreement for several raters on a category, where different raters may judge each item. extends chance-corrected agreement to any number of raters assigning nominal categories. Each subject should have the same number of ratings, though not necessarily from the same people.

With 5 raters and 4 categories across 149 subjects, κ\kappa = 0.54 (95% interval 0.48 to 0.60).

Fleiss' kappaRecorded · Python and R agreeRecorded 2026-11-17 · 28 values compared
R

κ = .54, 95% CI [0.48, 0.60], z = 33.95, p < .001

κ
0.5411
95% CI
[0.4791, 0.6032]
p
< .001

Effect size

  • Fleiss' κ 0.5411 95% CI [0.4791, 0.6032]

Plots

Category use by raterWhat do the values of a square or rectangular result matrix look like at a glance?
View data
CategoryShareRaterShare of subjects
none38%rater_a0.3758
mild30%rater_a0.2953
moderate22%rater_a0.2215
severe11%rater_a0.1074
none36%rater_b0.3624
mild31%rater_b0.3087
moderate20%rater_b0.2013
severe13%rater_b0.1275
none37%rater_c0.3691
mild34%rater_c0.3356
moderate18%rater_c0.1812
severe11%rater_c0.1141
none37%rater_d0.3691
mild36%rater_d0.3557
moderate17%rater_d0.1745
severe10%rater_d0.1007
none38%rater e0.3758
mild30%rater e0.2953
moderate21%rater e0.2148
severe11%rater e0.1141

Assumptions

  • Sample size — 149 subjects rated by 5 raters.
  • Category use — Every category has at least 5% of the ratings.

Agreement by category

CategoryShare of ratingsκzp
none37.0%0.654725.271< .001
mild31.8%0.412115.909< .001
moderate19.9%0.468818.096< .001
severe11.3%0.671325.911< .001
  • 1 of 150 rows were left out because a value was missing.
  • z test with the null SE of Fleiss, Nee & Landis (1979); interval from a jackknife SE. Categories: none, mild, moderate, severe.
The exact R script · R R version 4.5.1 (2025-06-13)
# Fleiss' kappa (several raters)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.fleiss 1.0.1 · spec c346f434f1807a55
# Dataset: ratings_sim (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ratings_sim.parquet", col_select = c("rater_a", "rater_b", "rater_c", "rater_d", "rater e")))
n_input <- nrow(df)
df[["rater_a"]] <- factor(df[["rater_a"]], levels = c("none", "mild", "moderate", "severe"))  # stored level order
df[["rater_b"]] <- factor(df[["rater_b"]], levels = c("none", "mild", "moderate", "severe"))  # stored level order
df[["rater_c"]] <- factor(df[["rater_c"]], levels = c("none", "mild", "moderate", "severe"))  # stored level order
df[["rater_d"]] <- factor(df[["rater_d"]], levels = c("none", "mild", "moderate", "severe"))  # stored level order
df[["rater e"]] <- factor(df[["rater e"]], levels = c("none", "mild", "moderate", "severe"))  # stored level order
df <- df[stats::complete.cases(df[c("rater_a", "rater_b", "rater_c", "rater_d", "rater e")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("rater_a", "rater_b", "rater_c", "rater_d", "rater e"))  # infinite values stop the run (registry/errors.yaml)

# %% Category counts per subject
raters <- c("rater_a", "rater_b", "rater_c", "rater_d", "rater e")
cats <- unique(unlist(lapply(raters, function(r) levels(df[[r]]))))  # stored order
k <- length(cats)
if (k < 2) cs_error("CS_E_UNDEFINED", what = "Fleiss' κ", reason = "the raters used only one category")
codes <- sapply(raters, function(r) match(as.character(df[[r]]), cats))
codes <- matrix(codes, ncol = length(raters))
n <- nrow(codes)
m <- ncol(codes)
counts <- t(apply(codes, 1, function(x) tabulate(x, k)))
counts <- matrix(counts, nrow = n)

# %% Fleiss' kappa
conf <- 0.95
res <- cs_fleiss(counts, conf)  # twin of codesplash.stats.agreement.fleiss
values <- res[c("kappa", "ci_low", "ci_high", "se", "se0", "z", "p", "po", "pe")]
values$n <- n
values$m <- m
values$k <- k
fin <- function(x) if (!is.finite(x)) NA else unname(x)
# The jackknife interval is undefined when leaving a subject out leaves one category (tiny samples): null.
for (key in c("se", "ci_low", "ci_high")) values[key] <- list(fin(values[[key]]))
rows <- list()
for (i in seq_along(cats)) {
  c0 <- cats[i]
  values[[sprintf("prop[%s]", c0)]] <- res$pj[i]
  values[[sprintf("kappa[%s]", c0)]] <- fin(res$kappa_j[i])
  values[[sprintf("z[%s]", c0)]] <- fin(res$z_j[i])
  values[[sprintf("p[%s]", c0)]] <- fin(res$p_j[i])
  rows[[i]] <- list(category = c0, prop = res$pj[i], kappa = fin(res$kappa_j[i]), z = fin(res$z_j[i]), p = fin(res$p_j[i]))
}

# %% Assumptions
rare <- cats[res$pj < 0.05]
assumptions <- list(
  list(key = "sample_size", label = "Sample size", status = if (n < 30) "warn" else "pass",
       detail = paste0(sprintf("%d subjects rated by %d raters", n, m), if (n < 30) " — the interval is approximate." else ".")),
  list(key = "category_use", label = "Category use", status = if (length(rare)) "warn" else "pass",
       detail = if (length(rare)) sprintf("Rarely used (< 5%% of ratings): %s.", paste(rare, collapse = ", ")) else "Every category has at least 5% of the ratings.")
)

# %% Result
pct <- sprintf("%.0f%%", conf * 100)
share <-as.vector(vapply(seq_len(m), function(j) vapply(seq_len(k), function(i) mean(codes[, j] == i), numeric(1)), numeric(k)))
cs_publish(list(
  method = "agreement.fleiss",
  methodVersion = "1.0.1",
  title = "Fleiss' kappa",
  engine = cs_engine_info("stats", "codesplashr"),
  n = n,
  summary = sprintf("Fleiss' κ = %.3f, %s CI [%.3f, %.3f] for %d raters and %d subjects.", res$kappa, pct, res$ci_low, res$ci_high, m, n),
  apa = sprintf("κ = %s, %s CI [%s, %s], z = %s, %s", cs_fmt_num(res$kappa, 2, leading_zero = FALSE), pct, cs_fmt_num(res$ci_low),
                cs_fmt_num(res$ci_high), cs_fmt_num(res$z), cs_fmt_p(res$p)),
  statistics = list(list(key = "kappa", label = "κ", value = res$kappa), list(key = "ci", label = paste(pct, "CI"), value = c(res$ci_low, res$ci_high)),
                    list(key = "p", label = "p", value = res$p, format = "p")),
  tables = list(list(key = "categories", title = "Agreement by category", columns = list(
    list(key = "category", label = "Category", type = "string"), list(key = "prop", label = "Share of ratings", type = "percent"),
    list(key = "kappa", label = "κ", type = "number"), list(key = "z", label = "z", type = "number"), list(key = "p", label = "p", type = "pvalue")
  ), rows = rows)),
  effectSizes = list(list(key = "kappa", label = "Fleiss' κ", value = res$kappa, ciLow = res$ci_low, ciHigh = res$ci_high,
                          ciLevel = conf, method = "jackknife SE over subjects")),
  assumptions = assumptions,
  warnings = warnings,
  notes = list(sprintf("z test with the null SE of Fleiss, Nee & Landis (1979); interval from a jackknife SE. Categories: %s.", paste(cats, collapse = ", "))),
  charts = list(cs_chart("use", "matrix-heatmap", "Category use by rater", list(
    row = cs_col("Rater", rep(raters, each = k), "categorical", levels = raters),
    col = cs_col("Category", rep(cats, times = m), "categorical", levels = cats),
    value = cs_col("Share of subjects", share, "numeric"),
    label = cs_col("Share", sprintf("%.0f%%", 100 * share), "categorical")
  ), controls = list(scale = "sequential"))),
  values = values
))
Python

κ = .54, 95% CI [0.48, 0.60], z = 33.95, p < .001

κ
0.5411
95% CI
[0.4791, 0.6032]
p
< .001

Effect size

  • Fleiss' κ 0.5411 95% CI [0.4791, 0.6032]

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Sample size — 149 subjects rated by 5 raters.
  • Category use — Every category has at least 5% of the ratings.

Agreement by category

CategoryShare of ratingsκzp
none37.0%0.654725.271< .001
mild31.8%0.412115.909< .001
moderate19.9%0.468818.096< .001
severe11.3%0.671325.911< .001
  • 1 of 150 rows were left out because a value was missing.
  • z test with the null SE of Fleiss, Nee & Landis (1979); interval from a jackknife SE. Categories: none, mild, moderate, severe.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Fleiss' kappa (several raters)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.fleiss 1.0.1 · spec c346f434f1807a55
# Dataset: ratings_sim (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import agreement as ag  # Fleiss' κ (twin of R's cs_fleiss)

# %% Data
df = pd.read_parquet("tests/parity/fixtures/ratings_sim.parquet", columns=["rater_a", "rater_b", "rater_c", "rater_d", "rater e"])
n_input = len(df)
df["rater_a"] = pd.Categorical(df["rater_a"], categories=["none", "mild", "moderate", "severe"])  # stored level order
df["rater_b"] = pd.Categorical(df["rater_b"], categories=["none", "mild", "moderate", "severe"])  # stored level order
df["rater_c"] = pd.Categorical(df["rater_c"], categories=["none", "mild", "moderate", "severe"])  # stored level order
df["rater_d"] = pd.Categorical(df["rater_d"], categories=["none", "mild", "moderate", "severe"])  # stored level order
df["rater e"] = pd.Categorical(df["rater e"], categories=["none", "mild", "moderate", "severe"])  # stored level order
df = df.dropna(subset=["rater_a", "rater_b", "rater_c", "rater_d", "rater e"])  # listwise deletion over the analysis columns
df["rater_a"] = df["rater_a"].cat.remove_unused_categories()
df["rater_b"] = df["rater_b"].cat.remove_unused_categories()
df["rater_c"] = df["rater_c"].cat.remove_unused_categories()
df["rater_d"] = df["rater_d"].cat.remove_unused_categories()
df["rater e"] = df["rater e"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["rater_a", "rater_b", "rater_c", "rater_d", "rater e"])  # infinite values stop the run (registry/errors.yaml)

# %% Category counts per subject
raters = ["rater_a", "rater_b", "rater_c", "rater_d", "rater e"]
cats = list(dict.fromkeys(str(x) for r in raters for x in df[r].cat.categories))  # stored order
k = len(cats)
if k < 2:
    cs.cs_error("CS_E_UNDEFINED", what="Fleiss' κ", reason="the raters used only one category")
codes = np.column_stack([[cats.index(x) for x in df[r].astype(str)] for r in raters])
n, m = codes.shape
counts = np.zeros((n, k))
for j in range(m):
    np.add.at(counts, (np.arange(n), codes[:, j]), 1)

# %% Fleiss' kappa
conf = 0.95
res = ag.fleiss(counts, conf)
values = {key: float(res[key]) for key in ("kappa", "ci_low", "ci_high", "se", "se0", "z", "p", "po", "pe")}
values.update({"n": float(n), "m": float(m), "k": float(k)})
rows = []
nan = lambda x: None if not np.isfinite(x) else float(x)  # noqa: E731
# The jackknife interval is undefined when leaving a subject out leaves one category (tiny samples): null.
for key in ("se", "ci_low", "ci_high"):
    values[key] = nan(values[key])
for i, c in enumerate(cats):
    values[f"prop[{c}]"] = float(res["pj"][i])
    values[f"kappa[{c}]"], values[f"z[{c}]"], values[f"p[{c}]"] = nan(res["kappa_j"][i]), nan(res["z_j"][i]), nan(res["p_j"][i])
    rows.append({"category": c, "prop": float(res["pj"][i]), "kappa": values[f"kappa[{c}]"], "z": values[f"z[{c}]"], "p": values[f"p[{c}]"]})

# %% Assumptions
rare = [c for i, c in enumerate(cats) if res["pj"][i] < 0.05]
assumptions = [
    {"key": "sample_size", "label": "Sample size", "status": "warn" if n < 30 else "pass",
     "detail": f"{n} subjects rated by {m} raters" + (" — the interval is approximate." if n < 30 else ".")},
    {"key": "category_use", "label": "Category use", "status": "warn" if rare else "pass",
     "detail": f"Rarely used (< 5% of ratings): {', '.join(rare)}." if rare else "Every category has at least 5% of the ratings."},
]

# %% Result
pct = f"{conf:.0%}"
share = [float(np.mean(codes[:, j] == i)) for j in range(m) for i in range(k)]
cs.publish({
    "method": "agreement.fleiss",
    "methodVersion": "1.0.1",
    "title": "Fleiss' kappa",
    "engine": cs.engine_info("numpy", "scipy", "codesplash"),
    "n": int(n),
    "summary": f"Fleiss' κ = {res['kappa']:.3f}, {pct} CI [{res['ci_low']:.3f}, {res['ci_high']:.3f}] for {m} raters and {n} subjects.",
    "apa": f"κ = {cs.fmt_num(res['kappa'], 2, leading_zero=False)}, {pct} CI [{cs.fmt_num(res['ci_low'])}, {cs.fmt_num(res['ci_high'])}], z = {cs.fmt_num(res['z'])}, {cs.fmt_p(res['p'])}",
    "statistics": [{"key": "kappa", "label": "κ", "value": res["kappa"]}, {"key": "ci", "label": f"{pct} CI", "value": [res["ci_low"], res["ci_high"]]},
                   {"key": "p", "label": "p", "value": res["p"], "format": "p"}],
    "tables": [{"key": "categories", "title": "Agreement by category", "columns": [
        {"key": "category", "label": "Category", "type": "string"}, {"key": "prop", "label": "Share of ratings", "type": "percent"},
        {"key": "kappa", "label": "κ", "type": "number"}, {"key": "z", "label": "z", "type": "number"}, {"key": "p", "label": "p", "type": "pvalue"},
    ], "rows": rows}],
    "effectSizes": [{"key": "kappa", "label": "Fleiss' κ", "value": res["kappa"], "ciLow": res["ci_low"], "ciHigh": res["ci_high"],
                     "ciLevel": conf, "method": "jackknife SE over subjects"}],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"z test with the null SE of Fleiss, Nee & Landis (1979); interval from a jackknife SE. Categories: {', '.join(cats)}."],
    "charts": [cs.chart("use", "matrix-heatmap", "Category use by rater", {
        "row": cs.col("Rater", [r for r in raters for _ in cats], "categorical", levels=raters),
        "col": cs.col("Category", [c for _ in raters for c in cats], "categorical", levels=cats),
        "value": cs.col("Share of subjects", share, "numeric"),
        "label": cs.col("Share", [f"{x:.0%}" for x in share], "categorical"),
    }, controls={"scale": "sequential"})],
    "values": values,
})
02

When Fleiss doesn't fit

Predict

Predict first

Four coders each rated a dozen documents, but not every coder rated every document. Which approach uses all the ratings you have?

Use Fleiss' kappa on complete rows onlyUse Krippendorff's alphaAverage the Cohen's kappa of every pair
Reveal

Krippendorff's alpha. It works from pairs of values within each unit, so a unit needs only two ratings. Here 11 of 12 units qualify, giving α\alpha = 0.74. Dropping incomplete rows would throw away information, and possibly the difficult cases.

03

How alpha works

Read

Krippendorff's alphaKrippendorff's alphaChance-corrected agreement for any number of raters and any scale, and it tolerates missing ratings. compares observed disagreement with the disagreement expected by chance:

α=1−DoDe\alpha = 1 - \frac{D_o}{D_e}

What counts as disagreement depends on the Level of measurement:

  • Nominal: any difference counts the same.
  • Ordinal: larger rank distances count more.
  • Interval: squared differences.
  • Ratio: differences relative to size.

Choosing the level changes the answer, so choose it from the scale, not from the result.

04

Read a threshold, not a star

In the app

Krippendorff suggested relying on data with α≥0.8\alpha \ge 0.8 and drawing only tentative conclusions from α\alpha between 0.6670.667 and 0.8. The method's bootstrap estimates the chance that the true α\alpha falls below each.

In this interval-scale example, α\alpha = 0.85. The bootstrap puts 33.4% of its resamples below 0.8 and 14.4% below 0.667. With 11 units, you can't rule out low reliability, even though the estimate looks fine.

Krippendorff's alphaRecorded · Python and R agreeRecorded 2026-11-17 · 17 values compared
R

Krippendorff's α = .85, 90% CI [0.54, 0.99]

α
0.8491
90% CI
[0.5404, 0.9854]
Observed disagreement Do
0.4333
Expected disagreement De
2.872

Effect size

  • Krippendorff's α 0.8491 90% CI [0.5404, 0.9854]

Plots

Coincidences of valuesWhat do the values of a square or rectangular result matrix look like at a glance?
View data
Paired withCountValueCoincidences
17.017
21.311.333
30.310.3333
40.310.3333
50.010
11.321.333
210.0210
31.321.333
40.320.3333
50.020
10.330.3333
21.331.333
38.038
40.330.3333
50.030
10.340.3333
20.340.3333
30.340.3333
44.044
50.040
10.050
20.050
30.050
40.050
53.053

Assumptions

  • Units with two or more ratings — 11 of 12 units have two or more ratings (40 pairable values) — α is unstable with so few pairable values.
  • Level of measurement — Interval difference function over 5 distinct values.

Coincidence matrix (pairable values)

Value12345Total
171.3330.33330.333309
21.333101.3330.3333013
30.33331.33380.3333010
40.33330.33330.3333405
5000033
  • Interval α from the coincidence matrix (Krippendorff 2011); units with fewer than two ratings are left out.
  • Percentile bootstrap over 11 units, 500 resamples, seed 42 (the same resamples in Python and R). P(α < .667) = 0.144; P(α < .800) = 0.334.
The exact R script · R R version 4.5.1 (2025-06-13)
# Krippendorff's alpha (any number of raters, missing ratings)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.krippendorff 1.0.1 · spec eef779cdcc0f4084
# Dataset: s3_kripp (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# irr::kripp.alpha(t(x), method = level) computes the same alpha; the twin cs_agree_kripp adds the
# coincidence matrix and a bootstrap over units drawn from the shared seed.

# %% Data (missing ratings are kept: alpha uses every unit with two or more ratings)
raters <- c("rater_1", "rater_2", "rater_3", "rater 4")
kinds <- c(
  "rater_1" = "numeric",
  "rater_2" = "numeric",
  "rater_3" = "numeric",
  "rater 4" = "numeric"
)
stored <- list(
  "rater_1" = NULL,
  "rater_2" = NULL,
  "rater_3" = NULL,
  "rater 4" = NULL
)
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/s3_kripp.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"
cats <- NULL
if (numeric) {
  x <- sapply(raters, function(r) as.double(df[[r]]))
  x <- matrix(x, ncol = length(raters))
} 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
  }
  x <- sapply(raters, function(r) match(cols[[r]], cats) - 1)
  x <- matrix(as.double(x), ncol = length(raters))
}

level <- "interval"
if (level == "auto") level <- if (numeric) "interval" else "nominal"
if (level %in% c("interval", "ratio") && !numeric) {
  stop(sprintf("%s alpha needs numeric ratings; choose nominal or ordinal for categories", tools::toTitleCase(level)))
}
if (level == "ratio" && min(x, na.rm = TRUE) < 0) stop("Ratio alpha needs non-negative values")

# %% Krippendorff's alpha
conf <- 0.9
boot <- as.integer(500)
seed <- 42  # portable Wichmann–Hill stream: Python draws the same resamples for this seed
res <- cs_agree_kripp(x, level, boot = boot, seed = seed, conf = conf)
vals <- res$values
label <- function(v) {
  if (!is.null(cats)) return(cats[v + 1])
  if (v == round(v)) sprintf("%.0f", v) else formatC(v, digits = 15, format = "g")
}
labels <- vapply(vals, label, character(1))
units_total <- sum(rowSums(!is.na(x)) > 0)
has_ci <- boot > 0 && is.finite(res$ci_low)
na_unless <- function(v) if (has_ci) v else NA
values <- list(
  alpha = res$alpha, do = res$do, de = res$de, ci_low = na_unless(res$ci_low), ci_high = na_unless(res$ci_high),
  units = res$units, units_total = units_total, pairable = res$pairable, n_values = length(vals), raters = length(raters),
  q_667 = na_unless(if (has_ci) unname(res$q[1]) else NA), q_800 = na_unless(if (has_ci) unname(res$q[2]) else NA)
)
n_c <- rowSums(res$o)
for (i in seq_along(vals)) values[[sprintf("n_value[%s]", labels[i])]] <- n_c[i]

# %% Assumptions
few <- res$pairable < 50 || res$units < 10
assumptions <- list(
  list(key = "units", label = "Units with two or more ratings", status = if (few) "warn" else "pass",
       detail = paste0(sprintf("%d of %d units have two or more ratings (%.0f pairable values)", res$units, units_total, res$pairable),
                       if (few) " — α is unstable with so few pairable values." else ".")),
  list(key = "level", label = "Level of measurement", status = "info",
       detail = paste0(sprintf("%s difference function over %d distinct values", tools::toTitleCase(level), length(vals)),
                       if (level == "ordinal") sprintf(" (category order: %s).", paste(labels, collapse = ", ")) else "."))
)

# %% Result
pct <- sprintf("%.0f%%", conf * 100)
k <- length(vals)
rows <- lapply(seq_len(k), function(i) {
  r <- list(value = labels[i])
  for (j in seq_len(k)) r[[sprintf("v%d", j - 1)]] <- res$o[i, j]
  r$n <- n_c[i]
  r
})
cols <- c(list(list(key = "value", label = "Value", type = "string")),
          lapply(seq_len(k), function(j) list(key = sprintf("v%d", j - 1), label = labels[j], type = "number")),
          list(list(key = "n", label = "Total", type = "number")))
flat_o <- as.vector(t(res$o))
stats_list <- list(list(key = "alpha", label = "α", value = res$alpha))
if (has_ci) stats_list <- c(stats_list, list(list(key = "ci", label = paste(pct, "CI"), value = c(res$ci_low, res$ci_high))))
stats_list <- c(stats_list, list(list(key = "do", label = "Observed disagreement Do", value = res$do),
                                 list(key = "de", label = "Expected disagreement De", value = res$de)))
notes <- list(sprintf("%s α from the coincidence matrix (Krippendorff 2011); units with fewer than two ratings are left out.", tools::toTitleCase(level)))
if (has_ci) {
  notes <- c(notes, sprintf("Percentile bootstrap over %d units, %d resamples, seed %s (the same resamples in Python and R). P(α < .667) = %.3f; P(α < .800) = %.3f.",
                            res$units, boot, seed, res$q[1], res$q[2]))
}
cs_publish(list(
  method = "agreement.krippendorff",
  methodVersion = "1.0.1",
  title = "Krippendorff's alpha",
  engine = cs_engine_info("stats", "codesplashr"),
  n = res$units,
  summary = paste0(sprintf("Krippendorff's α (%s) = %.3f", level, res$alpha),
                   if (has_ci) sprintf(", %s CI [%.3f, %.3f]", pct, res$ci_low, res$ci_high) else "",
                   sprintf(" for %d raters and %d units.", length(raters), res$units)),
  apa = paste0(sprintf("Krippendorff's α = %s", cs_fmt_num(res$alpha, 2, leading_zero = FALSE)),
               if (has_ci) sprintf(", %s CI [%s, %s]", pct, cs_fmt_num(res$ci_low), cs_fmt_num(res$ci_high)) else ""),
  statistics = stats_list,
  tables = list(list(key = "coincidences", title = "Coincidence matrix (pairable values)", columns = cols, rows = rows)),
  effectSizes = list(list(key = "alpha", label = "Krippendorff's α", value = res$alpha, ciLow = na_unless(res$ci_low), ciHigh = na_unless(res$ci_high),
                          ciLevel = conf, method = if (has_ci) sprintf("percentile bootstrap over units (%d resamples)", boot) else "no interval")),
  assumptions = assumptions,
  warnings = warnings,
  notes = notes,
  charts = list(cs_chart("coincidences", "matrix-heatmap", "Coincidences of values", list(
    row = cs_col("Value", rep(labels, each = k), "categorical", levels = labels),
    col = cs_col("Paired with", rep(labels, times = k), "categorical", levels = labels),
    value = cs_col("Coincidences", flat_o, "numeric"),
    label = cs_col("Count", sprintf("%.1f", flat_o), "categorical")
  ), controls = list(scale = "sequential"))),
  values = values
))
Python

Krippendorff's α = .85, 90% CI [0.54, 0.99]

α
0.8491
90% CI
[0.5404, 0.9854]
Observed disagreement Do
0.4333
Expected disagreement De
2.872

Effect size

  • Krippendorff's α 0.8491 90% CI [0.5404, 0.9854]

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Units with two or more ratings — 11 of 12 units have two or more ratings (40 pairable values) — α is unstable with so few pairable values.
  • Level of measurement — Interval difference function over 5 distinct values.

Coincidence matrix (pairable values)

Value12345Total
171.3330.33330.333309.000
21.333101.3330.3333013.000
30.33331.33380.3333010
40.33330.33330.3333405
5000033
  • Interval α from the coincidence matrix (Krippendorff 2011); units with fewer than two ratings are left out.
  • Percentile bootstrap over 11 units, 500 resamples, seed 42 (the same resamples in Python and R). P(α < .667) = 0.144; P(α < .800) = 0.334.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Krippendorff's alpha (any number of raters, missing ratings)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.krippendorff 1.0.1 · spec eef779cdcc0f4084
# Dataset: s3_kripp (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  # Krippendorff's α (twin of R's cs_agree_kripp)

# krippendorff.alpha(reliability_data=x.T, level_of_measurement=level) computes the same α; the twin
# adds the coincidence matrix and a bootstrap over units drawn from the shared seed.

# %% Data (missing ratings are kept: α uses every unit with two or more ratings)
raters = ["rater_1", "rater_2", "rater_3", "rater 4"]
kinds = {"rater 4":"numeric","rater_1":"numeric","rater_2":"numeric","rater_3":"numeric"}
stored = json.loads("{\"rater 4\":null,\"rater_1\":null,\"rater_2\":null,\"rater_3\":null}")
df = pd.read_parquet("tests/parity/fixtures/s3_kripp.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:
    x = df[raters].to_numpy(dtype=float)
    cats = None
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)}
    x = np.column_stack([[pos[v] if v is not None else np.nan for v in cols[r]] for r in raters]).astype(float)

level = "interval"
if level == "auto":
    level = "interval" if numeric else "nominal"
if level in ("interval", "ratio") and not numeric:
    raise ValueError(f"{level.capitalize()} α needs numeric ratings; choose nominal or ordinal for categories")
if level == "ratio" and np.nanmin(x) < 0:
    raise ValueError("Ratio α needs non-negative values")

# %% Krippendorff's alpha
conf = 0.9
boot = int(500)
seed = 42  # portable Wichmann–Hill stream: R draws the same resamples for this seed
res = ag.kripp_alpha(x, level, boot=boot, seed=seed, conf=conf)
vals = res["values"]


def label(v):
    if cats is not None:
        return cats[int(v)]
    return f"{v:.0f}" if float(v).is_integer() else f"{v:.15g}"


labels = [label(v) for v in vals]
units_total = int(np.sum(np.sum(~np.isnan(x), axis=1) > 0))
has_ci = boot > 0 and np.isfinite(res["ci_low"])
values = {
    "alpha": res["alpha"], "do": res["do"], "de": res["de"],
    "ci_low": res["ci_low"] if has_ci else None, "ci_high": res["ci_high"] if has_ci else None,
    "units": float(res["units"]), "units_total": float(units_total), "pairable": res["pairable"],
    "n_values": float(len(vals)), "raters": float(len(raters)),
    "q_667": res["q"][0.667] if has_ci else None, "q_800": res["q"][0.8] if has_ci else None,
}
n_c = res["o"].sum(axis=1)
for lb, nc in zip(labels, n_c):
    values[f"n_value[{lb}]"] = float(nc)

# %% Assumptions
assumptions = [
    {"key": "units", "label": "Units with two or more ratings", "status": "warn" if res["pairable"] < 50 or res["units"] < 10 else "pass",
     "detail": f"{res['units']} of {units_total} units have two or more ratings ({res['pairable']:.0f} pairable values)"
               + (" — α is unstable with so few pairable values." if res["pairable"] < 50 or res["units"] < 10 else ".")},
    {"key": "level", "label": "Level of measurement", "status": "info",
     "detail": f"{level.capitalize()} difference function over {len(vals)} distinct values" + (f" (category order: {', '.join(labels)})." if level == "ordinal" else ".")},
]

# %% Result
pct = f"{conf:.0%}"
rows = [{"value": labels[i], **{f"v{j}": float(res["o"][i, j]) for j in range(len(vals))}, "n": float(n_c[i])} for i in range(len(vals))]
flat_o = [float(res["o"][i, j]) for i in range(len(vals)) for j in range(len(vals))]
stats_list = [{"key": "alpha", "label": "α", "value": res["alpha"]}]
if has_ci:
    stats_list.append({"key": "ci", "label": f"{pct} CI", "value": [res["ci_low"], res["ci_high"]]})
stats_list += [{"key": "do", "label": "Observed disagreement Do", "value": res["do"]}, {"key": "de", "label": "Expected disagreement De", "value": res["de"]}]
notes = [f"{level.capitalize()} α from the coincidence matrix (Krippendorff 2011); units with fewer than two ratings are left out."]
if has_ci:
    notes.append(f"Percentile bootstrap over {res['units']} units, {boot} resamples, seed {seed} (the same resamples in Python and R). "
                 f"P(α < .667) = {res['q'][0.667]:.3f}; P(α < .800) = {res['q'][0.8]:.3f}.")
cs.publish({
    "method": "agreement.krippendorff",
    "methodVersion": "1.0.1",
    "title": "Krippendorff's alpha",
    "engine": cs.engine_info("numpy", "codesplash"),
    "n": int(res["units"]),
    "summary": f"Krippendorff's α ({level}) = {res['alpha']:.3f}" + (f", {pct} CI [{res['ci_low']:.3f}, {res['ci_high']:.3f}]" if has_ci else "")
               + f" for {len(raters)} raters and {res['units']} units.",
    "apa": f"Krippendorff's α = {cs.fmt_num(res['alpha'], 2, leading_zero=False)}" + (f", {pct} CI [{cs.fmt_num(res['ci_low'])}, {cs.fmt_num(res['ci_high'])}]" if has_ci else ""),
    "statistics": stats_list,
    "tables": [{"key": "coincidences", "title": "Coincidence matrix (pairable values)", "columns": [
        {"key": "value", "label": "Value", "type": "string"},
        *[{"key": f"v{j}", "label": labels[j], "type": "number"} for j in range(len(vals))],
        {"key": "n", "label": "Total", "type": "number"},
    ], "rows": rows}],
    "effectSizes": [{"key": "alpha", "label": "Krippendorff's α", "value": res["alpha"],
                     "ciLow": res["ci_low"] if has_ci else None, "ciHigh": res["ci_high"] if has_ci else None,
                     "ciLevel": conf, "method": f"percentile bootstrap over units ({boot} resamples)" if has_ci else "no interval"}],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": notes,
    "charts": [cs.chart("coincidences", "matrix-heatmap", "Coincidences of values", {
        "row": cs.col("Value", [labels[i] for i in range(len(vals)) for _ in vals], "categorical", levels=labels),
        "col": cs.col("Paired with", [labels[j] for _ in vals for j in range(len(vals))], "categorical", levels=labels),
        "value": cs.col("Coincidences", flat_o, "numeric"),
        "label": cs.col("Count", [f"{v:.1f}" for v in flat_o], "categorical"),
    }, controls={"scale": "sequential"})],
    "values": values,
})
05

Same statistic, two dialects

Read
Python
import numpy as np
import pandas as pd
import krippendorff

df = pd.read_csv("s3_kripp.csv")
ratings = df[["rater_1", "rater_2", "rater_3", "rater 4"]]
print(krippendorff.alpha(reliability_data=ratings.to_numpy(dtype=float).T,
                         level_of_measurement="nominal"))
R
library(irr)
df <- read.csv("s3_kripp.csv", check.names = FALSE)
m <- t(as.matrix(df[, c("rater_1", "rater_2", "rater_3", "rater 4")]))
kripp.alpha(m, method = "nominal")
06

Check your understanding

Checkpoint

Check yourself

Six clinicians rate 40 patients on a 5-point ordered scale. A few ratings are missing. Which method fits best?

Show the answer

Answer: b

Fleiss' kappa treats categories as nominal and expects the same number of ratings per subject. Krippendorff's alpha handles both order and missing ratings. Gwet's AC2 is a good alternative.

Check yourself

A team reports α\alpha at the interval level for Likert ratings because it's higher than the ordinal value. What's the problem?

Show the answer

Answer: a

Choosing the level by result is a forking path. If the distances between points aren't equal, use ordinal.

Check yourself

α\alpha = 0.85, with 35% of bootstrap resamples below 0.8. What should you say?

Show the answer

Answer: b

The estimate and its uncertainty both matter. A small study can't support a confident claim, whatever the point estimate.

07

Recap

Recap
  • Fleiss' kappa: several raters, nominal categories, the same number of ratings per subject.
  • Krippendorff's alpha: any number of raters, missing ratings, any level of measurement.
  • Choose the level from the scale, and report the interval, not only the estimate.

Concepts in this lesson