GAgreement · Guide test 307
Cohen kappa significance test
Tests a specified chance corrected agreement level for two categorical raters using estimated sampling uncertainty.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- Fleiss' kappa (several raters) — Do several raters assign the same categories more often than chance?
- Cohen's kappa (two raters) — Do two raters assign the same categories more often than chance?
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Cohen kappa significance test
Alternative
Your data
Edit the counts| Rater 2: low | mid | high | Total | |
|---|---|---|---|---|
| Rater 1: low | 24E = 11.8 | 9E = 17.2 | 8E = 12.0 | 41 |
| Rater 1: mid | 13E = 17.2 | 35E = 25.2 | 12E = 17.6 | 60 |
| Rater 1: high | 6E = 14.0 | 19E = 20.6 | 24E = 14.4 | 49 |
| Total | 43 | 63 | 44 | 150 |
E is the count expected if rows and columns were unrelated.
If H₀ were true
- The reference: how z varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = < .001).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- observed agreement
- agreement expected from the margins
- standard error when κ = 0
The verdict
z = 5.54, p < .001, κ = 0.32
p ≤ α = .050: reject H₀
Effect size: Cohen's kappa κ = 0.321
Significance only shows agreement beats chance — almost always true. Report κ with its interval and remember it depends on prevalence.
- Statistic
- 5.536
- p-value
- 0.0000
Cohen kappa significance test on a 3 × 3 table of 150 counts: z = 5.54, p < .001, κ = 0.32. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: population agreement coefficient κ=κ0, commonly κ0=0.
Assumptions
Independent rated subjects; a defined rater/category design and appropriate multinomial/cluster covariance. Weighted and multi-rater kappas require their own formulas.
Formula
Parameters and notation
For two raters, p is the cell-probability vector. Delta variance is ∇κᵀ[diag(p)−ppᵀ]∇κ/n, evaluated under the appropriate null or estimate; weighted κ replaces agreement scores.
Structure of the method
Construct the two-rater contingency table, estimate observed and marginal-chance agreement, calculate kappa and derive a null-appropriate sampling variance. A normal-score test for κ=0 is distinct from estimating a confidence interval or testing a clinically meaningful reliability threshold.
Estimated and nuisance parameters
Estimated parameters are cell probabilities, rater margins and kappa; the variance follows the chosen multinomial/cluster model. For weighted kappa, the agreement-weight matrix is a prespecified measurement choice. Subjects, not individual rater cells, are the independent sampling units in the standard design.
Settings and design choices
Choose unweighted versus an explicitly justified ordinal weight system, category ordering, null kappa and missing-rating policy. The irr implementation performs listwise omission. Do not interpret integer-coded categories as ordered unless that matches their meaning; changing category collapse or weights changes the estimand.
Fitting and adaptation
Estimate agreement and its interval using a model appropriate to the rater/subject design. For clustered ratings, use a compatible cluster variance or subject-level resampling. There is no neural tuning; selecting weights or category merges to maximize kappa requires independent justification and transparent reporting.
Sensitivity and robustness
Prevalence, marginal imbalance and rare categories can cause surprising kappa behavior even with high observed agreement. Asymptotic tests may be fragile with sparse tables. Report the full table and raw agreement alongside kappa; rejecting zero agreement does not establish that the reliability is sufficient for the intended use.
How to use and calibrate
Use a valid asymptotic normal test or a subject-level bootstrap; report κ and its confidence interval.
Example application
Assess agreement beyond marginal chance for two categorical raters.
Interpretation and pitfalls
Watch out
Testing κ=0 rarely establishes useful agreement. Prevalence and marginal imbalance strongly affect κ.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Two raters, same subjects and category levels. Unweighted Cohen kappa with significance test of kappa=0; report a confidence interval and category prevalences as well.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: irr
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
a<-factor(sample(1:3,80,TRUE),levels=1:3);b<-a;b[1:15]<-factor(sample(1:3,15,TRUE),levels=1:3);print(irr::kappa2(data.frame(a,b),weight="unweighted"))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Not run — Syntax checked; runtime not verified in the final environment · needs irr
set.seed(2026)
a<-factor(sample(1:3,80,TRUE),levels=1:3);b<-a;b[1:15]<-factor(sample(1:3,15,TRUE),levels=1:3);print(irr::kappa2(data.frame(a,b),weight="unweighted"))
Sources
- irr — irr · kappa2Author documentation/source reviewed: irr 0.85.search.r-project.org
- irr — irr · kappam.fleissAuthor documentation/source reviewed: irr 0.85.search.r-project.org
- kappa2search.r-project.org
- kappam.fleisssearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 307, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT307.