Stats for

Correlation and Association

Goodman and Kruskal's Gamma

Gamma measures whether two ordered variables rise and fall together.

Goodman and Kruskal's gamma takes two ordered categorical variables measured on the same people and tests whether higher categories on one tend to go with higher categories on the other.

Example

Do students feel they belong at their university more the further along they are? Two hundred undergraduates, 50 from each year, answered “I feel like I belong at this university” with disagree, neutral or agree.

One Sample + 2 Ordinal Variables → Goodman and Kruskal's Gamma
Tests
Population gamma (concordant minus discordant pairs, among untied pairs)
Observations
Independent
Parametric
No
Headline Statistic
\gamma
Effect Size
Goodman and Kruskal's Gamma
Groups
1

The Basics

When to Use It

Use it when you've sorted each person into one category on each of two variables whose categories have a natural order, such as a rating scale, a severity level or a year, and want to know whether higher on one tends to go with higher (or lower) on the other. It suits small tables, where many people share a category and ties are everywhere. For example:

  • Do students feel they belong at their university more the further along they are?
  • Do clients who rate their therapy alliance higher (low, medium, high) report more improvement (worse, same, better, much better)?
  • Is reported screen time before bed (under 1 hour, 1–2 hours, over 2 hours) related to daytime sleepiness (rarely, sometimes, often)?

Vocabulary You Need

Definition Contingency Table

A table that cross-classifies people on two categorical variables, one along the rows and one along the columns, so each cell counts the people with that combination. The row and column totals (the margins) show how each variable is spread on its own; the cells show how the two go together. Tables are described by their size, rows × columns, such as a 2 × 3 table. Glossary →

Definition Concordant Pair (C)

Two people who differ on both of two ordered variables, where the one who is higher on the first is also higher on the second. Counting concordant pairs, against discordant ones, is how rank measures such as Kendall's τ, Somers' d and Goodman and Kruskal's γ measure a one-direction association without using the distances between scores. In a contingency table with both variables in order, a cell's concordant partners sit below and to the right of it (and above and to the left). Glossary →

Definition Discordant Pair (Ordinal) (D)

Two people who differ on both of two ordered variables, where the one who is higher on the first is lower on the second. They are the evidence against a positive association, just as concordant pairs are the evidence for one. In a contingency table with both variables in order, a cell's discordant partners sit below and to the left of it (and above and to the right). Not the same idea as a discordant pair in McNemar's test, which is one person whose yes/no answer changed. Glossary →

Definition Tied Pair

Two people who share the same category on one variable (tied on X), on the other (tied on Y), or on both. With ordered categories such as ratings or bands, most pairs are tied on something. Ordinal measures of association differ mainly in what they do with ties: gamma leaves out every tied pair; Somers' d_YX leaves out pairs tied on the predictor but keeps pairs tied only on the outcome, counting them as failed predictions; Kendall's tau-b keeps pairs tied on just one variable in its denominator, splitting the difference between the two Somers' d's (it's their geometric mean). Glossary →

Assumptions and Inference

1. Two Ordered Variables Both variables' categories run from less to more of something, and at least one pair of people differs on both, so γ can be computed.
What It Means
A higher value means more of something, so scores can be compared as more or less: each person's scores across conditions, or two ordered variables in a table. Ratings, rankings and continuous scores all qualify; unordered categories don't. Rank-based methods use only that order, not the distances between scores.
Applies To
Observations
How to Check
By design. Ask whether a higher score means more of something. Then count how many people gave tied scores, since ties carry less information about the order.
How Much It Matters
Complete. Gamma only means something if both variables' categories run from less to more. Year in school and a disagree–neutral–agree scale both do. Reorder the categories of a nominal variable and γ changes, even changing sign, while the data stay the same. And if no pair differs on both variables, γ is 0 ÷ 0 and can't be computed.

What to Do

  • Alternative Test Cramér's V. If either variable's categories have no order (college major, help source), measure the association without direction using Cramér's V and a chi-square test.
  • Correction Make sure the software sorts the categories in their real order, not alphabetically: coded 1, 2, 3 or with value labels. Alphabetical order scrambles them (agree, disagree, neutral; first, fourth, second, third), which changes gamma's size and can flip its sign: here it gives −.11.
2. Monotonic Association (for What γ Means) γ summarizes an overall tendency to move in one direction; it can be computed for any pattern, but a relationship that rises and then falls can give a γ near zero.
What It Means
The relationship keeps one direction across the whole range of scores, though it doesn't have to be a straight line or change at a steady rate. Rank-based coefficients summarize how consistently it keeps that direction, so a relationship that rises and then falls can show a coefficient near zero even when the two variables are strongly related.
Applies To
Variables
How to Check
Look at a scatterplot, ideally with a smooth trend line through it. For a small table of ordered categories, look instead at the percentages within each category (or a stacked bar chart): the share at the high end should move one way across the categories. A trend that bends but keeps going the same way is fine; one that clearly turns around, like a U or an inverted U, is not. It's a question about the shape, so decide by looking, not by a test.
How Much It Matters
A lot, for what γ means. It counts pairs that go the same way against pairs that go opposite ways, so a relationship that rises and then falls, such as belonging peaking in second year, can cancel out to a γ near zero. The belonging study's percentages climb steadily with year.

What to Do

  • Proceed with Caveat Show the row or column percentages. If the association changes direction partway, say so and don't summarize it with a single γ.
  • Alternative Test Pearson Chi-Square Test. It detects any pattern of association, including an up-then-down one, though it ignores the order and says nothing about direction.
3. Independent Observations (for the p-Value and Interval) The people (or other units) in your study don't influence each other.
What It Means
Each person's data comes from a separate, unconnected source, so knowing one person's scores tells you nothing about anyone else's. In designs that measure people more than once, their own scores are meant to be related; it's different people who must be independent. Methods built for clustered data, such as multilevel models and GEE, also allow members of the same group to be related, as long as the analysis names the grouping; then it's the groups that must be independent.
Applies To
Observations
How to Check
By design, not by a test. Did each person contribute their own data, with no clusters such as roommates, couples, therapy groups or classrooms whose members influence each other? If there are clusters, does the analysis model every one of them?
How Much It Matters
A lot. Every pair of people is compared, so each person has to be a separate, unconnected case counted once. Students surveyed in friendship groups or residence halls who shape each other's answers make the standard error too small and p too small. The pairs themselves aren't independent, since each person appears in many of them; γ's standard error already allows for that overlap, but not for links between people.

What to Do

  • Design Change Count each person once, and sample people rather than clusters such as halls or classes.
  • Alternative Test Ordinal Regression. If people come in clusters, an ordinal regression with a random effect for the cluster (a cumulative link mixed model) can estimate the same ordered association while accounting for the clustering.
4. Enough Data in the Table (for the p-Value and Interval) The z test and the Wald interval are large-sample approximations, which need a reasonable sample spread over the table.
What It Means
The z test and the interval γ ± 1.96 × SE treat γ as roughly normal, which holds once the sample is reasonably large and the table isn't sparse. With few people, many near-empty cells or γ near ±1, the approximations can be poor.
Applies To
Observations
How to Check
Look at the table's counts and γ's size. With a small sample, several near-empty cells, or γ near ±1, check p with an exact or permutation test and use a bootstrap or transformed-scale interval.
How Much It Matters
Some, for p and the interval only. With 200 students and no cell below 8, the belonging study is well within range: a permutation test gives p = .004, close to the z test's .002.

What to Do

  • Robust Estimation Shuffle one variable a few thousand times and count how often γ lands at least as far from zero, or click Exact in SPSS Crosstabs.
  • Robust Estimation Resample people and take the middle 95% of the γ values, or build the interval on the scale ln[(1 + γ) ÷ (1 − γ)] and transform back; say which method you used.

Limitations

This Is Not Your Test If…

What It Doesn't Tell You

  • Why. Nothing here shows that time at the university builds belonging. Students who felt they didn't belong may have left before their fourth year, so later years hold the ones who stayed.
  • How strong, on a common scale. γ = .25 counts only the half of the pairs that weren't tied. Kendall's τ-b, a close cousin that also counts pairs tied on just one variable in its denominator, is .18, so don't line γ up against correlations from other studies.
  • Who else. The result describes students like these 200, at one university, at one point in time; it doesn't follow any student from year to year.
  • That there's no association, if p had been above .05. A non-significant γ would have meant the data were inconclusive, not that belonging is the same in every year. It also wouldn't rule out an association that rises and then falls, which γ can miss.

Common Mistakes

  • Don'tLet software sort ordered categories alphabetically.

    InsteadCode the categories as numbers in their real order (1 = disagree, 2 = neutral, 3 = agree) before running Crosstabs.

  • Don'tRead γ = .25 as “25% of the variation explained.”

    InsteadRead it as a gap between pair types. Among untied pairs, 62.5% line up and 37.5% go the other way.

  • Don'tReport γ without saying how many pairs were tied.

    InsteadGive the percentages in the table, and say γ is based only on the untied pairs, or report τ-b too.

  • Don'tRead a γ near ±1 as a near-perfect relationship.

    InsteadCheck the table. γ is ±1 whenever no pair goes the other way, which a single empty cell can cause: in a 2 × 2 table, an empty cell forces γ to ±1 whenever any untied pairs remain. Report τ-b too.

  • Don'tSwitch to a one-sided p because the association went the way you hoped.

    InsteadUse a one-sided test only if you predicted the direction before collecting data, and say so.

  • Don'tTreat a γ as if it were on the same scale as Pearson's r or Kendall's τ-b.

    InsteadRemember γ ignores tied pairs, so it runs larger when ties are common. Compare γ with γ, or report τ-b too.

  • Don'tRead a p-value as the chance that the null hypothesis is true.

    InsteadRead it as: if the null were true, how often data at least this extreme would turn up.

Result Decoder

Significance Guidelines

Benchmarks Significance (p Value)
  • p < .001

    Very strong evidence against the null hypothesis.

  • .001 ≤ p < .01

    Strong evidence against the null hypothesis.

  • .01 ≤ p < .05

    Statistically significant at α = .05. Moderate evidence against the null hypothesis.

  • .05 ≤ p < .10

    Not significant. Weak evidence; sometimes called a “trend.” Treat it as inconclusive.

  • p ≥ .10

    Not significant. Little evidence against the null, which is not the same as evidence of no effect.

These evidence labels are one common convention for describing p in graded language rather than as significant or not; the boundaries are rough guides, not rules, and other authors draw them differently. Muff et al. (2022) argue for this kind of language of evidence over a single cutoff. α is chosen before the analysis, and p never says how big or important an effect is.

More about statistical significance ↓

How It's Reported

Equation Form

Example

γ = .25, 95% CI [.09, .41], z = 3.04, p = .002

Full Text (APA Style)

Example

Students further along in school more often agreed that they belonged at the university: 30% of first-years agreed, against 42%, 48% and 60% of second-, third- and fourth-years, while disagreement was lower in later years, from 30% of first-years to 16% of fourth-years. Goodman and Kruskal's gamma showed a positive association between year and sense of belonging, γ = .25, 95% CI [.09, .41]. Gamma uses only the 49% of pairs of students who differed in both year and answer; counting pairs tied on just one of the two, Kendall's τb = .18. The association was statistically significant, z = 3.04, p = .002.

  • Give the percentages, so readers can see the pattern γ summarizes. Percentage within the groups you're comparing (here, within each year).
  • Say that γ ignores tied pairs, and give τ-b or Somers' d alongside it when ties are common, as they are in any small table.
  • SPSS reports an Asymptotic Standard Error for γ but not a confidence interval. For a reasonably large sample with γ away from ±1, an approximate 95% interval is γ ± 1.96 × SE. Near ±1 or with sparse cells this interval can be unreliable (cutting it off at ±1 doesn't fix that); use a transformed-scale interval, built on ln[(1 + γ) ÷ (1 − γ)] and transformed back, or a bootstrap interval instead, and say which method you used.
  • Report the z (SPSS's Approx. T) and exact p to three decimals, with no leading zero for γ or p: neither can go past 1.

Reading Each Piece

The equation form above, piece by piece, in this order: how big, how certain, then how surprising.

γ = .25 Of the pairs of students who differed in both year and answer, 62.5% had the later-year student feeling more at home, and 37.5% the reverse. There are no agreed benchmarks for γ, and it runs high because it ignores the tied half of the pairs.
95% CI [.09, .41] The population gamma is plausibly anywhere from .09, barely above zero, to .41. The whole range is above zero, but 200 students can't pin the strength down precisely.
z = 3.04 Gamma is 3.04 null-hypothesis standard errors above zero. SPSS prints this as Approx. T, but it's judged against the normal curve.
p = .002 If year and sense of belonging were unrelated, a gamma at least this far from zero, in either direction, would turn up about 0.2% of the time. That's well below .05, so the association is statistically significant. Benchmarks ↑

Calculations

The Running Example

Example

The belonging study: 200 undergraduates, 50 per year from first to fourth, each answering disagree, neutral or agree to “I feel like I belong at this university.”

Null Hypothesis:
\gamma = 0
Alternative (Two-Sided):
\gamma \neq 0

\gamma (“gamma”) is the population gamma: among all pairs of students like these who differ in both year and answer, the share whose year and answer line up in the same order minus the share that go opposite ways. The sample's γ = .25 estimates it. Strictly, the test assumes the two variables are unrelated (independent), which implies γ = 0; it isn't built to test γ = 0 when the variables are related in some other way, such as up and then down.

What Your Data Should Look Like

One row per person, with one column for each ordered variable. Code the categories as numbers in their real order (1 = disagree, 2 = neutral, 3 = agree), or give them value labels in that order, so software doesn't sort them alphabetically. Software builds the table of counts for you.

Our 200 rows become a 3 × 4 table, answers down the side and years across the top, both in order. Every cell's concordant partners sit below and to the right of it; its discordant partners sit below and to the left. The box below gives percentages within each year, as the write-up does (30% of first-years agreed, against 60% of fourth-years).

Example
participantbelongingyear
1neutralfirst
2agreethird
3disagreethird
4agreethird
5disagreefourth
6disagreethird
… 194 more rows
First-YearSecond-YearThird-YearFourth-YearTotal
Disagree15 (30%)15 (30%)12 (24%)8 (16%)50
Neutral20 (40%)14 (28%)14 (28%)12 (24%)60
Agree15 (30%)21 (42%)24 (48%)30 (60%)90
Total50505050200

Counts, with the percentage of each year (each column adds to 100%).

Simulated data.

Download all 200 rows (data.csv)

Napkin Math

The whole test, one idea at a time. Under each heading, a line says why the step matters, and the green note reads the equation in plain English with the belonging study's numbers. Collapse all to read just the headings: they tell the whole story on their own.

  1. 1. Pair Up Every Two Students and Count the Pairs That Line Up

    Gamma works on pairs of people. A pair is concordant when the student who is further along in school also gave the higher answer: their year and their answer go in the same order.

    C = \sum_{i,j} n_{ij} \times \Big(\sum_{h > i,\; k > j} n_{hk}\Big) =15 \times (40 + 75) + 15 \times 80 + \cdots

    = 6105 pairs

    \text{from the first-year, disagree corner} = 1725

    Start in the corner: the 15 first-years who disagreed. Every student in a later year with a higher answer lines up with them: 14 + 14 + 12 = 40 who were neutral and 21 + 24 + 30 = 75 who agreed, so 15 × 115 = 1,725 pairs. Do the same from every cell, always looking down and to the right, and C = 6,105 concordant pairs.

  2. 2. Count the Pairs That Go the Opposite Way

    A pair is discordant when the student further along gave the lower answer. Every discordant pair is a small piece of evidence against the idea that later-year students feel they belong more.

    D = \sum_{i,j} n_{ij} \times \Big(\sum_{h > i,\; k < j} n_{hk}\Big) =8 \times (48 + 60) + \cdots

    = 3663 pairs

    \text{from the fourth-year, disagree corner} = 864

    Take the 8 fourth-years who disagreed. Every student in an earlier year with a higher answer goes the other way: 20 + 14 + 14 = 48 neutral and 15 + 21 + 24 = 60 agree, so 8 × 108 = 864 pairs. Looking down and to the left from every cell, D = 3,663 discordant pairs.

  3. 3. Set Aside the Pairs That Tie

    Two students in the same year, or with the same answer, can't show which way the association runs. Gamma leaves these tied pairs out entirely, and in a small table they are often the majority.

    T = \dfrac{n(n - 1)}{2} - C - D =\dfrac{200 \times 199}{2} - 6105 - 3663

    = 10132 pairs

    \text{share of all pairs} = .51

    n is our 200 students, who make 200 × 199 ÷ 2 = 19,900 pairs in all. Take away the 6,105 concordant and 3,663 discordant pairs and T = 10,132 pairs are tied on year, on answer or on both: just over half.

  4. 4. Compare the Pairs That Line Up with the Pairs That Don't

    Among the untied pairs, subtract the discordant from the concordant and divide by how many there are. The result runs from −1 (every untied pair goes opposite ways) through 0 to 1 (every untied pair lines up), and it's also the effect size.

    \gamma = \dfrac{C - D}{C + D} =\dfrac{6105 - 3663}{6105 + 3663}

    = .25

    C is our 6,105 concordant pairs and D our 3,663 discordant ones. 2,442 ÷ 9,768 = .25: of the untied pairs, 62.5% line up and 37.5% go the other way.

  5. 5. Figure Out How Precisely Gamma Is Estimated

    Another sample of 200 students would give a somewhat different γ. The standard error measures how much, from how unevenly each cell's partners split between lining up and going against (Goodman & Kruskal, 1963, 1972).

    SE = \dfrac{2}{(C + D)^2}\sqrt{\sum_{i,j} n_{ij}\,(D\,C_{ij} - C\,D_{ij})^2} =\dfrac{2}{9768^2}\sqrt{1.50 \times 10^{13}}

    = 0.081

    C_{ij} and D_{ij} are how many students line up with, or go against, a student in cell ij: 115 and 0 for a first-year who disagreed. That cell adds 15 × (3,663 × 115 − 6,105 × 0)² = 2.66 × 10¹², a large share, because its students line up far more often than the overall 6,105 to 3,663 split. The 12 cells together give 1.50 × 10¹³. Its square root, times 2 ÷ 9,768², is 0.081.

  6. 6. Give a Range of Plausible Values for the True Gamma

    Instead of a single best guess, give the range of population gammas that fit the data, 1.96 standard errors either side.

    \gamma \pm 1.96 \times SE =0.25 \pm 1.96 \times 0.081

    = [.09, .41]

    1.96 is the cutoff that holds the middle 95% of a normal curve. 1.96 × 0.081 = 0.16, so the range is .25 ± .16, from .09 to .41.

  7. 7. Compare Gamma with the Wobble Expected If Year and Belonging Were Unrelated

    The test asks what γ would do if there were no association, so it divides by the standard error worked out under that assumption, which is slightly larger here. SPSS calls the result Approx. T.

    z = \dfrac{\gamma}{SE_0}, \quad SE_0 = \dfrac{1}{C + D}\sqrt{\sum_{i,j} n_{ij}(C_{ij} - D_{ij})^2 - \dfrac{4(C - D)^2}{n}} =\dfrac{0.25}{0.0822}

    = 3.04

    SE_0 = 0.0822

    SE_0 is an estimate of the standard error if year and belonging were unrelated, 0.0822 (against 0.0812 for the interval). .25 ÷ 0.0822 = 3.04: gamma sits 3.04 of these standard errors above zero.

  8. 8. Ask How Surprising the Result Would Be If Year and Belonging Were Unrelated

    Finally, ask how often a gamma at least this far from zero, in either direction, would turn up if year and sense of belonging were unrelated.

    p = 2 \times P(Z \ge |z|) =2 \times P(Z \ge 3.04)

    = .002

    P(Z \ge 3.04) is the chance a standard normal value lands at or above 3.04. Doubling it counts both directions: .002, about 1 in 426.

  9. 9. See How Much the Ties Flatter Gamma

    Gamma's denominator counts only untied pairs, so it can be large even when most pairs say nothing. Kendall's τ-b puts the pairs tied on just one variable back into the denominator, which gives a more modest number for the same data.

    \tau_b = \dfrac{C - D}{\sqrt{(N_0 - T_{\text{answer}})(N_0 - T_{\text{year}})}} =\dfrac{2442}{\sqrt{(19900 - 7000)(19900 - 4900)}}

    \tau_b = .18

    d_{\text{belonging} \mid \text{year}} = .16

    N_0 is all 19,900 pairs, T_{\text{answer}} the 7,000 pairs who gave the same answer and T_{\text{year}} the 4,900 in the same year. 2,442 ÷ √(12,900 × 15,000) = 2,442 ÷ 13,910 = .18, well under gamma's .25. Somers' d, predicting belonging from year, is 2,442 ÷ 15,000 = .16. In a table that isn't square, τ-b can't quite reach ±1; Stuart's τ-c (SPSS: Kendall's tau-c) adjusts for that and gives .18 here too.

Run It in Software

The code below reads the running example's data from data.csv; save it in the same folder you run the code from.

SPSS (version 30, as documented by IBM)
  1. Put the categories in order first. Transform → Recode into Different Variables: recode belonging into belong_n (disagree = 1, neutral = 2, agree = 3) and year into year_n (first = 1 through fourth = 4), and give both value labels.
  2. Analyze → Descriptive Statistics → Crosstabs. Move belong_n into Row(s) and year_n into Column(s).
  3. Click Statistics, check Gamma (and Kendall's tau-b, to see the effect of ties), and click Continue.
  4. Click Cells, check Observed and Column percentages, and click Continue, then OK.

Or paste this syntax:

RECODE belonging ('disagree'=1) ('neutral'=2) ('agree'=3) INTO belong_n.
RECODE year ('first'=1) ('second'=2) ('third'=3) ('fourth'=4) INTO year_n.
VALUE LABELS belong_n 1 'disagree' 2 'neutral' 3 'agree'
  /year_n 1 'first' 2 'second' 3 'third' 4 'fourth'.
EXECUTE.

CROSSTABS
  /TABLES=belong_n BY year_n
  /FORMAT=AVALUE TABLES
  /STATISTICS=GAMMA BTAU
  /CELLS=COUNT COLUMN
  /COUNT ROUND CELL.

Reading the Output

Read the tables in this order: the column percentages in the Crosstabulation (the pattern), then Gamma's Value (the size), then build the interval from its Asymptotic Standard Error, and finally Approximate T and Approximate Significance (the test).

belong_n * year_n Crosstabulation (abridged)

first second third fourth Total
disagree Count 15 15 12 8 50
% within year_n 30.0% 30.0% 24.0% 16.0% 25.0%
neutral Count 20 14 14 12 60
% within year_n 40.0% 28.0% 28.0% 24.0% 30.0%
agree Count 15 21 24 30 90
% within year_n 30.0% 42.0% 48.0% 60.0% 45.0%

Symmetric Measures

Value Asymptotic Standard Errorᵃ Approximate Tᵇ Approximate Significance
Ordinal by Ordinal Kendall's tau-b .176 .058 3.042 .002
Gamma .250 .081 3.042 .002
N of Valid Cases 200

a. Not assuming the null hypothesis. b. Using the asymptotic standard error assuming the null hypothesis.

SPSS doesn't print a confidence interval for gamma: take .250 ± 1.96 × .081, which gives [.09, .41]. “Approximate T” is the z on this page, compared with the normal curve. It uses a different standard error (0.082, assuming no association; Mehta & Patel, 2021) from the one printed next to it, so .250 ÷ .081 won't reproduce it exactly. It's the same for tau-b and gamma: SPSS's Approx. T is the same for every concordant-minus-discordant measure, so the choice between them changes the size you report, not p.

Output laid out from this page's computed results, not captured from a live run; labels and layout may differ slightly in your version.

R
belong <- read.csv("data.csv")

# Put the categories in their real order before tabulating.
belong$belonging <- factor(belong$belonging, levels = c("disagree", "neutral", "agree"))
belong$year <- factor(belong$year, levels = c("first", "second", "third", "fourth"))
n <- table(belong$belonging, belong$year)

# Students concordant (C_ij) and discordant (D_ij) with someone in each cell
Cij <- Dij <- matrix(0, nrow(n), ncol(n))
for (i in 1:nrow(n)) for (j in 1:ncol(n)) {
  Cij[i, j] <- sum(n[row(n) < i & col(n) < j]) + sum(n[row(n) > i & col(n) > j])
  Dij[i, j] <- sum(n[row(n) < i & col(n) > j]) + sum(n[row(n) > i & col(n) < j])
}
C <- sum(n * Cij) / 2
D <- sum(n * Dij) / 2
gamma <- (C - D) / (C + D)
se  <- 2 / (C + D)^2 * sqrt(sum(n * (D * Cij - C * Dij)^2))            # for the interval
se0 <- sqrt(sum(n * (Cij - Dij)^2) - 4 * (C - D)^2 / sum(n)) / (C + D)  # for the test
z <- gamma / se0
round(c(C = C, D = D, gamma = gamma, se = se, lower = gamma - 1.96 * se,
        upper = gamma + 1.96 * se, z = z, p = 2 * pnorm(-abs(z))), 4)

# Kendall's tau-b, for comparison
cor(as.numeric(belong$year), as.numeric(belong$belonging), method = "kendall")
        C         D     gamma        se     lower     upper         z         p
6105.0000 3663.0000    0.2500    0.0812    0.0909    0.4091    3.0424    0.0023

[1] 0.1755518

Base R has no gamma function, so the code builds it from the pair counts. The DescTools package offers GoodmanKruskalGamma(n, conf.level = 0.95) for the estimate and interval, and KendallTauB(n). cor(..., method = "kendall") gives τ-b, since it adjusts for ties.

Output laid out from this page's computed results, not captured from a live run; labels and layout may differ slightly in your version.

Python
import numpy as np
import pandas as pd
from scipy import stats

belong = pd.read_csv("data.csv")
answers = ["disagree", "neutral", "agree"]
years = ["first", "second", "third", "fourth"]
n = pd.crosstab(belong["belonging"], belong["year"]).loc[answers, years].to_numpy()

# Students concordant (C_ij) and discordant (D_ij) with someone in each cell
r, k = n.shape
Cij = np.array([[n[:i, :j].sum() + n[i+1:, j+1:].sum() for j in range(k)] for i in range(r)])
Dij = np.array([[n[:i, j+1:].sum() + n[i+1:, :j].sum() for j in range(k)] for i in range(r)])
C = (n * Cij).sum() / 2                  # 6105.0
D = (n * Dij).sum() / 2                  # 3663.0
gamma = (C - D) / (C + D)                # 0.25
se = 2 / (C + D)**2 * np.sqrt((n * (D * Cij - C * Dij)**2).sum())            # 0.0812
se0 = np.sqrt((n * (Cij - Dij)**2).sum() - 4 * (C - D)**2 / n.sum()) / (C + D)  # 0.0822
gamma - 1.96 * se, gamma + 1.96 * se     # (0.0909, 0.4091)
z = gamma / se0                          # 3.0424
2 * stats.norm.sf(abs(z))                # 0.0023

# Kendall's tau-b, for comparison
x = belong["year"].map({y: i for i, y in enumerate(years)})
y = belong["belonging"].map({a: i for i, a in enumerate(answers)})
stats.kendalltau(x, y).statistic         # 0.1756

scipy has no gamma function, so the code builds it from the pair counts. .loc[answers, years] puts the rows and columns in their real order; without it pandas sorts them alphabetically. stats.kendalltau gives τ-b; its p-value (.004) uses a different variance from SPSS's Approx. T, so it won't match the .002 above.

Output laid out from this page's computed results, not captured from a live run; labels and layout may differ slightly in your version.

Impact

Effect Size

Gamma is its own effect size. It compares the pairs of people who line up in the same order with the pairs who go opposite ways, so it has no units and runs from −1 to 1 whatever the categories are.

\gamma = \dfrac{C - D}{C + D} = \dfrac{6105 - 3663}{6105 + 3663} = .25

Of the pairs of students who differed in both year and answer, 62.5% had the later-year student feeling more at home and 37.5% the reverse. That 25-point gap is γ.

Gamma has one big blind spot: it leaves out every tied pair, and in a small table with concentrated category frequencies, a substantial share of pairs can tie. Here 51% of the pairs were in the same year or gave the same answer. Because its denominator only counts the untied pairs, γ is always at least as far from zero as Kendall's τ-b (which also counts pairs tied on just one variable) or Somers' *d* (which also counts pairs tied only on the outcome) for the same table, and with many ties it's a good deal larger: τ-b is .18 and d is .16 for the belonging study. In simulations that cut correlated normal scores into small square tables, γ came closer than τ-b or d, on average, to the correlation of the original scores, though it overshot that correlation as samples grew (Göktaş & İşçi, 2011). Their tables were square and ours is 3 × 4. None of these measures is the "right" one: they answer different questions about ties.

For the same reason, γ reaches ±1 as soon as one kind of pair is missing, however weak the rest of the pattern. In a 2 × 2 table, one empty cell is enough whenever any untied pairs remain: counts of 30 and 0 over 20 and 10 give γ = 1, but τ-b = .45. A γ near ±1 from a small or sparse table isn't a near-perfect association; look at the table.

Whatever the benchmark, go back to the percentages too: 30% of first-years agreed that they belonged, against 60% of fourth-years. Whether that difference calls for a program for first-years is a question about student life, not statistics.

There are no agreed benchmarks for γ. Borrowing Cohen's .10, .30 and .50 for r would flatter it: γ ignores tied pairs, so in a table with many ties it runs well above Kendall's τ-b or Spearman's ρ for the same data. Compare it with γ from similar tables, or report τ-b alongside it.

Statistical Significance

p answers one narrow question: if the two variables were unrelated in the population, how often would a sample's γ land at least this far from zero, in either direction? It comes from z, γ divided by its standard error worked out under that no-association assumption, compared with the normal curve. Below the conventional α = .05, the association is called statistically significant.

If year and sense of belonging were unrelated, 200 students would give a γ at least this far from zero, in either direction, about 0.2% of the time, roughly 1 in 426. That's well below .05, so it's significant.

Using the order pays off. A chi-square test on the same table ignores the order of the categories and asks only whether the mix of answers differs somehow across years; for the belonging study it isn't significant, χ²(6, N = 200) = 10.24, p = .115. Gamma pools the evidence into one direction, higher belonging in later years, and has more power to find that kind of pattern.

Both z and p are large-sample approximations. With a small sample or many near-empty cells, use an exact or permutation test instead: in SPSS, click Exact in Crosstabs; in R or Python, shuffle one variable a few thousand times and count how often γ lands at least as far from zero. For the belonging study a permutation test gives p = .004, close to the .002 here.

p is not the probability that the variables are unrelated, and it says nothing about how strong the association is. That's what γ, its interval and the percentages are for.

Benchmarks p at a Glance
Very Strong
p < .001
Strong
.001 ≤ p < .01
Significant
.01 ≤ p < .05
Weak
.05 ≤ p < .10
Little
p ≥ .10

Strength of evidence against the null hypothesis.

Full benchmarks and caveats ↑

Power and Sample Size

Power is the chance that a study detects an effect that's really there. A real association doesn't guarantee a significant result: with too few people, it can easily come out non-significant. For gamma, power depends on how strong the true association is, how many people you have, α, and how the people spread across the table: many ties leave fewer informative pairs.

There's no standard formula or calculator for gamma's power. The practical route is simulation: write down the table of proportions you expect, draw many samples of a given size from it, run the test on each, and count how often it comes out significant.

Suppose, before collecting any data, we expected a table like the one we found, with γ = .25, and planned equal numbers from each year. Simulating 4,000 studies of each size, each year's answers drawn from that year's expected proportions, 200 students (50 per year) came out significant about 86% of the time, 150 students about 74%, and 100 students only about 57%.

Researchers usually aim for at least 80% power. Plan it before collecting data, using the smallest association that would matter. With the planning table in hand, a short loop in R or Python does the simulation: sample each year's answers with rmultinom (R) or numpy.random.multinomial (Python), keeping the planned number per year (sampling all the cells at once instead lets the year totals vary, which here gives 84%, 73% and 57%), compute γ and z each time, and count the z values beyond ±1.96.

Other Info

Follow-Up and Post Hoc Tests

None needed. This test answers a single question, so there are no planned contrasts or post hoc tests to run.

References

  • Goodman, L. A., & Kruskal, W. H. (1954). Measures of association for cross classifications. Journal of the American Statistical Association, 49(268), 732–764. https://doi.org/10.1080/01621459.1954.10501231
  • Goodman, L. A., & Kruskal, W. H. (1963). Measures of association for cross classifications III: Approximate sampling theory. Journal of the American Statistical Association, 58(302), 310–364. https://doi.org/10.1080/01621459.1963.10500850
  • Goodman, L. A., & Kruskal, W. H. (1972). Measures of association for cross classifications, IV: Simplification of asymptotic variances. Journal of the American Statistical Association, 67(338), 415–421. https://doi.org/10.1080/01621459.1972.10482401
  • Agresti, A. (2010). Analysis of ordinal categorical data (2nd ed.). Wiley. https://doi.org/10.1002/9780470594001
  • Mehta, C. R., & Patel, N. R. (2021). IBM SPSS Exact Tests [Software manual, for version 28]. IBM Corporation. https://www.ibm.com/docs/en/SSLVMB_28.0.0/pdf/IBM_SPSS_Exact_Tests.pdf
  • Göktaş, A., & İşçi, Ö. (2011). A comparison of the most commonly used measures of association for doubly ordered square contingency tables via simulation. Metodološki zvezki, 8(1), 17–37. https://ibmi.mf.uni-lj.si/mz/2011/no-1/goktas.pdf
    “for small table dimensions Gamma overestimate the actual the degree of ordinal association.” (p. 35)
    “The estimator of gamma uses only the number of concordant and discordant pairs of observations. It ignores tied pairs.” (p. 23)
  • Muff, S., Nilsen, E. B., O'Hara, R. B., & Nater, C. R. (2022). Rewriting results sections in the language of evidence. Trends in Ecology & Evolution, 37(3), 203–210. https://doi.org/10.1016/j.tree.2021.10.009
    “we suggest language of evidence that allows for a more nuanced approach to communicate scientific findings as a simple and intuitive alternative to statistical significance testing” (Abstract)
  • McHugh, M. L. (2013). The chi-square test of independence. Biochemia Medica, 23(2), 143–149. https://doi.org/10.11613/BM.2013.018
    “The value of the cell expecteds should be 5 or more in at least 80% of the cells, and no cell should have an expected of less than one” (Assumptions of the Chi-square)
  • Campbell, I. (2007). Chi-squared and Fisher–Irwin tests of two-by-two tables with small sample recommendations. Statistics in Medicine, 26(19), 3661–3675. https://doi.org/10.1002/sim.2832

Spot an error? Something still confusing? Tell us at support@statsforpsychology.com.