Written and maintained by CASRAI Editorial Board
Last updated
The Cochran-Armitage trend test (also called the Cochran-Armitage test for trend) checks whether the proportion of “successes” rises or falls steadily across ordered groups. It reduces the question to one degree of freedom, so it is usually more powerful than an ordinary chi-square test when the pattern you suspect is really there. This page works one 2 × 3 table by hand, shows why the trend test returns p = 0.022 where Pearson’s chi-square returns p = 0.0695 on the same counts, and gives the formula, reporting wording and code.
What is the Cochran-Armitage test for trend?
It is a test for a linear trend in proportions. The data form a 2 × k table: one binary variable (for example case versus control) and one ordinal variable with k ordered categories (for example genotype copies, dose level or age band). The null hypothesis is that the probability of the binary outcome is the same in every one of the k categories, that is, no association. The alternative is that the probability changes steadily with the category scores you assign. The test is named after W. G. Cochran (1954) and P. Armitage (1955); see the sources below.
Cochran-Armitage formula and symbols
Using the standard layout, let the table have row totals R1 and R2, column totals Ci = N1i + N2i, and grand total N. Assign a weight ti to each of the k columns. The test statistic and its variance under the null hypothesis are:
T = Σ ti (N1i R2 − N2i R1)
Var(T) = (R1 R2 / N) × ( Σ ti² Ci (N − Ci) − 2 Σi<j ti tj Ci Cj )
For large samples, Z = T / √Var(T) follows a standard normal distribution under the null hypothesis, and Z² follows a chi-square distribution with 1 degree of freedom.
- k: the number of ordered categories (columns).
- N1i, N2i: the counts in row 1 and row 2 of column i.
- R1, R2: the two row totals. Ci: the column totals. N: the grand total.
- ti: the weight (score) for column i, chosen before you look at the data.
Which row you call “row 1” only flips the sign of T and Z; the p-value is unchanged.
Worked example (2 × 3 table)
A genotype table with 120 people: 60 controls and 60 cases, split across three ordered genotype groups.
| Genotype 1 | Genotype 2 | Genotype 3 | Row total | |
|---|---|---|---|---|
| Controls (row 1) | 20 | 20 | 20 | R1 = 60 |
| Cases (row 2) | 10 | 20 | 30 | R2 = 60 |
| Column total Ci | 30 | 40 | 50 | N = 120 |
We expect cases to become more common from genotype 1 to genotype 3, so we choose the evenly spaced weights t = (0, 1, 2) before looking at any test result.
- T. Each column contributes ti (N1i × 60 − N2i × 60). Column 1: 0 × (1200 − 600) = 0. Column 2: 1 × (1200 − 1200) = 0. Column 3: 2 × (1200 − 1800) = −1200. So T = −1200.
- First variance sum. Σ ti² Ci (N − Ci) = 0 + 1 × 40 × 80 + 4 × 50 × 70 = 3200 + 14000 = 17200.
- Cross-product sum. Σi<j ti tj Ci Cj: only the pair (2, 3) is non-zero, giving 1 × 2 × 40 × 50 = 4000. Twice that is 8000.
- Var(T). (60 × 60 / 120) × (17200 − 8000) = 30 × 9200 = 276000.
- Z. √276000 ≈ 525.36, so Z = −1200 / 525.36 ≈ −2.28. Z² ≈ 5.217 on 1 degree of freedom.
- p-value. Two-sided p ≈ 0.022 (one-sided 0.011, valid only if the direction was fixed in advance).
The negative sign appears because controls were entered as row 1 and the controls are relatively more common in the low-score column. If you enter cases as row 1, Z = +2.28. The proportion of cases rises across the groups: 10/30 = 33.3%, 20/40 = 50.0%, 30/50 = 60.0%.
Cochran-Armitage vs chi-square test
Run Pearson’s chi-square test on the same table and you get χ² = 5.33 on 2 degrees of freedom, p = 0.0695, which misses the 0.05 threshold. The trend test uses the same data but concentrates the evidence into 1 degree of freedom: χ² = 5.22, p = 0.022. The difference between the two (5.33 − 5.22 ≈ 0.12) is the part of the association that is not explained by a linear trend in the scores.
| Pearson chi-square | Cochran-Armitage (0, 1, 2) | |
|---|---|---|
| Question asked | Is the outcome associated with category in any way? | Does the proportion change steadily with the category scores? |
| Degrees of freedom | k − 1 (2 here) | 1 |
| Statistic on the example | 5.33 | 5.22 (Z = −2.28) |
| p-value on the example | 0.0695 | 0.022 |
The trend test has more power than the ordinary chi-square test when the suspected trend is correct, and less sensitivity to patterns you did not anticipate, such as a middle category that differs from both ends. See also the chi-square test guide.
Choosing weights (scores)
The weights encode your hypothesis about the shape of the relationship. They must be specified before you examine the data, and only one set may be used for the test. Choosing the weights after seeing which set gives the smallest p-value invalidates the p-value. The same example table gives different answers under different pre-specified weights:
| Weights (t1, t2, t3) | Hypothesis they express | T | Var(T) | |Z| | Two-sided p |
|---|---|---|---|---|---|
| (0, 1, 2) | Linear trend across evenly spaced categories | −1200 | 276000 | 2.28 | 0.022 |
| (0, 1, 1) | Category 1 differs from categories 2 and 3 | −600 | 81000 | 2.11 | 0.035 |
| (1, 1, 0) | Categories 1 and 2 similar, category 3 differs | 600 | 105000 | 1.85 | 0.064 |
If the direction of the trend was specified in advance, a one-sided p-value is allowed; otherwise report the two-sided value.
Assumptions and common mistakes
- Table shape. One binary variable and one ordered variable (a 2 × k or k × 2 table). An unordered categorical variable (blood group, country) has no meaningful weights.
- Independent observations. Each person or unit appears once.
- Large samples. The normal approximation for Z is stated for large samples.
- Weights chosen after the fact. The most common error; see above.
- Reading a small p-value as proof of linearity. A significant trend means the linear component is detectable, not that the true relationship is a straight line.
Interpreting the result still follows the usual rules for statistical significance: a small p-value speaks to the null hypothesis, not to the size or importance of the effect.
How to interpret the result
| What you see | Reading |
|---|---|
| Small p, weights pre-specified | Evidence that the proportion changes along the chosen score scale. |
| Sign of Z | Direction only, and it depends on which row you called row 1. Check it against the observed proportions in each column. |
| Trend test significant, Pearson chi-square not | A pattern consistent with the pre-specified trend; as in the example above (p = 0.022 versus 0.0695). |
| Trend test not significant | No evidence of a trend with those weights. It does not rule out a non-linear pattern. |
How to report it (APA example)
State the test, the weights and why they were chosen, the statistic and the exact p-value. In APA style, statistical symbols are italicised and p is reported without a leading zero. For the example above:
A Cochran-Armitage test for trend with equally spaced scores (0, 1, 2), specified in advance, indicated that the proportion of cases increased across genotype groups (33.3%, 50.0%, 60.0%), Z = 2.28, p = .022, two-sided.
Report the sign of Z in the direction that matches your description of the data. For more on formatting, see the guides on how to report p-values and writing the results section.
How to calculate it in Excel, R or Python
Excel
Excel has no built-in function for this test, but the formula needs only SUMPRODUCT. Put controls in B2:D2, cases in B3:D3, weights in B4:D4, column totals in B5:D5 (=B2+B3), R1 in F2 (=SUM(B2:D2)), R2 in F3 (=SUM(B3:D3)) and N in F4 (=F2+F3). Then:
T: =F3*SUMPRODUCT(B4:D4,B2:D2)-F2*SUMPRODUCT(B4:D4,B3:D3) Var T: =F2*F3/F4*(F4*SUMPRODUCT(B4:D4,B4:D4,B5:D5)-SUMPRODUCT(B4:D4,B5:D5)^2) Z: =T/SQRT(Var T) p: =2*(1-NORM.S.DIST(ABS(Z),TRUE))
This is the same Var(T) as above, rearranged: N × Σ t²C − (Σ tC)² = 120 × 240 − 140² = 9200, then × 30 = 276000. For other worksheet statistics see Excel statistics functions.
R
The CATT package provides a function for the test; weights (0, 1, 2) are used by default.
library(CATT) tbl = matrix(c(20, 10, 20, 20, 20, 30), nrow = 2) # row 1 = controls, row 2 = cases CATT(table = tbl) # returns Z and p.value; compare |Z| with 2.28 above
Python
from math import sqrt, erfc
controls = [20, 20, 20]
cases = [10, 20, 30]
t = [0, 1, 2]
R1, R2 = sum(controls), sum(cases)
N = R1 + R2
C = [a + b for a, b in zip(controls, cases)]
T = sum(w * (a * R2 - b * R1) for w, a, b in zip(t, controls, cases))
s1 = sum(w**2 * c * (N - c) for w, c in zip(t, C))
s2 = sum(t[i] * t[j] * C[i] * C[j]
for i in range(len(t)) for j in range(i + 1, len(t)))
var_T = R1 * R2 / N * (s1 - 2 * s2)
z = T / sqrt(var_T)
p = erfc(abs(z) / sqrt(2)) # two-sided
print(round(z, 2), round(p, 3)) # -2.28 0.022
FAQ
What does the Cochran-Armitage test tell you?
Whether a binary outcome becomes steadily more or less common across ordered categories, judged against the scores you chose in advance.
When should I use it instead of the chi-square test?
Use it when the categories are ordered and you expect a monotone pattern. It uses 1 degree of freedom instead of k − 1, which gives it more power for that pattern. Use Pearson’s chi-square when the categories are unordered or you have no expected shape.
Which weights should I use?
Evenly spaced scores such as (0, 1, 2) for a suspected linear trend, actual dose values when categories correspond to measured doses, or a grouping such as (0, 1, 1) when you expect the first category to differ from the rest. Fix them before analysis.
Is the test one-sided or two-sided?
Two-sided by default. A one-sided p-value is appropriate only when the direction of the trend was known in advance.
Sources
- Cochran, W. G. (1954). Some methods for strengthening the common chi-squared tests. Biometrics, 10(4), 417-451. doi:10.2307/3001616
- Armitage, P. (1955). Tests for linear trends in proportions and frequencies. Biometrics, 11(3), 375-386. doi:10.2307/3001775
- Agresti, A. (2002). Categorical data analysis (2nd ed.). Wiley.
- Armitage, P., Berry, G., and Matthews, J. N. S. (1994). Statistical methods in medical research (Blackwell Science), section 15.2 (cited in the GenStat documentation below).
- Wikipedia, Cochran-Armitage test for trend (formula, weights, genotype example; checked 2026-10-29). All arithmetic on this page was recomputed independently.
- CRAN, CATT package reference manual (default weights and return values; checked 2026-10-29).
- VSNi, GenStat CATRENDTEST documentation (1 degree of freedom and deviation-from-trend statistic; checked 2026-10-29).








