Weighted Kappa: Formula, Interpretation, Example, Python, R, SPSS, SAS and Excel Guide
Weighted Kappa measures agreement between two ordinal classifications while giving small disagreements less penalty than large disagreements. This worked analysis compares four-level G1 and G3 grade bands for 649 students, reconstructs every linear and quadratic weighting calculation, separates exact agreement from chance agreement, explains the direction of category movement, and provides verified Python, R, SPSS and Excel outputs.
Weighted Kappa Model Overview
Weighted Kappa, often called weighted Cohen’s kappa, evaluates agreement between two ratings measured on the same ordered scale. It improves on ordinary Cohen’s kappa by recognising that a one-category disagreement is less serious than a two- or three-category disagreement. The present analysis compares G1 and G3 grade classifications using four ordered bands: low, medium, high and very high.
The complete 4 × 4 table contains 649 paired classifications. The diagonal contains 463 exact matches. Of the 186 disagreements, 185 are only one category apart, 1 is two categories apart and 0 are three categories apart. That concentration near the diagonal is the central reason quadratic weighted kappa (0.765160) is higher than linear weighted kappa (0.647398).
Exact Research Question
How strongly do G1 and G3 ordinal grade bands agree beyond the agreement expected from their different marginal distributions, and how does the result change when disagreements are penalised linearly rather than quadratically?
| Result component | Verified value | Interpretive role |
|---|---|---|
| Unweighted κ | 0.544050 | Treats every mismatch equally. |
| Linear weighted κ | 0.647398 | Penalty increases in direct proportion to category distance. |
| Quadratic weighted κ | 0.765160 | Penalty increases with squared category distance; primary result. |
| Exact agreement | 463/649 (71.34%) | Raw diagonal agreement before chance correction. |
| Within one category | 648/649 (99.85%) | Shows how rarely the ratings are far apart. |
Quick Answer: Weighted Kappa Result
The primary quadratic weighted kappa is 0.765160. Under quadratic disagreement weights, observed disagreement is 0.032357, compared with 0.137785 expected from the row and column margins. The calculation therefore removes 76.52% of the weighted disagreement expected by chance.
Statistical Result
- Observed quadratic disagreement: 0.032357
- Expected quadratic disagreement: 0.137785
- Quadratic weighted κ: 0.765160
- Supplementary bootstrap 95% CI: 0.7289 to 0.7974
- Exact agreement: 71.34%
Data Meaning
- 185 disagreements are adjacent.
- Only 1 disagreement spans two bands.
- No pair spans all three possible category steps.
- 153 pairs move to a higher G3 band; 33 move lower.
- Among disagreements, 82.26% move upward.
Table of Contents
- What weighted kappa measures
- Research question and hypotheses
- When to use weighted kappa
- Linear, quadratic and custom weights
- Variables and ordinal coding
- Formula and manual calculation
- Observed, expected and residual tables
- Complete weighted kappa results
- Assumptions and diagnostic checks
- Comparison with related methods
- Calculator workflow
- Python chart interpretations
- Paired R chart interpretations
- Python, R, SPSS, SAS and Excel
- Expandable code
- APA interpretation and reporting
- Common mistakes
- Practice questions
- Reports and worked files
- Related guides
- Frequently asked questions
- Conclusion
What Is Weighted Kappa?
Weighted Kappa is a chance-corrected agreement coefficient for two ratings recorded on the same ordinal scale. It starts with a cross-classification table, assigns each cell a disagreement weight, and compares the observed weighted disagreement with the disagreement expected if the two marginal distributions were independent.
Ordinary kappa treats low-versus-medium and low-versus-very-high disagreements as equally wrong. Weighted kappa does not. In this four-band example, a low-to-medium disagreement receives a linear penalty of 1/3 or a quadratic penalty of 1/9, whereas low-to-very-high receives the maximum penalty of 1 under both systems.
| Quantity | Meaning | Worked value |
|---|---|---|
| Observed exact agreement | Proportion on the diagonal | 463/649 = 0.713405 |
| Chance exact agreement | Diagonal agreement implied by margins | 0.371433 |
| Unweighted kappa | Chance-corrected exact agreement | 0.544050 |
| Linear weighted kappa | Chance-corrected agreement with proportional penalties | 0.647398 |
| Quadratic weighted kappa | Chance-corrected agreement with squared penalties | 0.765160 |
Why Weighted Kappa Is Not a Reliability Percentage
The value 0.7652 is not “76.52% of ratings are correct.” It means the observed quadratic disagreement is 76.52% lower than the disagreement expected from the marginal distributions. Raw exact agreement is 71.34%, while the weighted agreement score is 96.76%. These quantities answer different questions and should be reported separately.
Why Marginal Distributions Matter
G1 has 157 low, 340 medium, 128 high and 24 very-high classifications. G3 has 100, 355, 148 and 46, respectively. Because the G3 distribution is shifted upward, raw agreement alone would not fully describe the agreement process. Weighted kappa retains the paired table and corrects for the agreement expected from these margins.
Research Question, Hypotheses and Data Design
Research Question
Do G1 and G3 place students in the same or nearby ordinal grade bands more often than expected from their separate grade-band distributions?
| Component | Formal statement | Meaning in this analysis |
|---|---|---|
| Null hypothesis | κw = 0 | Observed weighted disagreement equals chance-weighted disagreement. |
| Alternative hypothesis | κw > 0 | Observed weighted disagreement is smaller than chance expectation. |
| Primary weighting | Quadratic | Distant disagreements receive disproportionately larger penalties. |
| Secondary weighting | Linear | Each additional category step adds the same penalty. |
| Direction analysis | G3 − G1 | Positive cells above the diagonal indicate movement to a higher final-grade band. |
Prespecified Analysis Decisions
The grade cut points, category order, pairing rule and weighting scheme should be selected before inspecting the kappa result. Quadratic weights are primary here because a two-band classification error is intended to count four times as much as a one-band error, while a three-band error receives the maximum penalty.
When to Use Weighted Kappa
Use Weighted Kappa When
- The same cases receive two ratings or classifications.
- Both ratings use the same ordered categories.
- Near disagreements are less serious than distant disagreements.
- The goal is agreement beyond chance, not merely correlation.
- Each case contributes one independent pair.
- The category order and weights are defensible before analysis.
- The complete cross-classification table can be inspected.
Choose Another Method When
- Categories are nominal with no defensible order.
- More than two raters classify the same cases.
- The ratings are continuous and measurement error is the focus.
- Repeated ratings create clustering or longitudinal dependence.
- Different raters use different category systems.
- Prevalence, bias or marginal homogeneity is the main question.
- The purpose is prediction rather than agreement.
Decision Flow
If no, agreement kappa is not appropriate.
If no, use ordinary nominal kappa.
Select linear, quadratic or justified custom weights.
For two nominal ratings, use the ordinary kappa statistic. For more than two raters, consider Fleiss’ kappa. For paired binary change rather than agreement, use McNemar’s test; for paired multicategory marginal change, use the McNemar–Bowker test.
Linear, Quadratic and Custom Weighted Kappa
The numerical value of weighted kappa depends on the weight matrix. Weighting is part of the estimand, not a decorative software option.
Linear Disagreement Weights
| G1 \ G3 | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) |
|---|---|---|---|---|
| Low (<10) | 0.000000 | 0.333333 | 0.666667 | 1.000000 |
| Medium (10–13) | 0.333333 | 0.000000 | 0.333333 | 0.666667 |
| High (14–16) | 0.666667 | 0.333333 | 0.000000 | 0.333333 |
| Very high (17+) | 1.000000 | 0.666667 | 0.333333 | 0.000000 |
Quadratic Disagreement Weights
| G1 \ G3 | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) |
|---|---|---|---|---|
| Low (<10) | 0.000000 | 0.111111 | 0.444444 | 1.000000 |
| Medium (10–13) | 0.111111 | 0.000000 | 0.111111 | 0.444444 |
| High (14–16) | 0.444444 | 0.111111 | 0.000000 | 0.111111 |
| Very high (17+) | 1.000000 | 0.444444 | 0.111111 | 0.000000 |
| Scheme | One-step penalty | Two-step penalty | Three-step penalty | Worked κ |
|---|---|---|---|---|
| Unweighted | 1 | 1 | 1 | 0.544050 |
| Linear | 0.333333 | 0.666667 | 1.000000 | 0.647398 |
| Quadratic | 0.111111 | 0.444444 | 1.000000 | 0.765160 |
Why Quadratic Kappa Is Higher Here
There are 185 adjacent disagreements, only 1 two-step disagreement and no three-step disagreement. Quadratic weights sharply discount adjacent errors: a one-step error contributes only 1/9 of a maximum error instead of 1/3. Because almost all mismatches are adjacent, quadratic observed disagreement falls to 0.032357, compared with linear observed disagreement of 0.096045.
Variables, Ordinal Coding and Data Dictionary
| Variable | Role | Coding | Valid N | Interpretation |
|---|---|---|---|---|
| G1 | First ordinal classification | 1 = low; 2 = medium; 3 = high; 4 = very high | 649 | Earlier grade-band classification. |
| G3 | Second ordinal classification | Same four cut points | 649 | Final grade-band classification. |
| Distance |G3−G1| | Disagreement severity | 0, 1, 2 or 3 | 649 | Number of category steps separating the pair. |
| Linear weight | Disagreement penalty | distance / 3 | 649 | Equal penalty added per category step. |
| Quadratic weight | Disagreement penalty | distance² / 9 | 649 | Large errors penalised disproportionately. |
Marginal Grade-Band Distributions
| Band | G1 count | G1 % | G3 count | G3 % | G3 − G1 count |
|---|---|---|---|---|---|
| Low (<10) | 157 | 24.19% | 100 | 15.41% | -57 |
| Medium (10–13) | 340 | 52.39% | 355 | 54.70% | +15 |
| High (14–16) | 128 | 19.72% | 148 | 22.80% | +20 |
| Very high (17+) | 24 | 3.70% | 46 | 7.09% | +22 |
Scale-Score Summary
| Descriptive quantity | Value | Interpretation |
|---|---|---|
| Mean G1 category score | 2.029276 | Average location on the 1–4 ordinal coding. |
| Mean G3 category score | 2.215716 | G3 classifications are somewhat higher overall. |
| Mean category shift | +0.186441 | Average G3 band exceeds G1 by 0.186 category steps. |
| Mean absolute category distance | 0.288136 | Average pair is 0.288 bands apart. |
| Root mean squared distance | 0.539645 | Gives more weight to the rare larger discrepancy. |
Category Retention and Movement from Each G1 Band
| G1 band | Row N | Exact N | Exact % | Moved lower N | Moved lower % | Moved higher N | Moved higher % |
|---|---|---|---|---|---|---|---|
| Low (<10) | 157 | 88 | 56.05% | 0 | 0.00% | 69 | 43.95% |
| Medium (10–13) | 340 | 267 | 78.53% | 12 | 3.53% | 61 | 17.94% |
| High (14–16) | 128 | 86 | 67.19% | 19 | 14.84% | 23 | 17.97% |
| Very high (17+) | 24 | 22 | 91.67% | 2 | 8.33% | 0 | 0.00% |
The very-high band has the highest exact retention at 91.67%, although it contains only 24 cases. The low band has the lowest exact retention at 56.05%; all 69 low-band mismatches move one step upward to medium. Medium is the largest row and retains 267 of 340 students, while 61 move upward and 12 move downward.
Where Each G3 Band Came From
| G3 band | From Low (<10) | From Medium (10–13) | From High (14–16) | From Very high (17+) | Column total |
|---|---|---|---|---|---|
| Low (<10) | 88.00% | 12.00% | 0.00% | 0.00% | 100.00% |
| Medium (10–13) | 19.44% | 75.21% | 5.35% | 0.00% | 100.00% |
| High (14–16) | 0.00% | 40.54% | 58.11% | 1.35% | 100.00% |
| Very high (17+) | 0.00% | 2.17% | 50.00% | 47.83% | 100.00% |
Column percentages reveal a different perspective from row retention. Of the 100 students classified low at G3, 88.00% were already low at G1 and 12.00% came from medium. Among the 46 very-high G3 classifications, 47.83% were already very high, 50.00% moved up from high, and 2.17% moved two bands from medium.
Weighted Kappa Formula and Manual Calculation
This article uses disagreement weights. With cell proportion pij, row marginal pi+, column marginal p+j and disagreement weight wij, weighted kappa is:
| Symbol | Definition |
|---|---|
| pij | Observed proportion in row i and column j. |
| pi+ | Marginal proportion for G1 category i. |
| p+j | Marginal proportion for G3 category j. |
| wij | Disagreement penalty for cell i,j. |
| Do | Observed weighted disagreement Σwijpij. |
| De | Expected weighted disagreement Σwijpi+p+j. |
Linear Calculation
Quadratic Calculation
| Method | Observed weighted agreement | Expected weighted agreement | Chance-corrected κ |
|---|---|---|---|
| Exact / unweighted | 71.34% | 37.14% | 0.544050 |
| Linear | 90.40% | 72.76% | 0.647398 |
| Quadratic | 96.76% | 86.22% | 0.765160 |
Manual Check from Disagreement Distances
For the linear system, the 185 one-step disagreements contribute 185 × (1/3) weighted count units and the one two-step disagreement contributes 1 × (2/3). Dividing by 649 gives Do,L = 0.096045. For quadratic weights, the same cells contribute 185 × (1/9) plus 1 × (4/9), producing Do,Q = 0.032357.
Cell-by-Cell Disagreement Contributions
| Observed transition | Count | Distance | Linear weight | Linear contribution | Quadratic weight | Quadratic contribution | Share of quadratic Do |
|---|---|---|---|---|---|---|---|
| Low (<10) → Medium (10–13) | 69 | 1 | 0.333333 | 0.035439 | 0.111111 | 0.011813 | 36.51% |
| Medium (10–13) → Low (<10) | 12 | 1 | 0.333333 | 0.006163 | 0.111111 | 0.002054 | 6.35% |
| Medium (10–13) → High (14–16) | 60 | 1 | 0.333333 | 0.030817 | 0.111111 | 0.010272 | 31.75% |
| Medium (10–13) → Very high (17+) | 1 | 2 | 0.666667 | 0.001027 | 0.444444 | 0.000685 | 2.12% |
| High (14–16) → Medium (10–13) | 19 | 1 | 0.333333 | 0.009759 | 0.111111 | 0.003253 | 10.05% |
| High (14–16) → Very high (17+) | 23 | 1 | 0.333333 | 0.011813 | 0.111111 | 0.003938 | 12.17% |
| Very high (17+) → High (14–16) | 2 | 1 | 0.333333 | 0.001027 | 0.111111 | 0.000342 | 1.06% |
The contribution table separates frequency from severity. Low→medium is the largest quadratic contribution because it occurs 69 times. Medium→very-high spans two categories and receives a four-times-larger quadratic weight than an adjacent error, but it occurs once and therefore contributes only 0.000685. This is why a weighted analysis must multiply cell frequency by the selected penalty rather than ranking errors by distance alone.
Expected Disagreement Is Built from the Margins
Expected cell probability is pi+p+j. For example, the expected low-G1/medium-G3 probability is (157/649) × (355/649) = 0.132324. Under quadratic weights, multiplying that probability by 1/9 contributes 0.014703 to expected disagreement. Repeating this for all 16 cells gives De,Q = 0.137785100753.
Chance correction therefore does not assume equal category frequencies. It uses the actual G1 and G3 margins. This matters because medium dominates both distributions and G3 is shifted toward higher categories.
Observed Agreement, Expected Counts and Diagnostic Tables
Observed G1-by-G3 Agreement Matrix
| G1 \ G3 | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) | Row total |
|---|---|---|---|---|---|
| Low (<10) | 88 | 69 | 0 | 0 | 157 |
| Medium (10–13) | 12 | 267 | 60 | 1 | 340 |
| High (14–16) | 0 | 19 | 86 | 23 | 128 |
| Very high (17+) | 0 | 0 | 2 | 22 | 24 |
| Column total | 100 | 355 | 148 | 46 | 649 |
The diagonal holds 463 exact matches. Blue cells above the diagonal represent movement to a higher G3 band; amber cells below the diagonal represent movement to a lower G3 band.
Row Percentages
| G1 band | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) | Row total |
|---|---|---|---|---|---|
| Low (<10) | 56.05% | 43.95% | 0.00% | 0.00% | 100.00% |
| Medium (10–13) | 3.53% | 78.53% | 17.65% | 0.29% | 100.00% |
| High (14–16) | 0.00% | 14.84% | 67.19% | 17.97% | 100.00% |
| Very high (17+) | 0.00% | 0.00% | 8.33% | 91.67% | 100.00% |
Exact retention is 56.05% for low, 78.53% for medium, 67.19% for high and 91.67% for very-high G1 classifications.
Expected Counts Under Independent Margins
| G1 \ G3 | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) | Row total |
|---|---|---|---|---|---|
| Low (<10) | 24.191 | 85.878 | 35.803 | 11.128 | 157 |
| Medium (10–13) | 52.388 | 185.978 | 77.535 | 24.099 | 340 |
| High (14–16) | 19.723 | 70.015 | 29.190 | 9.072 | 128 |
| Very high (17+) | 3.698 | 13.128 | 5.473 | 1.701 | 24 |
Expected diagonal counts total 241.060, corresponding to 37.14% chance exact agreement. Observed diagonal agreement is 463, substantially above that expectation.
Pearson Residuals for the Unweighted Table
| G1 \ G3 | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) |
|---|---|---|---|---|
| Low (<10) | +12.973 | -1.821 | -5.984 | -3.336 |
| Medium (10–13) | -5.580 | +5.941 | -1.991 | -4.705 |
| High (14–16) | -4.441 | -6.097 | +10.515 | +4.624 |
| Very high (17+) | -1.923 | -3.623 | -1.485 | +15.564 |
Large positive diagonal residuals show that exact matches occur far more often than expected under independence. Negative residuals in distant off-diagonal cells show that severe disagreements are rarer than expected.
Disagreement Distance Distribution
| Category distance | Count | Percent of all pairs | Percent of disagreements | Interpretation |
|---|---|---|---|---|
| 0 — exact match | 463 | 71.34% | — | Same grade band. |
| 1 — adjacent mismatch | 185 | 28.51% | 99.46% | One band apart. |
| 2 — two-band mismatch | 1 | 0.15% | 0.54% | Only one observed pair. |
| 3 — maximum mismatch | 0 | 0.00% | 0.00% | No observed pair. |
Quadratic Observed Disagreement Contributions
| G1 \ G3 | Low (<10) | Medium (10–13) | High (14–16) | Very high (17+) |
|---|---|---|---|---|
| Low (<10) | 0.000000 | 0.011813 | 0.000000 | 0.000000 |
| Medium (10–13) | 0.002054 | 0.000000 | 0.010272 | 0.000685 |
| High (14–16) | 0.000000 | 0.003253 | 0.000000 | 0.003938 |
| Very high (17+) | 0.000000 | 0.000000 | 0.000342 | 0.000000 |
Observed Versus Expected Exact Agreement by Band
| Band | Observed diagonal | Expected diagonal | Observed − expected | Observed/expected ratio | Diagonal residual |
|---|---|---|---|---|---|
| Low (<10) | 88 | 24.191 | +63.809 | 3.638× | +12.973 |
| Medium (10–13) | 267 | 185.978 | +81.022 | 1.436× | +5.941 |
| High (14–16) | 86 | 29.190 | +56.810 | 2.946× | +10.515 |
| Very high (17+) | 22 | 1.701 | +20.299 | 12.933× | +15.564 |
Every diagonal cell exceeds its chance expectation. The strongest proportional concentration is in the very-high cell: 22 observed versus 1.701 expected. The low cell has 88 observed versus 24.191 expected. These large diagonal excesses are why both unweighted and weighted kappa are well above zero.
Marginal Shift from G1 to G3
| Band | G1 count | G3 count | Count change | G1 share | G3 share | Share change |
|---|---|---|---|---|---|---|
| Low (<10) | 157 | 100 | -57 | 24.19% | 15.41% | -8.78 pp |
| Medium (10–13) | 340 | 355 | +15 | 52.39% | 54.70% | +2.31 pp |
| High (14–16) | 128 | 148 | +20 | 19.72% | 22.80% | +3.08 pp |
| Very high (17+) | 24 | 46 | +22 | 3.70% | 7.09% | +3.39 pp |
The margins show a redistribution rather than identical prevalence. Low declines by 57 cases, while high rises by 20 and very high rises by 22. Medium rises by 15. Weighted kappa remains high because most individual transitions are exact or adjacent, but the margin table demonstrates that agreement does not imply an unchanged grade distribution.
Complete Weighted Kappa Results
463 diagonal pairs
All mismatches equal
Proportional distance penalty
Squared distance penalty
648 of 649
153 upward versus 33 downward
Primary Weighted Kappa Results
| Measure | Estimate | Observed disagreement | Expected disagreement | Supplementary bootstrap 95% CI |
|---|---|---|---|---|
| Linear weighted kappa | 0.647398407 | 0.096045198 | 0.272390142 | 0.6007 to 0.6909 |
| Quadratic weighted kappa | 0.765159855 | 0.032357473 | 0.137785101 | 0.7289 to 0.7974 |
Agreement Decomposition
| Component | Count | Percent of all pairs | Analytical meaning |
|---|---|---|---|
| Exact match | 463 | 71.34% | Raw agreement before chance correction. |
| Adjacent disagreement | 185 | 28.51% | Minor one-band difference. |
| Two-band disagreement | 1 | 0.15% | Rare moderate discrepancy. |
| Three-band disagreement | 0 | 0.00% | No maximum discrepancy. |
| G3 higher than G1 | 153 | 23.57% | Upward classification movement. |
| G3 lower than G1 | 33 | 5.08% | Downward classification movement. |
Bootstrap Precision Check
| Estimate | Bootstrap SE | 2.5th percentile | 97.5th percentile | Resamples |
|---|---|---|---|---|
| Linear κ | 0.02290 | 0.60073 | 0.69087 | 20,000 |
| Quadratic κ | 0.01754 | 0.72894 | 0.79744 | 20,000 |
The bootstrap is a supplementary reproducibility check generated directly from the verified 4 × 4 empirical table with a fixed seed. It is not presented as an output from the linked software reports. Both intervals remain well above zero and preserve the ordering quadratic κ > linear κ.
Directional Transition Detail
| Transition | Count | Percent of all pairs | Share of disagreements |
|---|---|---|---|
| Low → Medium | 69 | 10.63% | 37.10% |
| Medium → High | 60 | 9.24% | 32.26% |
| Medium → Very high | 1 | 0.15% | 0.54% |
| High → Very high | 23 | 3.54% | 12.37% |
| Medium → Low | 12 | 1.85% | 6.45% |
| High → Medium | 19 | 2.93% | 10.22% |
| Very high → High | 2 | 0.31% | 1.08% |
Where the Quadratic Disagreement Comes From
| Source group | Quadratic contribution | Percent of observed quadratic disagreement | Interpretation |
|---|---|---|---|
| Upward adjacent transitions | 0.026023 | 80.42% | Low→medium, medium→high and high→very high. |
| Downward adjacent transitions | 0.005650 | 17.46% | Medium→low, high→medium and very high→high. |
| Two-step upward transition | 0.000685 | 2.12% | One medium→very-high pair. |
| Three-step transitions | 0.000000 | 0.00% | No low↔very-high pair. |
Upward adjacent transitions account for 80.42% of observed quadratic disagreement, while downward adjacent transitions account for 17.46%. The coefficient is therefore not only high; its remaining disagreement is directionally concentrated.
Three Complementary Conclusions from the Same Table
| Question | Statistic or evidence | Conclusion |
|---|---|---|
| How often are classifications identical? | 463/649 = 71.34% | Most pairs match exactly. |
| How close are classifications beyond chance? | Quadratic κ = 0.765160 | Strong distance-sensitive agreement. |
| Did the distribution shift over time? | 153 upward vs 33 downward transitions; mean shift +0.186 | G3 is systematically higher despite strong agreement. |
These conclusions are not contradictory. A student can remain close to the earlier band while still being more likely to move upward than downward. Reporting only weighted kappa would omit the third conclusion; reporting only the margins would omit the strong case-level pairing.
Weighted Kappa Assumptions and Diagnostic Checks
Weighted kappa requires a defensible paired ordinal design. The coefficient can be computed mechanically even when the design is inappropriate, so each condition should be checked explicitly.
Each of the 649 students contributes one G1 and one G3 classification.
Both variables use identical low, medium, high and very-high cut points.
One student’s pair should not determine another student’s pair.
Quadratic weighting is chosen for substantive reasons, not because it gives a larger κ.
All 16 cells and both margins are inspected, not only the final coefficient.
The very-high G1 band has only 24 cases, so category-specific percentages need context.
| Diagnostic | Observed evidence | Assessment |
|---|---|---|
| Missing paired values | 649 valid, 0 missing in SPSS case summary | Satisfied for the analysed table. |
| Scale alignment | Identical four grade bands for G1 and G3 | Satisfied. |
| Distant disagreement support | 1 two-step and 0 three-step errors | Quadratic result is driven by adjacent-error discounting. |
| Marginal equality | G1 and G3 margins differ | Not required for kappa, but direction should be reported. |
| Sparse cells | Several distant cells are zero | Substantively informative; bootstrap precision is useful. |
| Rater independence | G1 and G3 are repeated classifications, not independent raters | Interpret as temporal/measurement agreement, not inter-rater reliability. |
Prevalence and Marginal Effects
Kappa can change when category prevalence or rater margins change, even with similar raw agreement. Here medium classifications dominate both margins, while G3 contains fewer low and more high/very-high classifications. Reporting the full margins, exact agreement and direction counts protects against overinterpreting one coefficient.
Sparse-Cell Interpretation
Seven of the 16 cells are zero. In this dataset, zero distant-error cells are substantively favourable because they indicate no low-to-high, low-to-very-high, high-to-low, very-high-to-low or very-high-to-medium movements. They also mean that uncertainty for rare error types cannot be learned directly from many observed cases. The supplementary bootstrap interval therefore resamples the full empirical table rather than applying a normal approximation to individual sparse cells.
Independence and Temporal Pairing
The pair is formed within student, so G1 and G3 are intentionally dependent. The independence assumption applies across students: one student’s grade-band pair should not be duplicated or nested in a way that makes pairs correlated. If students are clustered in classrooms or schools and inference must generalise beyond the observed sample, a multilevel ordinal model may be needed in addition to descriptive weighted kappa.
Weighted Kappa Versus Related Agreement and Change Methods
| Method | Data structure | Uses order? | Chance correction? | What it answers |
|---|---|---|---|---|
| Weighted kappa | Two paired ordinal ratings | Yes | Yes | How strongly do ratings agree when distance matters? |
| Ordinary Cohen’s kappa | Two paired nominal ratings | No | Yes | How strongly do exact categories agree beyond chance? |
| Fleiss’ kappa | Multiple raters, nominal categories | No | Yes | How strongly do more than two raters agree? |
| McNemar’s test | Paired binary outcomes | No | No | Do paired marginal proportions differ? |
| McNemar–Bowker test | Paired multicategory outcomes | Optional | No | Is the square table marginally symmetric? |
| Spearman correlation | Two ordered/continuous variables | Yes | No | Is there monotonic association? |
| Intraclass correlation | Continuous ratings | Continuous | Model-based | How reliable are continuous measurements? |
Weighted Kappa Versus Ordinary Kappa
Ordinary κ is 0.5441; linear weighted κ is 0.6474; quadratic weighted κ is 0.7652. The increase is not evidence that ordinary kappa is wrong. It reflects a different loss function: ordinary kappa treats all 186 disagreements equally, while weighted kappa recognises that 185 of them are only one category apart.
Weighted Kappa Versus Marginal-Homogeneity Tests
Agreement and change are distinct. The 153 upward and 33 downward transitions suggest that G3 tends to be higher than G1. A McNemar–Bowker test would test symmetry of the paired square table, while weighted kappa quantifies closeness. A complete study can report both when both questions matter.
Weighted Kappa Versus Correlation
Correlation is unaffected by certain systematic shifts and does not require identical values. Weighted kappa rewards equality and near equality on a common scale. Use Spearman rank correlation for monotonic ordering and weighted kappa for category agreement.
What Different Analyses Would Say About This Exact Matrix
| Analysis applied to the same table | Key worked quantity | Information retained | Information lost |
|---|---|---|---|
| Exact agreement | 71.34% | Diagonal match rate | Chance expectation and disagreement distance. |
| Ordinary kappa | 0.544050 | Chance-corrected exact agreement | Difference between near and far errors. |
| Linear weighted kappa | 0.647398 | Ordered distance with proportional loss | Nonlinear severity preferences. |
| Quadratic weighted kappa | 0.765160 | Strong penalty for far errors | Specific directional asymmetry. |
| Marginal comparison | Low −57; high +20; very high +22 | Distributional shift | Individual pairing closeness. |
| Transition direction | 153 upward; 33 downward | Direction of change | Chance-corrected agreement. |
| Correlation | Not the primary estimand | Monotonic association | Exact category equality. |
Weighted Kappa Calculator: Step-by-Step Workflow
A weighted kappa calculator needs the full square count matrix and the intended weight system. Entering only the diagonal percentage is insufficient.
Use rows for G1 and columns for G3 in the same category order.
Linear, quadratic or a justified custom matrix.
Margins, exact agreement, distance counts and directional imbalance.
| Calculator input | Worked entry | Validation rule |
|---|---|---|
| Number of categories | 4 | Rows and columns must match. |
| Observed matrix | [[88,69,0,0],[12,267,60,1],[0,19,86,23],[0,0,2,22]] | All counts nonnegative; total = 649. |
| Category order | Low, Medium, High, Very high | Same order for both ratings. |
| Primary weights | Quadratic disagreement | Diagonal = 0; maximum distance = 1. |
| Secondary weights | Linear disagreement | Used for sensitivity comparison. |
| Confidence method | 20,000-table bootstrap | Label as supplementary if not part of primary software output. |
Manual Calculator Audit
A trustworthy calculator should reproduce κL = 0.647398407 and κQ = 0.765159855. If the result is instead .544, the calculator is reporting ordinary unweighted kappa.
Python Weighted Kappa Chart Interpretations
These six Python figures are interpreted with the exact matrix values. Each chart supports a different part of the agreement argument: counts, weights, contributions, sensitivity and final reporting.
1. Agreement Matrix Python

The matrix contains 463 diagonal agreements, 153 cells above the diagonal and 33 below. The largest off-diagonal cells are low→medium (69) and medium→high (60).
The dense diagonal and near-diagonal concentration visually support a strong weighted kappa. Exact agreement is 71.34%, and 99.85% of all pairs are no more than one category apart.
2. Linear Disagreement Weights Python

Linear penalties are 0, 1/3, 2/3 and 1 for distances 0 through 3.
Applying these weights produces observed disagreement 0.096045, expected disagreement 0.272390 and κ = 0.647398.
3. Quadratic Disagreement Weights Python

Quadratic penalties are 0, 1/9, 4/9 and 1.
Because 185 of 186 mismatches are adjacent, quadratic observed disagreement falls to 0.032357; κ rises to 0.765160.
4. Weighted Contributions Python

The largest quadratic contributions are low→medium (0.011813) and medium→high (0.010272).
The single medium→very-high case contributes 0.000685; despite spanning two bands, it remains a small part of total observed disagreement because it occurs once.
5. Weighting Comparison Python

Unweighted κ = 0.5441, linear κ = 0.6474, and quadratic κ = 0.7652.
The 0.1178 gap between quadratic and linear results quantifies sensitivity to how adjacent errors are discounted.
6. Result Summary Python

The summary combines N = 649, exact agreement 71.34%, linear κ 0.6474 and quadratic κ 0.7652.
Observed quadratic agreement is 96.76% compared with 86.22% expected under the margins.
R Weighted Kappa Charts in Paired Rows
The R figures are displayed in paired rows, matching the fresh permanent sample. Explanations remain separate so each visual has its own numerical interpretation.


Agreement Matrix
The R agreement matrix reproduces all 16 counts and both margins. Diagonal agreement is 463/649.
The diagonal is strongest in the medium cell (267), while the most common movement is low→medium (69).
Linear Weights
The linear matrix assigns 0.3333 to adjacent, 0.6667 to two-step and 1.0000 to maximum disagreements.
The resulting κ is 0.647398; observed weighted agreement is 90.40%.


Quadratic Weights
The quadratic matrix assigns 0.1111, 0.4444 and 1.0000 to one-, two- and three-step errors.
The resulting κ is 0.765160; the higher value reflects the near absence of distant disagreements.
Weighted Contributions
Observed quadratic contributions sum to 0.032357.
Low→medium and medium→high together contribute 0.022085, or 68.25% of observed quadratic disagreement.


Weighting Comparison
Linear κ = 0.647398; quadratic κ = 0.765160.
Quadratic κ exceeds linear κ by 0.117761 and unweighted κ by 0.221109.
Result Summary
The summary reports the verified coefficients and disagreement terms.
The preferred conclusion is strong ordinal agreement with a separate upward-shift finding: 153 G3 increases versus 33 decreases.
Weighted Kappa in Python, R, SPSS, SAS and Excel
Python
- Build the 4 × 4 matrix with pandas or NumPy.
- Use disagreement matrices for linear and quadratic weights.
- Compute Do, De and κ directly.
- Cross-check with
sklearn.metrics.cohen_kappa_scoreusing weights.
R
- Create an ordered contingency table.
- Use
irr::kappa2,psych::cohen.kappaor a manual matrix calculation. - Confirm category order and weight definition.
- Export the matrix, weights and result plots.
SPSS
CROSSTABS /STATISTICS=KAPPAreturns ordinary kappa (.544 here).- Weighted kappa requires an extension, embedded Python/R or manual matrix computation.
- The linked SPSS output verifies the counts, margins and custom weighted results.
SAS
- Use
PROC FREQwith the square table. - Request agreement statistics and specify appropriate weights.
- Verify whether SAS reports agreement or disagreement weighting conventions.
Excel
- Enter the observed matrix and calculate row/column margins.
- Create linear and quadratic weight matrices.
- Use
SUMPRODUCTfor observed and expected disagreement. - Compute
1 - Do/De.
Cross-software target
- Linear κ = 0.6473984073
- Quadratic κ = 0.7651598550
- Quadratic Do = 0.0323574730
- Quadratic De = 0.1377851008
| Software | Native weighted kappa? | Verified role in this project | Expected result |
|---|---|---|---|
| Python | Yes, through libraries or manual formula | Primary transcript and figures | Linear 0.647398; quadratic 0.765160 |
| R | Yes, packages or manual formula | Independent reproduction and figures | Linear 0.647398; quadratic 0.765160 |
| SPSS | Built-in CROSSTABS is unweighted | Matrix verification plus integrated custom calculation | Unweighted .544; custom weighted values match |
| SAS | Available through agreement procedures | Reproducible alternative workflow | Should match when weights and ordering match |
| Excel | Manual formulas | Transparent worked calculation | Should match to displayed precision |
Cross-Software Reconciliation Checklist
| Checkpoint | Python report | R report | SPSS output | Required agreement |
|---|---|---|---|---|
| Valid N | 649 | 649 | 649 | All software uses the same complete pairs. |
| Observed matrix | 4 × 4 counts | Same 4 × 4 counts | Same crosstab | Cell order must match. |
| Linear weights | 0, .3333, .6667, 1 | Same matrix | Custom calculation | Disagreement convention. |
| Quadratic weights | 0, .1111, .4444, 1 | Same matrix | Custom calculation | Disagreement convention. |
| Linear κ | 0.6473984073 | 0.6473984073 | 0.6473984073 printed in custom block | Exact match. |
| Quadratic κ | 0.7651598550 | 0.7651598550 | 0.7651598550 printed in custom block | Exact match. |
| Ordinary κ | Optional | Optional | 0.544 | Do not confuse with weighted κ. |
If software values differ, check category ordering first, then whether the program uses agreement weights or disagreement weights, then whether missing values or zero-count categories were dropped. A reversed category on one axis can produce a radically different coefficient even when the same counts are present.
Expandable Weighted Kappa Code
Python: manual linear and quadratic weighted kappa
import numpy as np
O = np.array([
[88, 69, 0, 0],
[12,267, 60, 1],
[ 0, 19, 86, 23],
[ 0, 0, 2, 22]
], dtype=float)
N = O.sum()
P = O / N
row = P.sum(axis=1)
col = P.sum(axis=0)
E = np.outer(row, col)
idx = np.arange(4)
distance = np.abs(idx[:, None] - idx[None, :])
W_linear = distance / 3
W_quadratic = (distance / 3) ** 2
def weighted_kappa(W):
observed_disagreement = np.sum(W * P)
expected_disagreement = np.sum(W * E)
return 1 - observed_disagreement / expected_disagreement
print(weighted_kappa(W_linear)) # 0.647398407289
print(weighted_kappa(W_quadratic)) # 0.765159855031Python: scikit-learn cross-check
from sklearn.metrics import cohen_kappa_score
g1 = []
g3 = []
for i in range(4):
for j in range(4):
g1.extend([i + 1] * int(O[i, j]))
g3.extend([j + 1] * int(O[i, j]))
print(cohen_kappa_score(g1, g3, weights="linear"))
print(cohen_kappa_score(g1, g3, weights="quadratic"))R: manual matrix calculation
O <- matrix(c(
88,69,0,0,
12,267,60,1,
0,19,86,23,
0,0,2,22
), nrow=4, byrow=TRUE)
P <- O / sum(O)
E <- outer(rowSums(P), colSums(P))
d <- abs(outer(1:4, 1:4, "-"))
W.linear <- d / 3
W.quadratic <- (d / 3)^2
wk <- function(W) {
Do <- sum(W * P)
De <- sum(W * E)
1 - Do / De
}
wk(W.linear)
wk(W.quadratic)SPSS: verify the table and ordinary kappa
CROSSTABS
/TABLES=grade1 BY grade3
/FORMAT=AVALUE TABLES
/STATISTICS=KAPPA
/CELLS=COUNT ROW COLUMN
/COUNT ROUND CELL.This command verifies the 4 × 4 table and ordinary κ = .544. Use embedded Python/R or an extension for weighted κ.
Excel: observed quadratic disagreement
=SUMPRODUCT(Observed_Proportions, Quadratic_Weights)For the worked table this returns 0.032357473035.
Excel: expected quadratic disagreement and kappa
=SUMPRODUCT(Expected_Proportions, Quadratic_Weights)
=1-(Observed_Quadratic_Disagreement/Expected_Quadratic_Disagreement)The final value is 0.765159855031.
How to Interpret and Report Weighted Kappa
Report the weighting scheme, category structure, sample size, coefficient and enough table information to understand disagreement severity. Avoid labels such as “good” or “substantial” without the underlying numbers.
Primary APA-Style Result
Agreement between G1 and G3 four-level grade bands was evaluated using quadratic weighted Cohen’s kappa. Agreement was strong, κw = 0.765, supplementary bootstrap 95% CI [0.729, 0.797], N = 649. Exact agreement was 71.34%, and 648 of 649 pairs (99.85%) were within one category.
Sensitivity Result
Using linear rather than quadratic weights produced κw = 0.647, supplementary bootstrap 95% CI [0.601, 0.691]. The lower linear estimate reflects its larger penalty for adjacent disagreements.
Data-Focused Interpretation
Of 649 paired classifications, 463 matched exactly, 185 differed by one category, one differed by two categories and none differed by three. G3 was higher than G1 for 153 students and lower for 33, indicating that strong agreement coexisted with a systematic upward shift in the final classification.
Reporting Hierarchy
| Reporting element | Include? | Worked content |
|---|---|---|
| Weighting scheme | Always | Quadratic primary; linear sensitivity. |
| Category order | Always | Low, medium, high, very high. |
| Sample size | Always | 649 |
| Weighted kappa | Always | 0.765160 |
| Uncertainty | Recommended | Bootstrap 95% CI 0.7289–0.7974. |
| Raw exact agreement | Recommended | 71.34% |
| Distance distribution | Strongly recommended | 185 adjacent, 1 two-step, 0 three-step mismatches. |
| Direction | When ratings are ordered in time | 153 upward vs 33 downward transitions. |
| Unweighted kappa | Optional comparison | 0.544050. |
Quadratic Weighted Kappa
Primary
Agreement between rating 1 and rating 2 was assessed using quadratic weighted Cohen’s kappa across k ordered categories.
Weighted agreement was κw = estimate, 95% CI [lower, upper], N = sample size.
exact agreement % matched exactly and within-one-category % were within one category.
Weighting Sensitivity
Secondary
Linear weighting produced κw = value, compared with quadratic κw = value.
The difference reflected the concentration of disagreements at specified category distances.
How to Discuss the Upward Shift Without Undermining Agreement
A rigorous discussion should state that weighted agreement is strong and that G3 tends to be higher. The agreement coefficient summarises closeness after chance correction; the direction counts summarise change. The recommended wording is: “Ratings were usually identical or adjacent, but disagreements were asymmetric, with 153 upward and 33 downward transitions.” This avoids the misleading implication that high kappa means no systematic movement.
Interpretive Labels Are Secondary
Conventional labels such as moderate, substantial or strong vary across disciplines and should never replace the numerical evidence. In this example, the most defensible interpretation comes from the coefficient together with 71.34% exact agreement, 99.85% within-one-category agreement, and the complete absence of maximum-distance errors.
Common Weighted Kappa Mistakes and Corrections
| Mistake | Why it is wrong | Correction for this analysis |
|---|---|---|
| Calling .544 the weighted result | SPSS CROSSTABS reports ordinary kappa | Use .647398 linear or .765160 quadratic. |
| Reporting only exact agreement | {fmt_pct(exact_pct)} ignores chance and distance | Report raw agreement plus weighted kappa. |
| Choosing quadratic weights because κ is larger | Weight choice becomes outcome-driven | Justify the loss function before analysis. |
| Treating κ as percent correct | Kappa is a chance-corrected ratio | Explain observed and expected disagreement. |
| Ignoring table direction | Agreement can coexist with systematic change | Report {up} upward and {down} downward transitions. |
| Using weighted kappa for nominal categories | Distance would be arbitrary | Use ordinary kappa. |
| Reversing category order on one axis | Weights attach to wrong cells | Use the same ordered category list on both axes. |
| Ignoring zero distant cells | Sparse severe-error cells affect uncertainty | Show the full matrix and use a suitable interval method. |
| Calling the result causal | Agreement does not explain why grades changed | Interpret as classification agreement and movement. |
| Using correlation as a substitute | Correlation measures association, not equality | Use weighted kappa for agreement. |
Weighted Kappa Practice Questions
1. Compute exact agreement.
Add the diagonal cells 88 + 267 + 86 + 22 and divide by 649.
2. Count adjacent disagreements.
Add all cells one step above and below the diagonal.
3. Why is quadratic κ higher?
Use the distance distribution rather than a verbal benchmark alone.
4. Interpret κQ = 0.7652.
5. What does ordinary κ = 0.5441 add?
6. Describe directional movement.
7. Identify the largest quadratic contribution.
8. Should weighted kappa replace McNemar–Bowker?
9. Calculate chance exact agreement.
Multiply corresponding G1 and G3 marginal proportions and sum across the four bands.
10. Calculate ordinary kappa.
Use (Po − Pe)/(1 − Pe).
11. Which band shows the largest upward count?
12. What percentage of all pairs are within one category?
Weighted Kappa Reports and Worked Files
R Weighted Kappa ReportIndependent R reproduction with paired ordinal agreement figures.
SPSS Weighted Kappa OutputCrosstab, ordinary kappa and integrated weighted calculations.
Worked Excel AnalysisObserved matrix, weights, expected proportions and formulas.
Weighted Kappa Frequently Asked Questions
What is weighted kappa?
Weighted kappa is a chance-corrected agreement coefficient for two ordinal ratings. It assigns smaller penalties to near disagreements and larger penalties to distant disagreements.
What is the weighted kappa formula?
Using disagreement weights, κw = 1 − observed weighted disagreement divided by expected weighted disagreement.
What is the result in this example?
Linear weighted kappa is 0.647398 and quadratic weighted kappa is 0.765160 for 649 paired G1 and G3 classifications.
Why is quadratic kappa higher than linear kappa?
Because 185 of the 186 mismatches are adjacent, one is two categories apart and none are three categories apart. Quadratic weights heavily discount adjacent errors.
Is .765 the same as 76.5% agreement?
No. Exact agreement is 71.34%. The .765 value is the proportionate reduction in quadratic disagreement relative to chance expectation.
What does SPSS kappa .544 mean here?
It is ordinary unweighted Cohen’s kappa from CROSSTABS, not the weighted coefficient.
Can weighted kappa be negative?
Yes. A negative value indicates weighted disagreement greater than expected under the marginal distributions.
Should I use linear or quadratic weights?
Choose based on the practical cost of category distance. Linear weights add equal penalty per step; quadratic weights make distant errors disproportionately worse.
Does weighted kappa test marginal change?
No. Use McNemar’s test for paired binary margins or McNemar–Bowker/Bowker symmetry methods for paired multicategory change.
Can I use weighted kappa for more than two raters?
Standard weighted Cohen’s kappa is for two ratings. Multiple-rater ordinal agreement requires another method or a model designed for several raters.
What should be reported with weighted kappa?
Report category order, weighting scheme, N, κ, uncertainty, raw exact agreement, distance distribution and any directional imbalance.
Why report the full agreement matrix?
The matrix shows that 153 mismatches move upward and 33 downward, information that the single kappa value cannot reveal.
Weighted Kappa Conclusion
Weighted Kappa provides a precise summary of agreement when categories are ordered and disagreement severity matters. In this G1-versus-G3 analysis, 463 of 649 classifications match exactly, 185 differ by one category, one differs by two categories and none differ by three. Linear weighted κ is 0.647398, while quadratic weighted κ is 0.765160.
The quadratic result is higher because almost every error is adjacent. That finding should not hide the transition pattern: 153 classifications move upward from G1 to G3 and 33 move downward. The most complete conclusion is therefore strong distance-sensitive agreement with a clear net upward shift in G3 classifications.
