Agreement between raters beyond chance: Cohen's kappa (unweighted, linear or quadratic) and Fleiss' kappa, version 1.1.1
stats-agreement-kappa@1.1.1: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.
What this page can and cannot show
Level: Checked against a reference; Formulas as given in SAS and Gwet 2021; SEs checked against the transcribed formulas only; no published kappa table. Reference kind: an outside program, Python fractions and mpmath, Python 3.13.18; mpmath 1.4.1; an outside program, statsmodels inter_rater; SciPy, statsmodels 0.15.0; scipy 1.18.1; a reference program this project wrote itself, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14, exact rationals for the agreements, kappa and both variances; square roots, the normal quantile and the p value in mpmath at 400 bits, each rounded once to a double; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14, exact rationals for the agreements, kappa and both variances; square roots, the normal quantile and the p value in mpmath at 80 digits, each rounded once to a double; not an outside program.
Checked by this project, not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with the stated reference within the stated tolerance. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed them.
Every version of this method · Every method · What the levels mean
Version 1.1.1
Level: Checked against a reference; Formulas as given in SAS and Gwet 2021; SEs checked against the transcribed formulas only; no published kappa table. Reference kind: an outside program, Python fractions and mpmath, Python 3.13.18; mpmath 1.4.1; an outside program, statsmodels inter_rater; SciPy, statsmodels 0.15.0; scipy 1.18.1; a reference program this project wrote itself, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14, exact rationals for the agreements, kappa and both variances; square roots, the normal quantile and the p value in mpmath at 400 bits, each rounded once to a double; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14, exact rationals for the agreements, kappa and both variances; square roots, the normal quantile and the p value in mpmath at 80 digits, each rounded once to a double; not an outside program. stats-agreement-kappa@1.1.1
Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.
Verification statement: Formulas as given in the SAS/STAT 14.1 PROC FREQ documentation, 'Tests and Measures of Agreement' (Cohen's and weighted kappa, their large-sample SE and the SE under kappa = 0), and in Gwet 2021, Eq. 2 (Fleiss' kappa), both read in full on 11 November 2026; checked by exact rational arithmetic, 50-digit mpmath and statsmodels 0.15.0 run as a black box. SEs, interval and z are checked against the transcribed formulas only: statsmodels' KappaResults page, which would list its SE fields, returned HTTP 503 on 11 November 2026 (Drybench's S1). The original papers are unread, and no published table with its printed kappa and SE has been reproduced. Intervals and p are large-sample (Wald) approximations. Fleiss' kappa is a point estimate only.
From a table of counts or one row of category labels per subject, Cohen's kappa for two raters (unweighted, or weighted linearly or quadratically over ordered, evenly spaced categories) with observed and chance agreement, its large-sample SE and Wald interval, and z and p against kappa = 0 from the SE under kappa = 0; or Fleiss' kappa for two or more raters as a point estimate only; the category proportions behind the chance agreement.
- How results are reported: none: full double precision
- Uncertainty: Cohen's kappa only: the large-sample (Wald) interval from the SE not assuming kappa = 0, and z from the SE under kappa = 0; Fleiss' kappa has no SE, interval or test in this version; its coverage is not checked
- Every reply through it says: Kappa depends on how common each category is and on each rater's totals: the same observed agreement can give very different kappas, and high observed agreement can give a low kappa. Weighted kappa depends on the weights chosen. No threshold or band is applied; how much agreement is enough is yours to set.
- Computes through this project's own routines: the Wald interval's z quantile; the z test's two-sided p
- Reference, as its record states it: exact rational arithmetic and mpmath at 50 digits on the transcribed formulas, and statsmodels 0.15.0 cohens_kappa and fleiss_kappa run as a black box
- Level confirmed by this project's ruling of 21 November 2026
What this page can and cannot show
What was checked
355 cases in 5 files, linked by this exact version.
Run through the tool at build against an outside program, Python fractions and mpmath, Python 3.13.18; mpmath 1.4.1; an outside program, statsmodels inter_rater; SciPy, statsmodels 0.15.0; scipy 1.18.1; a reference program this project wrote itself, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14, exact rationals for the agreements, kappa and both variances; square roots, the normal quantile and the p value in mpmath at 400 bits, each rounded once to a double; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14, exact rationals for the agreements, kappa and both variances; square roots, the normal quantile and the p value in mpmath at 80 digits, each rounded once to a double; not an outside program: 242 agree within the tolerance the file states, 113 refuse as the case expects, 0 differ, 0 were not run.
File 1, 55 cases
- Where the expected values came from: an outside program, Python fractions and mpmath Python 3.13.18; mpmath 1.4.1
- Recorded on: 2026-11-14
- Reference: Python fractions and mpmath, Python 3.13.18; mpmath 1.4.1; licence PSF-2.0; BSD-3-Clause
- Tolerance as the file states it: agreements, kappa and proportions absolute 1e-14 (Drybench ruling, 11 November 2026, K4); SEs, z and interval limits relative 1e-12; p relative 1e-10 (1e-300 absolute below 1e-290); counts, names, codes and statuses exact
File 2, 29 cases
- Where the expected values came from: an outside program, statsmodels inter_rater; SciPy statsmodels 0.15.0; scipy 1.18.1
- Recorded on: 2026-11-14
- Reference: statsmodels inter_rater; SciPy, statsmodels 0.15.0; scipy 1.18.1; licence BSD-3-Clause
- Tolerance as the file states it: kappa, SEs, z and limits relative 1e-12 against statsmodels (Drybench ruling, 11 November 2026, K4; near zero 1e-14 absolute below 1e-2); p relative 1e-10 (1e-300 absolute below 1e-290); agreements and proportions absolute 1e-14; counts, names, codes and statuses exact
File 3, 14 cases
- Where the expected values came from: an outside program, Python fractions and mpmath Python 3.13.18; mpmath 1.4.1
- Recorded on: 2026-11-14
- Reference: Python fractions and mpmath, Python 3.13.18; mpmath 1.4.1; licence PSF-2.0; BSD-3-Clause
- Tolerance as the file states it: agreements, kappa and proportions absolute 1e-14; SEs, z and limits relative 1e-12; p relative 1e-10 (1e-300 absolute below 1e-290); counts, names, codes and statuses exact
File 4, 227 cases
- Where the expected values came from: an outside program, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only) 2026-11-14
- Recorded on: 2026-11-14
- Reference: second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14; licence BSD-3-Clause
- Tolerance as the file states it: every number relative 1e-10 (absolute 1e-16 below 1e-6; p absolute 1e-307 below 1e-297); counts, statuses, codes and strings exact
File 5, 30 cases
- Where the expected values came from: an outside program, second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only) 2026-11-14
- Recorded on: 2026-11-14
- Reference: second implementation (Python 3.13; NumPy, SciPy distribution functions and mpmath only), 2026-11-14; licence BSD-3-Clause
- Tolerance as the file states it: every number relative 1e-10 (absolute 1e-16 below 1e-6; p absolute 1e-307 below 1e-297); counts, statuses, codes and strings exact
Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.
What was not checked
Cohen 1960, Cohen 1968, Fleiss, Cohen and Everitt 1969, Fleiss 1971, Fleiss, Nee and Landis 1979 and Fleiss, Levin and Paik 2003 are not read; no published table with its printed kappa and SE is reproduced. The Fleiss SE, interval and test are not offered (Drybench ruling, 11 November 2026, S4), nor Gwet's 2021 variance, per-category kappa, missing ratings, caller-supplied scores or weights, Krippendorff's alpha, ICC, weighted Fleiss, Light's kappa or PABAK. The 30-subject threshold is Drybench's judgement.
Definition or model
A closed form: the result follows from the inputs by the equations alone.
Equations
Equation 1
κ̂ = (P_o − P_e)/(1 − P_e), P_o = Σᵢ pᵢᵢ, P_e = Σᵢ pᵢ· p·ᵢ, pᵢⱼ = nᵢⱼ/n (as given in SAS/STAT documentation, which cites Cohen 1960, not read)
| Symbol | Meaning and unit |
|---|---|
| pᵢⱼ | proportion of subjects put in category i by the first rater and j by the second: nᵢⱼ/n, nᵢⱼ the count in row i and column j of `counts` (rows the first rater, columns the second, both in the order of `categories`) |
| pᵢ· | Σⱼ pᵢⱼ, the first rater's proportion in category i (the reply's proportionFirst) |
| p·ᵢ | Σⱼ pⱼᵢ, the second rater's proportion in category i (the reply's proportionSecond) |
| P_o | observed agreement (the reply's observedAgreement) |
| P_e | chance agreement (the reply's expectedAgreement) |
| n | subjects |
Source: SAS Institute Inc. SAS/STAT 14.1 User's Guide, The FREQ Procedure, Details: Tests and Measures of Agreement, section Simple Kappa Coefficient: the coefficient, SAS/STAT 14.1 (the 68162 documentation set); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a30c255e08a2. Free to read (free to read; © SAS Institute Inc., no licence grant (held for legal review)), checked 2026-11-11. No erratum found (searched the page and its procedure's reference list (statug_freq_references.htm)), 2026-11-11.
Equation 2
Var(κ̂) = (A + B − C)/((1 − P_e)² n), A = Σᵢ pᵢᵢ(1 − (pᵢ· + p·ᵢ)(1 − κ̂))², B = (1 − κ̂)² ΣΣ_{i≠j} pᵢⱼ(p·ᵢ + pⱼ·)², C = (κ̂ − P_e(1 − κ̂))²
standardError = √Var(κ̂)
interval κ̂ ± z₍₁₊ₗ₎/₂ √Var(κ̂), the reply's interval with method 'wald' and coverage l
with one rater constant (RATER_CONSTANT) Var(κ̂) is exactly 0 in every weighting, as Var₀(κ̂) is: an SE of 0 and an interval of 0 to 0 would describe no sampling uncertainty, which is false (the delta method breaking down at a boundary, not a measurement), so standardError and the interval are withheld with z and p, and nullStandardError is served as the exact 0 (as given in SAS/STAT documentation, which cites Fleiss, Cohen and Everitt 1969, not read)
| Symbol | Meaning and unit |
|---|---|
| κ̂ | Cohen's kappa |
| A, B, C | the three terms of the large-sample variance, as defined in the text |
| l | the caller's level (0.9, 0.95 or 0.99), the interval's coverage |
| z₍₁₊ₗ₎/₂ | the standard normal quantile Φ⁻¹((1 + l)/2) |
Source: SAS Institute Inc. SAS/STAT 14.1 User's Guide, The FREQ Procedure, Details: Tests and Measures of Agreement, section Simple Kappa Coefficient: the asymptotic variance and the confidence limits, SAS/STAT 14.1 (the 68162 documentation set); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a30c255e08a2. Free to read (free to read; © SAS Institute Inc., no licence grant (held for legal review)), checked 2026-11-11. No erratum found (searched the page and its procedure's reference list (statug_freq_references.htm)), 2026-11-11.
Equation 3
Var₀(κ̂) = (P_e + P_e² − Σᵢ pᵢ· p·ᵢ(pᵢ· + p·ᵢ))/((1 − P_e)² n)
z = κ̂/√Var₀(κ̂), the reply's nullStandardError being √Var₀(κ̂)
p = 2(1 − Φ(|z|)), Φ the standard normal distribution function (as given in SAS/STAT documentation, which cites Fleiss, Levin and Paik 2003, not read)
| Symbol | Meaning and unit |
|---|---|
| z | standardized test statistic against kappa = 0 |
| Φ | the standard normal distribution function |
Source: SAS Institute Inc. SAS/STAT 14.1 User's Guide, The FREQ Procedure, Details: Tests and Measures of Agreement, section Simple Kappa Coefficient: the test, the variance under the null hypothesis, SAS/STAT 14.1 (the 68162 documentation set); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a30c255e08a2. Free to read (free to read; © SAS Institute Inc., no licence grant (held for legal review)), checked 2026-11-11. No erratum found (searched the page and its procedure's reference list (statug_freq_references.htm)), 2026-11-11.
Equation 4
κ̂_w = (P_o(w) − P_e(w))/(1 − P_e(w)), P_o(w) = ΣΣ wᵢⱼ pᵢⱼ, P_e(w) = ΣΣ wᵢⱼ pᵢ· p·ⱼ
Var(κ̂_w) = (ΣΣ pᵢⱼ(wᵢⱼ − (w̄ᵢ· + w̄·ⱼ)(1 − κ̂_w))² − (κ̂_w − P_e(w)(1 − κ̂_w))²)/((1 − P_e(w))² n)
Var₀(κ̂_w) = (ΣΣ pᵢ· p·ⱼ(wᵢⱼ − (w̄ᵢ· + w̄·ⱼ))² − P_e(w)²)/((1 − P_e(w))² n), w̄ᵢ· = Σⱼ p·ⱼ wᵢⱼ, w̄·ⱼ = Σᵢ pᵢ· wᵢⱼ The reply's observedAgreement and expectedAgreement are then P_o(w) and P_e(w), and kappa, standardError, nullStandardError, z and p are those of κ̂_w (as given in SAS/STAT documentation)
| Symbol | Meaning and unit |
|---|---|
| wᵢⱼ | agreement weight of categories i and j, i and j indexing the categories in the order listed |
| w̄ᵢ·, w̄·ⱼ | the margin-weighted mean weights of row i and column j, as defined in the text |
Source: SAS Institute Inc. SAS/STAT 14.1 User's Guide, The FREQ Procedure, Details: Tests and Measures of Agreement, section Weighted Kappa Coefficient, SAS/STAT 14.1 (the 68162 documentation set); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a30c255e08a2. Free to read (free to read; © SAS Institute Inc., no licence grant (held for legal review)), checked 2026-11-11. No erratum found (searched the page and its procedure's reference list (statug_freq_references.htm)), 2026-11-11.
Equation 5
linear (Cicchetti–Allison weights, as given in SAS): wᵢⱼ = 1 − |i − j|/(k − 1)
quadratic (Fleiss–Cohen weights, as given in SAS): wᵢⱼ = 1 − (i − j)²/(k − 1)², the categories scored 1 to k (ordered, evenly spaced)
no caller-supplied scores or weights
| Symbol | Meaning and unit |
|---|---|
| k | categories |
Source: SAS Institute Inc. SAS/STAT 14.1 User's Guide, The FREQ Procedure, Details: Tests and Measures of Agreement, section Weights: Cicchetti–Allison and Fleiss–Cohen weights from the column scores, with the printed weights for scores 0, 2, 4 and 10, SAS/STAT 14.1 (the 68162 documentation set); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a30c255e08a2. Free to read (free to read; © SAS Institute Inc., no licence grant (held for legal review)), checked 2026-11-11. No erratum found (searched the page and its procedure's reference list (statug_freq_references.htm)), 2026-11-11.
Equation 6
π̂ₖ = (1/n) Σᵢ rᵢₖ/r
p_a = (1/n) Σᵢ Σₖ rᵢₖ(rᵢₖ − 1)/(r(r − 1))
p_e = Σₖ π̂ₖ²
κ̂ = (p_a − p_e)/(1 − p_e) (as given in Gwet 2021, which cites Fleiss 1971, not read)
a point estimate only
the reply's observedAgreement is p_a, expectedAgreement p_e and perCategory[].proportion π̂ₖ. Labels are tallied into rᵢₖ
for Cohen's kappa the first label of a row is the first rater (the table's row) and the second the second rater (its column)
| Symbol | Meaning and unit |
|---|---|
| rᵢₖ | raters putting subject i in category k |
| r | raters per subject |
| π̂ₖ | pooled proportion of ratings in category k |
| p_a, p_e | observed and chance agreement |
| n | subjects |
Source: Gwet KL. Large-Sample Variance of Fleiss Generalized Kappa. Educational and Psychological Measurement 2021;81(4):781–790, section Notation, eq. 1, and 'Fleiss' Kappa and Its Variance', eq. 2, PMC8243202 (published 15 February 2021); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 5263915c212e. Free to read (free to read on PMC; © The Author(s) 2020, no Creative Commons grant on the page (held for legal review)), checked 2026-11-11. No erratum found (searched the PMC article page and its notes), 2026-11-11.
Conventions
What each mode computes:
method = cohen: Two raters, every subject rated by both: chance agreement from each rater's own category totals.method = fleiss: The same number of raters on every subject, who need not be the same people: chance agreement from the pooled category proportions. With two raters, Fleiss' kappa is not Cohen's kappa. A point estimate only.weights = unweighted: Only exact agreement counts.weights = linear: Partial credit falling linearly with distance in the category order (Cicchetti–Allison weights, as given in SAS); the categories are declared ordered and evenly spaced.weights = quadratic: Partial credit falling with the squared distance in the category order (Fleiss–Cohen weights, as given in SAS); the categories are declared ordered and evenly spaced.
Constants
Constants: none used.
Worked example
Worked example: one case of stats-agreement-kappa@1.1.1, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- method = cohen
- input = counts
- counts[0][0] = 20
- counts[0][1] = 3
- counts[0][2] = 0
- counts[1][0] = 2
- counts[1][1] = 10
- counts[1][2] = 2
- counts[2][0] = 0
- counts[2][1] = 3
- counts[2][2] = 10
- categories[0] = benign
- categories[1] = atypical
- categories[2] = malignant
- weights = unweighted
- replicates = independent
- level = 0.95
Steps
- po = 0.8, from counts; by equation 1; gives observedAgreement.
- pe = 0.3544, from counts; by equation 1; gives expectedAgreement.
- kappa = 0.69021066, from po, pe; by equation 1; gives kappa.
- se = 0.086165651, from counts, kappa, pe; by equation 2; gives standardError.
- se0 = 0.10106907, from counts, pe; by equation 3; gives nullStandardError.
- z = 6.829099, from kappa, se0; by equation 3; gives z.
The working, as the case writes it:
Margins rows 23, 14, 13 and columns 22, 16, 12 of 50. P_o = 40/50 = 4/5
P_e = (23·22 + 14·16 + 13·12)/2500 = 886/2500 = 443/1250
κ = (4/5 − 443/1250)/(1 − 443/1250) = 557/807. The SEs and z from the SAS variance and null variance (worked by hand by Drybench on 11 November 2026 to five figures
this is not an independent check).
Answer
observedAgreement= 0.8expectedAgreement= 0.3544kappa= 0.69021066standardError= 0.086165651nullStandardError= 0.10106907z= 6.829099
Where these values came from: an outside program, Python fractions and mpmath Python 3.13.18; mpmath 1.4.1; stored reference values: exact rationals and mpmath at 50 digits.
At build the tool returned this answer within the tolerance the file states: agreements, kappa and proportions absolute 1e-14 (Drybench ruling, 11 November 2026, K4); SEs, z and interval limits relative 1e-12; p relative 1e-10 (1e-300 absolute below 1e-290); counts, names, codes and statuses exact.
Who worked this case: not recorded.
What it refuses, and its input ranges
UNKNOWN_CATEGORY(invalid input): a label that is not in categoriesRATERS_PER_SUBJECT_DIFFER(invalid input): subjects rated by different numbers of raters (labels rows of different lengths, or Fleiss counts rows with different sums)LENGTHS_DIFFER(invalid input): a counts row without one entry per category, or a Cohen table that is not k × kDUPLICATE_NAME(invalid input): a category listed twiceINVALID_STRING(invalid input): a category name with a non-printing character, U+0000 to U+001F, U+007F to U+009F, U+2028 or U+2029 (tab, line break and the other C0 and C1 controls, and the line and paragraph separators), looked for after leading and trailing white space (as JavaScript's trim) is removed from every name and label, so a leading or trailing tab or line break is removed, not refused; or a name or label empty once trimmed. A label is not looked at for these characters: one that matches no category is UNKNOWN_CATEGORYINVALID_OPTION(invalid input): Fleiss' kappa with weights other than 'unweighted'; method, input, weights or replicates outside its listed values (replicates 'biological', for one); a level inside 0 to 1 that is not 0.9, 0.95 or 0.99 (0.8, or 80 %)CONFLICTING_ARGUMENT(invalid input): level with Fleiss' kappa, or the form not sent being sentMISSING_ARGUMENT(invalid input): Cohen's kappa without level, the form named by input not sent, or method, input, categories, weights or replicates not sentOUT_OF_RANGE(invalid input): a Cohen table total outside 2 to 10000 subjects (a total of 0 or 1 is OUT_OF_RANGE, not TOO_FEW_VALUES: a Cohen table's subjects are its total), a Fleiss counts row summing outside 2 to 100 raters (a row above 100 is OUT_OF_RANGE; rows checked from the first, after the 6000-cell cap and ahead of RATERS_PER_SUBJECT_DIFFER), a negative count, or a level of 0 or 1 or beyondTOO_MANY_VALUES(invalid input): more than 5000 rows of labels, 3000 rows of Fleiss counts, 100 raters or 20 categories; labels over 10000 in all; Fleiss counts over 6000 cells; or more than two labels per subject for Cohen's kappa (checked row by row from the first, ahead of RATERS_PER_SUBJECT_DIFFER, so a Cohen row of three labels is TOO_MANY_VALUES)TOO_FEW_VALUES(invalid input): fewer than two subjects as rows (rows of labels, or rows of Fleiss counts; a Cohen table of 0 or 1 subjects in all is OUT_OF_RANGE), fewer than two labels per subject, or fewer than two categoriesTOO_LONG(invalid input): a category name or label over 60 characters, counted in UTF-16 code units once trimmed (a character beyond U+FFFF counts 2); or labels over 60000 bytes of text in all: every label in every row, once trimmed, counted as the UTF-8 bytes of its JSON string as JavaScript's JSON.stringify writes it, less the two quotes (a quote or backslash 2 bytes, a control character 2 or 6, other characters unescaped)
Changes
No correction is logged for stats-agreement-kappa@1.1.1.
Tools that use it
Cite this version
Agreement between raters beyond chance: Cohen's kappa (unweighted, linear or quadratic) and Fleiss' kappa. Drybench; stats-agreement-kappa@1.1.1; https://www.drybench.com/methods/m/stats-agreement-kappa/1.1.1 (accessed [date]).