How to use the two-way anova calculator
- Enter one measurement per line as level of A, level of B, value, separated by commas.
- Make sure every combination of levels has the same number of values, at least 2.
- Read the p value of the interaction first, then the p values for factor A and factor B.
- Use the cell means table to see which combinations drive the result.
Formula
SS(A) = b r x sum of (mean of A level - grand mean)^2
SS(B) = a r x sum of (mean of B level - grand mean)^2
SS(AB) = r x sum of (cell mean - A mean - B mean + grand mean)^2
SS(error) = sum of (value - its cell mean)^2
F = mean square / MSE, with df: A a - 1, B b - 1, AB (a - 1)(b - 1), error a b (r - 1)
a and b are the numbers of levels and r the values per cell. p values come from the F distribution. Eta squared is each sum of squares divided by the total.
Two factors with three measurements per cell
Factor A has levels Low and High, factor B has levels X and Y, and each cell holds 3 values. Cell means are Low/X 4.7, Low/Y 6.1, High/X 7.3 and High/Y 6.1333. The grand mean is 6.0583.
The sums of squares are A 5.2008, B 0.0408, interaction 4.9408 and error 1.4267 with 8 degrees of freedom, so MSE = 0.1783. The F ratios are 29.1636 for A (p = 0.0006), 0.2290 for B (p = 0.6451) and 27.7056 for the interaction (p = 0.0008).
Reading an interaction
A two-way ANOVA splits the variation in the data into what comes from factor A, from factor B, from their combination and from random scatter inside the cells. The interaction asks whether the effect of one factor depends on the level of the other. In the example, B hardly matters on average, yet the interaction is large: Y raises the value at Low but not at High.
When the interaction is clear, the main effects can be misleading on their own, so compare the cell means. Plotting the cell means with one line per level of A makes the pattern visible: lines that cross or fan out indicate an interaction.
Balanced designs only
This page requires the same number of values in every cell. That keeps the three effects separate, so the order in which effects are tested does not change the answer. If your cells have unequal sizes, software must choose a type of sum of squares, and that choice changes the results, so unbalanced data are rejected here instead of being handled silently.
For a single factor use the one-way ANOVA. For ranked data with several groups see the Kruskal-Wallis test. To follow a significant result with a plan for several comparisons, the multiple comparison p adjuster helps.
Assumptions and limits
- Values in a cell are independent, and each measurement appears on one line only.
- Within every cell the values are roughly bell shaped, and the spread is similar across cells.
- The design is balanced: equal values per cell, with at least 2 per cell and every combination present.
- Factor levels are fixed choices, not random draws; mixed or random-effects models are not covered.
Frequently asked questions
Why does the page refuse unequal cell sizes?
With unequal cells the effects overlap, and different software defaults give different sums of squares. Rather than pick one without telling you, the page asks for a balanced table where the answer is unambiguous.
What if the interaction is significant but a main effect is not?
It means the factor has opposite or unequal effects at different levels of the other factor that cancel out on average, as with factor B in the example. Look at the cell means and discuss the effect level by level.
What does eta squared show here?
It is each effect's sum of squares divided by the total sum of squares, so it is the share of all variation attributed to that effect in this sample. The shares for A, B, the interaction and error add up to 1.
How many values per cell do I need?
At least 2, so the error can be estimated. More values per cell make the F tests more sensitive; with only 2 the error has few degrees of freedom and the p values are rough guides.