ExamSaathi learning library · Government exams · SSC CGL quantitative foundations; published syllabus labelled 2024 · Quantitative aptitude

Two-way analysis of variance: row, column and error sums of squares

Analyse a two-way table with one value in each cell, such as fertilisers tried on several blocks of land: split the total sum of squares into row, column and error parts, then test both factors with two F ratios.

Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.

You will learn to

Before you start

Two-way classified data are sorted by two factors at once. The layout here has r rows and c columns with exactly one value in each cell, so N = r x c. The columns are often treatments, such as fertilisers or machines, and the rows are blocks, such as strips of land, days or workers, that may differ among themselves. This lesson builds on the one-way lesson and reuses its correction factor without deriving it again. Write R for a row total, C for a column total and G for the grand total. The letter x stands only for multiplication. Two null hypotheses are tested side by side: the row means are all equal, and the column means are all equal. The data here are made up for practice.

Splitting the total into rows, columns and error

The total variation of the N values splits into three parts: one due to the rows, one due to the columns, and a residual that neither factor explains. Start with CF = G^2 / N and total SS = (sum of the squares of all N values) - CF, where SS means sum of squares. A row total adds up c values, so row SS = (sum of R^2) / c - CF. A column total adds up r values, so column SS = (sum of C^2) / r - CF. The error, or residual, SS is whatever remains: error SS = total SS - row SS - column SS. Mind the divisors. Each squared total is divided by the number of values that went into it, which is c for a row total and r for a column total, and swapping the two is a frequent slip. All four sums of squares must come out zero or positive.

The two-way table and the two F ratios

Degrees of freedom: rows r - 1, columns c - 1, error (r - 1)(c - 1), total rc - 1. As a check, (r - 1) + (c - 1) + (r - 1)(c - 1) = rc - 1. Divide each sum of squares by its degrees of freedom to get the row, column and error mean squares (MS). Both factors are judged against the same yardstick, the error mean square. F for rows = row MS / error MS, with (r - 1, (r - 1)(c - 1)) degrees of freedom, and F for columns = column MS / error MS, with (c - 1, (r - 1)(c - 1)) degrees of freedom. Set the table out in four lines. Rows: SS, df, MS, F. Columns: SS, df, MS, F. Error: SS, df, MS. Total: SS, df. Each F is compared with its own stated upper critical value, so one factor can be significant while the other is not. Give each decision in words: reject H0 or do not reject H0 for the rows, and the same for the columns.

Why blocks help, and what the method assumes

Suppose one block of land has richer soil. A one-way analysis of the fertiliser columns would leave that block-to-block difference inside the error, so the error mean square would be large and the fertiliser F small. The two-way analysis lifts the row SS out of the error. The residual left behind is smaller; if row and column effects simply add, it measures chance error alone, so its mean square shrinks and the treatment F grows, so a real difference among treatments is easier to detect. The price is r - 1 error degrees of freedom; if the blocks do not really differ, little is gained. The method assumes that the values are independent, that the chance errors are normal with the same variance in every cell, and that row and column effects simply add. With one value per cell, the residual is the only measure of chance error, so an interaction, such as a fertiliser that suits only one kind of soil, cannot be separated from it, so the table has no interaction line and no interaction F. Testing an interaction needs at least two values in each cell.

Common mistakes

Dividing the sum of squared row totals by r, or the squared column totals by c; each total is divided by the number of values it contains. Leaving CF out of the row or column sum of squares. Taking the error degrees of freedom as N - c, r + c - 2 or rc - 1 instead of (r - 1)(c - 1). Testing the rows against the column mean square, or the columns against the row mean square; both F ratios have the error mean square underneath. Reading a critical value with its degrees of freedom in the wrong order, or with the total degrees of freedom. Expecting an interaction line when each cell holds one value. Letting a negative error SS pass instead of rechecking the arithmetic. Calling a factor significant without quoting the critical value and the decision.

A routine for a two-way table

1. Count r and c, and check that each cell holds exactly one value. 2. If the numbers are large, take a convenient constant off every value; no sum of squares changes. 3. Find the row totals, the column totals, G and CF = G^2 / N. 4. Total SS from the squares of all the values. 5. Row SS = (sum of R^2) / c - CF and column SS = (sum of C^2) / r - CF. 6. Error SS by subtraction. 7. Degrees of freedom r - 1, c - 1, (r - 1)(c - 1) and rc - 1, then the mean squares. 8. Two F ratios, each with the error mean square underneath. 9. Compare each with its stated critical value and write both decisions in words.

Worked examples

  1. Three fertilisers P, Q and R were each tried once on each of 4 blocks of land near Meerut. Yields in kg per plot: block 1: P 5, Q 6, R 7; block 2: P 12, Q 13, R 14; block 3: P 6, Q 8, R 10; block 4: P 5, Q 9, R 13. Test at the 5 percent level whether the fertilisers differ and whether the blocks differ. The 5 percent points are F(2, 6) = 5.14 and F(3, 6) = 4.76.

    1. Rows are blocks (r = 4) and columns are fertilisers (c = 3), so N = 12. Row totals: 18, 39, 24, 27. Column totals: P 28, Q 36, R 44. G = 108 and CF = 108^2 / 12 = 11664 / 12 = 972.
    2. Squares of the 12 values, block by block: 110, 509, 200 and 275, which add up to 1094. Total SS = 1094 - 972 = 122.
    3. Row SS = (18^2 + 39^2 + 24^2 + 27^2) / 3 - 972 = 3150 / 3 - 972 = 1050 - 972 = 78.
    4. Column SS = (28^2 + 36^2 + 44^2) / 4 - 972 = 4016 / 4 - 972 = 1004 - 972 = 32.
    5. Error SS = 122 - 78 - 32 = 12, with (4 - 1)(3 - 1) = 6 degrees of freedom, so error MS = 12 / 6 = 2.
    6. Rows (blocks): SS 78, df 3, MS 26, F = 26 / 2 = 13. Columns (fertilisers): SS 32, df 2, MS 16, F = 16 / 2 = 8. Error: SS 12, df 6, MS 2. Total: SS 122, df 11.

    Answer: Fertilisers: F = 8, above 5.14, so reject H0; the fertilisers differ in mean yield. Blocks: F = 13, above 4.76, so reject H0; the blocks differ too.

  2. Analyse the yields of Example 1 again, but this time ignore the blocks and treat the 12 values as three fertiliser groups of 4. Compare the fertiliser F with the two-way result. The 5 percent point of F(2, 9) is 4.26.

    1. With no block line, the block SS of 78 stays inside the error: error SS = 78 + 12 = 90, with 3 + 6 = 9 degrees of freedom.
    2. Error MS = 90 / 9 = 10, while the fertiliser MS is still 32 / 2 = 16.
    3. F = 16 / 10 = 1.6, which is below 4.26, so this analysis would not reject H0.
    4. In the two-way analysis the block variation was taken out, the error MS fell from 10 to 2, and F rose from 1.6 to 8.

    Answer: Ignoring the blocks gives F = 1.6 (do not reject H0), against F = 8 (reject H0) in the two-way analysis: removing the block variation made the fertiliser test far sharper.

  3. Units made in a day by three workers on three knitting machines at a unit in Tiruppur: worker A: M1 32, M2 35, M3 31; worker B: M1 29, M2 36, M3 30; worker C: M1 34, M2 36, M3 34. Subtract 30 from every value and test, at the 5 percent level, whether the workers differ and whether the machines differ. The 5 percent point of F(2, 4) is 6.94.

    1. Coded values: A 2, 5, 1 (row total 8); B -1, 6, 0 (row total 5); C 4, 6, 4 (row total 14). Column totals: M1 5, M2 17, M3 5. G = 27, N = 9 and CF = 27^2 / 9 = 81.
    2. Squares of the coded values, row by row: 30 + 37 + 68 = 135, so total SS = 135 - 81 = 54.
    3. Row (worker) SS = (8^2 + 5^2 + 14^2) / 3 - 81 = 285 / 3 - 81 = 95 - 81 = 14. Column (machine) SS = (5^2 + 17^2 + 5^2) / 3 - 81 = 339 / 3 - 81 = 113 - 81 = 32.
    4. Error SS = 54 - 14 - 32 = 8, with (3 - 1)(3 - 1) = 4 degrees of freedom, so error MS = 8 / 4 = 2.
    5. Workers: SS 14, df 2, MS 7, F = 7 / 2 = 3.5. Machines: SS 32, df 2, MS 16, F = 16 / 2 = 8. Error: SS 8, df 4, MS 2. Total: SS 54, df 8.

    Answer: Machines: F = 8, above 6.94, so reject H0; the machines differ in mean output. Workers: F = 3.5, below 6.94, so do not reject H0; there is no evidence that the workers differ.

Practice checks

  1. A two-way table records ticket sales at 4 counters (columns) of a railway station in Chennai on 5 days (rows), with one value per cell. How many degrees of freedom does the error line have?
  2. In a two-way table with 4 rows and 3 columns, one value per cell, the column totals are 30, 36 and 42 and the grand total is 108. What is the column sum of squares?
  3. Trial plots near Nashik give a two-way table with 4 blocks as rows and 3 onion varieties as columns, one value per cell. The row SS is 45 and the error SS is 15. The 5 percent points are F(3, 6) = 4.76 and F(6, 3) = 8.94. Which is the correct test of the blocks?
  4. A two-way table with 3 rows and 5 columns, one value per cell, gives total SS = 120, row SS = 54 and column SS = 40. What is the error mean square?
  5. Why does a two-way analysis with only one value in each cell give no F test for interaction between the two factors?

Sources checked