Introduction
Hello! In our previous lesson, we explored the Cochran-Armitage (C-A) test, a powerful tool for detecting trends in proportions when you have one ordinal variable and one binary variable (a 2×k table). You learned that by focusing on a specific linear trend, it gains statistical power over the general chi-square test of independence.
But what happens when both of your variables are ordinal? For example, imagine studying the relationship between self-reported happiness (e.g., 'Not too happy', 'Pretty happy', 'Very happy') and job satisfaction ('Disagree', 'Neutral', 'Agree'). The C-A test doesn't apply here because neither variable is binary.
This lesson addresses that exact scenario. We will explore the linear-by-linear association test, which is the logical extension of our trend analysis to ordinal-by-ordinal contingency tables. By the end of this lesson, you will understand its underlying logic, how it is applied, and why it is often the most appropriate test for this type of data.
1. The Core Idea: Scoring Both Variables
The logic behind the linear-by-linear association test is a direct extension of what you saw with the Cochran-Armitage test. The key steps are:
- Assign Scores: We assign a numerical score to the categories of the first ordinal variable (let's call these scores ).
- Assign Scores Again: We do the same for the categories of the second ordinal variable (scores ).
- Calculate Correlation: With two sets of numerical scores, we can now treat the data as if it were quantitative and calculate a standard Pearson's correlation coefficient, .
This correlation coefficient, , measures the strength and direction of the linear relationship between the two sets of scores.
- An value close to +1 suggests a strong positive trend (as one variable increases, the other tends to increase).
- An value close to -1 suggests a strong negative trend.
- An value close to 0 suggests no linear trend.
The following reading explains this foundational concept of assigning scores to ordinal variables to enable the calculation of a correlation.
4 Tests for Ordinal Data and Small Samples
Please read the following section from the Penn State online notes. It will walk you through the concept of assigning scores to ordinal data to calculate a correlation, which is the foundation of the linear-by-linear association test.
Read the section titled '4.3 Measures of Linear Trend'. Focus on the main idea: how assigning quantitative scores (like simple ranks 1, 2, 3...) to ordered categories allows us to calculate Pearson's correlation coefficient, r. Note the formula for r in the context of a contingency table.
As the reading highlights, the choice of scores is a key step. The simplest choice is often equally spaced integers (e.g., 1, 2, 3), but other methods like midranks (which account for the number of observations in each category) also exist. For now, the crucial takeaway is that we can create a single number, , that summarizes the linear trend in an ordinal-by-ordinal table.
2. The Linear-by-Linear Association Test
The linear-by-linear association test simply asks: is the correlation () we just calculated statistically significant? In other words, is it far enough from zero that we can be confident the trend we're seeing isn't just due to random chance?
The hypotheses are:
- Null Hypothesis (): There is no linear association between the two variables ().
- Alternative Hypothesis (): There is a linear association between the two variables ().
To test this, we use a statistic, often denoted as , which is directly related to the correlation and the sample size :
This statistic has some very important properties:
- It follows a chi-square distribution with 1 degree of freedom.
- This single degree of freedom gives it more statistical power to detect a linear trend compared to the Pearson chi-square test, which has degrees of freedom.
- Like the C-A test, it will have low power to detect non-linear (e.g., U-shaped) associations.
The next reading formalizes this test, which it calls the Mantel-Haenszel test for linear trend, and explains its power advantage.
4 Tests for Ordinal Data and Small Samples
This next section formally introduces the test statistic and its properties. Pay close attention to the comparison with the standard Pearson chi-square test.
Read the section titled '4.4 Mantel-Haenszel Test for Linear Trend'. Focus on understanding the M-squared statistic, its chi-square distribution with 1 df, and the comparison of power versus the Pearson test. The examples at the end showing when the test is powerful (monotonic trend) versus when it is not (U-shaped trend) are very important for your functional understanding.
3. Application and Interpretation
Let's see how this works in practice. The following resource provides an excellent, clear example of applying the linear-by-linear test to a table where both 'Size' of a farm and 'Adoption' of a practice are ordinal variables.
Association Tests for Ordinal Tables - R Handbook
This guide from the R Companion handbook provides a practical walkthrough of conducting and interpreting a linear-by-linear test.
Read the introductory section 'Ordinal × ordinal tables' and then the detailed section 'Example of linear-by-linear test'. Notice how the linear-by-linear test gives a very small p-value (0.0008761), indicating a significant association, while the standard chi-square test on the same data gives a non-significant p-value (0.09593). This is a perfect demonstration of the power advantage.
As you saw in the reading, the interpretation is straightforward:
- Check for Significance: Look at the p-value for the linear-by-linear test. If it is below your significance level (e.g., p < 0.05), you conclude there is a significant linear association.
- Determine the Direction: The test statistic () is always positive. To find the direction of the trend (positive or negative), you need to look at either the sign of the underlying correlation (if provided by the software) or simply inspect the contingency table. In the example from the reading, as farm size increases, the adoption level moves from "Never" towards "Always," indicating a positive association (or negative, depending on how you code the levels).
The output from statistical software like SPSS often presents this test alongside the standard chi-square tests, making the comparison easy.

Conclusion
In this lesson, you have added a crucial tool to your categorical analysis toolkit. You've seen how to handle situations where both of your categorical variables have a natural order.
Key Takeaways:
- Application: The linear-by-linear association test is used for ordinal-by-ordinal contingency tables to check for a monotonic trend.
- Mechanism: It works by assigning numerical scores to the categories of both variables, calculating the Pearson correlation , and then testing if this correlation is significantly different from zero.
- Test Statistic: The test statistic, , follows a chi-square distribution with 1 degree of freedom.
- Power: This focus on a single degree of freedom makes the test more powerful than the general Pearson chi-square test for detecting linear trends.
- Interpretation: A significant result indicates a linear association. You must inspect the data or the correlation coefficient to determine the trend's direction (positive or negative).
Preview of the Next Lesson:
You have now learned the theory behind two essential trend tests: the Cochran-Armitage test (for ordinal-by-nominal tables) and the linear-by-linear association test (for ordinal-by-ordinal tables). In the next lesson, we will have a practical session where you will apply both of these tests to datasets to solidify your understanding and practice interpreting the results.