Statistics & probability

Two way factorial ANOVA calculator with interaction from raw data

Analyze a complete balanced crossed two-factor experiment with replicated observations in every cell.

Your numbers

Each line: integer factor A label, integer factor B label, response. Equal replication in every cell.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Analyze a complete balanced crossed two-factor experiment with replicated observations in every cell. Separate factor, interaction and residual sums of squares and report classical F tests.

THE FORMULASSA=brΣ(Amean−grand)²; SSB=arΣ(Bmean−grand)²; SSAB=rΣ(cell−Amean−Bmean+grand)²; SSE=Σ(y−cell)²; Fterm=(SSterm/dfterm)/(SSE/dfE).

A worked example

Two A levels, three B levels and three replicates per cell give SSA 40.5, SSB 147, SSAB 3 and SSE 12. Error mean square is 1; F statistics are 40.5, 73.5 and 1.5.

Good to know

2–5 integer-coded levels per factor; complete crossed balanced cells with ≥2 independent replicates each, ≤500 total rows, finite responses within ±10⁶ and positive residual variation. Fixed factors, common normal error variance. Classical term-specific F probabilities. No unbalanced/empty-cell convention, random factors, repeated observations, covariates, pairwise post-hoc tests or robust variance.

Cross both factors completely

A two-way factorial design observes every combination of two factor levels. Replication within each combination separates residual noise from interaction. This calculator implements the balanced fixed-effects design, where each cell has the same number of independent observations, rather than selecting an arbitrary sums-of-squares convention for an unbalanced table.

A response can change with factor A, factor B, or with their combination. Interaction means that the difference between levels of one factor depends on the level of the other. Its interpretation is substantive: averaging a strongly varying effect can hide the structure the experiment was designed to reveal.

Cell-mean profiles reveal the factorial interactionCell mean responseFactor B level123121826Blue A=1 · Green A=2
Scroll across to see the full diagram.
The two factor-A profiles are not parallel: their difference grows from two to four response units as factor B increases.

Compare this with the One way ANOVA groups calculator. Separate two categorical factors and their interaction rather than a single grouping effect.

Enter labels and raw responses

Each row contains an integer label for factor A, an integer label for factor B and one numeric response. Labels identify levels without imposing a numerical trend. Coding low, medium and high as 1, 2 and 3 does not turn this calculation into a polynomial regression.

The design supports two through five levels per factor and requires at least two observations in every crossed cell. Duplicate rows can be legitimate repeated response values, but copying an observation is not a new independent replicate. Subsamples from the same experimental unit may need a hierarchical error structure.

Understand the sums-of-squares split

Cell means describe the response at each factor combination. Factor means average cell means over the other factor, and the grand mean averages the complete balanced dataset. The A and B sums of squares measure their marginal departures from the grand mean with the appropriate replication multipliers.

Interaction sums of squares measure the part of each cell mean left after subtracting both factor means and restoring the grand mean. Error sums of squares measure individual deviations from their own cell mean. These four components add to the centered total sum of squares in the balanced design.

Check the supplied experiment

The example has two A levels, three B levels and three replicates per cell, giving eighteen observations. Each cell's residuals are minus one, zero and one, so its residual sum of squares is two. Six cells therefore produce error sum of squares twelve and error degrees of freedom twelve.

The A sum of squares is 40.5, the B sum is 147 and interaction sum is three. With error mean square one, their F statistics are 40.5, 73.5 and 1.5 respectively. The interaction has two numerator degrees of freedom, illustrating why its F is not the raw sum of squares.

Read the table term by term

Each F statistic divides a term's mean square by the common residual mean square. Its numerator degrees of freedom are A levels minus one, B levels minus one, or their product for interaction. Error degrees of freedom equal cells times replicates minus one per cell.

The reported p-values are upper-tail F probabilities under the corresponding null hypotheses and model assumptions. A small main-effect p-value does not show that every pair of factor levels differs. The calculation supplies omnibus tests, so claims about individual comparisons require further planned contrasts or multiplicity-aware follow-up.

Check the experimental errors

Independent errors, common residual variance and approximate normality support the classical finite-sample F reference distributions. A balanced table does not guarantee those assumptions. Inspect how treatments were assigned, whether observations share an experimental unit and whether response spread varies markedly between cells before interpreting the table.

An empty cell or unequal replicate count is rejected. With no replication, residual and interaction cannot be separated by this model. Exactly zero residual variation is also rejected rather than returning infinite F values. Those cases require a reconsidered design or explicitly different modeling assumptions.

Report interaction with the means

The cell-mean matrix is returned with its factor-label order, allowing the interaction pattern to be inspected directly. Crossing or nonparallel mean profiles can be informative even when the interaction test has limited power. Preserve the response's original units when describing differences, alongside the dimensionless F statistics.

This bounded analysis provides no random factors, repeated measures, covariates, missing-cell fit, post-hoc pairwise procedure or robust variance estimate. The result is invariant to row order and consistent relabeling. Adding a constant to every response preserves sums of squares and tests while shifting all displayed means by that constant.

A few questions, answered

Why must every cell have replication?

Replication identifies residual variation separately from A×B interaction. With one response per cell, those components cannot both be estimated in this model.

Can factor labels be arbitrary integers?

Yes. They identify categories, not numerical spacing or polynomial terms. Consistent relabeling preserves the analysis.

What does an interaction test assess?

It tests whether factor effects vary across levels of the other factor under the model. Inspect cell means to understand the pattern and scientific size.

Does a main-effect p-value identify different pairs?

No. It is an omnibus term test. Pairwise or planned contrasts require their own procedures and any appropriate multiplicity adjustment.

Find your calculator

Start typing to explore the library.