Two-Way ANOVA

Test whether two factors such as temperature and pressure, or material and process, affect the response on their own and together. The main effects and interaction plots show at a glance which levels are best and whether the two factors interact.

1Data Table

Paste a table copied from Excel into a cell (Ctrl+V). Click a column header (A, B…) before pasting to use the first line as column names. Double-click a header to rename it, right-click to insert/delete rows and columns, and formulas such as =A1*2 work too.

2Two-Way ANOVA Options

(Sum of squares: Type II - a stable default even for unbalanced designs)

※ The post hoc test compares factor 1 × factor 2 combinations (cells).

How to run a two-way ANOVA

  1. Copy the factor 1 column, factor 2 column and measurement column together with the header (one measurement per row).
  2. Select the response column and two different factor columns. The interaction is included by default; choose a post hoc test by combination (cell) if needed.
  3. Press Analyze and check the p-value of each term in the ANOVA table and the interaction plot.

Worked example with sample data

The sample data are 24 tensile strength measurements (MPa): 4 for each combination of 3 temperatures (180, 200, 220°C) and 2 pressures (1.0, 1.5 MPa), in shuffled row order.

Interaction plot (one line per pressure) from the two-way ANOVA of tensile strength by temperature and pressure
Interaction plot (one line per pressure) from the two-way ANOVA of tensile strength by temperature and pressure

In the ANOVA table, temperature has F = 20.82, p = 2.08e-05 (η² = 0.6982) and pressure F = 5.72, p = 0.02791 (η² = 0.2411), so both are significant. 220°C (309.4) is the highest temperature level and 180°C (301.8) the lowest, and 1.5 MPa (308.2) is higher than 1.0 MPa (305.5).

The temperature × pressure interaction has p = 0.5356 and is not significant. In the interaction plot the lines for the two pressures move in almost the same way, showing that the effect of pressure is similar regardless of temperature.

With no interaction, each factor can be read on its own, and 220°C with 1.5 MPa favors strength. The difference between 200°C (309.3) and 220°C (309.4) is small, though, so 200°C is also a candidate once energy cost is considered.

How it is calculated

The linear model y ~ factor 1 * factor 2 is fitted and each term is tested with Type II sums of squares. Type II measures each factor after adjusting for the other, so it stays stable in unbalanced designs where the cells have different numbers of replicates.

The effect size η² is the term's SS / (term's SS + residual SS).

Main effects and interaction plots

The main effects plot draws the level means of factor 1 (bottom axis, blue) and factor 2 (top axis, orange) on one chart. The interaction plot draws the mean change across factor 1 for each level of factor 2: parallel lines mean no interaction, crossing or diverging lines mean an interaction.

What the result shows

Descriptive statistics by combination, the ANOVA table, the main effects plot, the interaction plot, a box plot by combination, means with confidence intervals by combination, residuals vs fitted values and a post hoc test by combination.

How to read the two-way ANOVA result

  • Look at the interaction p-value first. If the interaction is significant, the effect of one factor depends on the level of the other, so judge by combination in the interaction plot rather than by the main effects alone.
  • If the interaction is not significant, judge by the main effect p-values and the highest/lowest levels given by the interpretation.
  • If the residuals in the residuals vs fitted plot are spread evenly around 0, the model assumptions look fine.

Frequently asked questions

Is it the same as Excel's ANOVA: Two-Factor With Replication?

For balanced designs with the same number of replicates in every cell, yes. Excel does not support unbalanced designs; here they are calculated with Type II.

What if there is only one measurement per cell?

With one measurement per cell the interaction cannot be separated from the error, so uncheck the interaction.

Can a factor be numeric (temperature values)?

Yes. The values are treated as categories (levels) and the level means are compared.

Other chart tools