Skip to content
Celeus

Two-way ANOVA (factorial)

Shown in the app as two_way_anova. Part of the method reference, under Comparing groups.

When to use

A continuous outcome and TWO categorical factors (2+ levels each): tests each factor's main effect and whether the two factors INTERACT (whether one factor's effect on the outcome depends on the level of the other).

What you provide

  • Outcome: one numeric column.
  • The two factors: two categorical columns.

Options

Missing data

  • Complete case (listwise deletion)

Multiple comparisons

  • Not adjustable for this method. Where it makes post-hoc comparisons, the procedure applies its own correction.

Confidence level

Every interval in the result is reported at the level you choose:

  • 90%
  • 95%
  • 99%

Other methods under Comparing groups:

Guides that discuss this method

How to read the output

Two-way ANOVA compares a numeric outcome across the combinations of two categorical factors, for example plant height under three fertilisers and two watering schedules, or the number of yarn breaks by wool type and loom tension. Each factor needs at least two levels, and only rows with a value for the outcome and both factors are used.

The interaction test. The headline result is the test of the interaction: does the effect of one factor on the outcome depend on the level of the other? It is an F-test with two degrees-of-freedom values (numerator and denominator), and it has no single point estimate or confidence interval. The effect size is partial eta-squared for the interaction, from 0 to 1: the interaction’s sum of squares as a proportion of itself plus the residual sum of squares.

Main effects. The test for each factor on its own is part of the same ANOVA table, which the reproducible R script prints in full, but it is not the headline. These tests use Type II sums of squares: each factor is adjusted for the other factor but tested without the interaction term. When the interaction is substantial, a main effect averages over effects that differ from one level of the other factor to the next, so it is hard to interpret. Celeus does not warn about this, so read the interaction first. Langsrud (2003) sets out why Type II rather than Type III tests suit unbalanced designs.

Cell means. The table of results lists the estimated mean outcome, with its confidence interval, for every combination of the two factors. These are the means themselves, not differences between them, so they show the pattern the interaction test is about.

Checks and limits. Celeus checks the normality of the residuals (Shapiro-Wilk), equal variance across the cells (Levene’s test, in the median-centred form of Brown and Forsythe), and warns when there are fewer than 10 observations. It does not run a post hoc test or adjust p-values for multiple comparisons after a two-way ANOVA. If you compare individual cells or factor levels yourself, treat them as a family of tests; see multiple comparisons.

Sources: Fisher RA (1925), Statistical Methods for Research Workers, Oliver and Boyd. Langsrud O (2003), Statistics and Computing 13(2):163-167, doi:10.1023/A:1023260610025. Brown MB, Forsythe AB (1974), Journal of the American Statistical Association 69(346):364-367, doi:10.1080/01621459.1974.10482955.

Worked examples

Celeus's result on a published or illustrative dataset, next to an independent computation and, where one exists, a published value. The data themselves are not reproduced here.

datasets::warpbreaks

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Tippett (1950), Technological Applications of Statistics
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic4.189074.18907-Yes
Degrees of freedom2,482,48-Yes
p-value0.02104420.0210442-Yes
Test statistic for each model term3.76529, 8.49805, 4.189073.76529, 8.49805, 4.18907-Yes
p-value for each model term0.058213000, 0.000692621, 0.0210442000.058213000, 0.000692621, 0.021044200-Yes
Partial eta-squared for each model term0.0727377, 0.2614940, 0.14860600.0727377, 0.2614940, 0.1486060-Yes
Effect size confidence interval0.00214424, 0.323609000.00214424, 0.32360900-Yes

datasets::ToothGrowth (dose stored as the numbers 0.5, 1, 2)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Crampton (1947), Journal of Nutrition 33(5):491-504 (the data); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic4.106994.10699-Yes
Degrees of freedom2,542,54-Yes
p-value0.02186030.0218603-Yes
Test statistic for each model term15.57200, 92.00000, 4.1069915.57200, 92.00000, 4.10699-Yes
p-value for each model term2.31183e-04, 4.04629e-18, 2.18603e-022.31183e-04, 4.04629e-18, 2.18603e-02-Yes
Partial eta-squared for each model term0.223825, 0.773109, 0.1320280.223825, 0.773109, 0.132028-Yes
Effect size confidence interval0.00146557, 0.294972000.00146556, 0.29497200-Yes

datasets::warpbreaks (tension L and H, first four looms per wool x tension cell)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Tippett (1950), Technological Applications of Statistics (the data); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic0.6861570.686157-Yes
Degrees of freedom1,121,12-Yes
p-value0.4236440.423644-Yes
Test statistic for each model term3.238240, 1.508570, 0.6861573.238240, 1.508570, 0.686157-Yes
p-value for each model term0.0971136, 0.2429030, 0.42364400.0971136, 0.2429030, 0.4236440-Yes
Partial eta-squared for each model term0.2125070, 0.1116750, 0.05408710.2125070, 0.1116750, 0.0540871-Yes
Effect size confidence interval0.00000, 0.394430.00000, 0.39443-Yes

datasets::warpbreaks without rows 1, 2, 3, 20 and 40 (unbalanced cells)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Tippett (1950), Technological Applications of Statistics (the data); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic6.182336.18233-Yes
Degrees of freedom2,432,43-Yes
p-value0.004365850.00436585-Yes
Test statistic for each model term3.87832, 8.25136, 6.182333.87832, 8.25136, 6.18233-Yes
p-value for each model term0.055378100, 0.000926896, 0.0043658500.055378100, 0.000926896, 0.004365850-Yes
Partial eta-squared for each model term0.0827317, 0.2773440, 0.22333100.0827317, 0.2773440, 0.2233310-Yes
Effect size confidence interval0.0504248, 0.38064000.0504248, 0.3806400-Yes
Confidence level of the effect size interval0.90.9-Yes

datasets::warpbreaks with the outcome removed on rows 5, 23 and 41

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Tippett (1950), Technological Applications of Statistics (the data); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic2.939582.93958-Yes
Degrees of freedom2,452,45-Yes
p-value0.06311480.0631148-Yes
Test statistic for each model term4.05590, 6.48209, 2.939584.05590, 6.48209, 2.93958-Yes
p-value for each model term0.05001940, 0.00335883, 0.063114800.05001940, 0.00335883, 0.06311480-Yes
Partial eta-squared for each model term0.0826791, 0.2236590, 0.11555200.0826791, 0.2236590, 0.1155520-Yes
Effect size confidence interval0.000000, 0.2894670.000000, 0.289467-Yes
Number of observations5151-Yes

Validation report

References

  1. Fisher, R. A. (1925). Statistical Methods for Research Workers. Oliver and Boyd, Edinburgh.