How to perform ANOVA

How to perform ANOVA

From Random Model Building to Systematic ANOVA

In our last blog post, we learned what a model is and what it can do for us. We even built one for our filtration rate experiment. But if you’re being honest, the process felt a bit random how we added the model parameters didn’t it?

There’s actually a systematic, statistically rigorous method for building models in DoE, and it’s called ANOVA (Analysis of Variance). ANOVA helps us answer a fundamental question: “Which parameters actually matter, and which ones are just noise?”

Think of ANOVA as your quality control inspector. It looks at every potential parameter—main effects, interactions, quadratic terms—and gives each one a pass/fail grade. Pass means “this parameter is contributing real information to your model.” Fail means “this parameter is just adding complexity without value.”

The Basic Concept of ANOVA

ANOVA works by comparing two types of variation in your data:

Within-group variance: How much do measurements vary when you keep a factor at the same level? This represents your measurement error, experimental noise, and all the uncontrolled factors you can’t account for.

Between-group variance: How much do your measurements change when you actually change your factor level? This represents the real effect of your factors.

If changing a factor creates more variation than your measurement noise, that factor significantly affects your response. If the variation from changing the factor is about the same as your measurement noise, that factor probably isn’t doing much.

Here’s a concrete example from our filtration rate experiment:

between vs. within group variance example

Figure 1: Example of between-group variance and within-group variance

The plot above illustrates the main effect of temperature (left) and pressure (right). Remember, main effects are calculated as averages: all filtration rates measured at the low level (-1) of a factor are averaged, and the same is done for the high level (+1). These averages are then plotted to show the overall effect of increasing the factor.

In other words, the slope of each line tells us: “On average, if we increase temperature (or pressure) from -1 to +1, the filtration rate changes by this much.” Each average, however, comes from a group of individual measurements. ANOVA compares the variation within each group (measurements at the same factor level) to the variation between the group means (the difference from -1 to +1).

When we compare the two plots, the effect of temperature stands out more clearly than that of pressure. Changing the temperature leads to a noticeable shift in the average filtration rate. The spread within each group is noticeable, but it seems that temperature does have a significant effect on filtration rate. For pressure, the variation within groups is much larger than the between-group variation (which is hardly there). Therefore, it seems that the main effect of temperature is significant, while pressure is not.

What Makes a Parameter Significant?

This is the basic concept of ANOVA, but simply looking at the data as we did above can be subjective. You might come to a different conclusion than I did. There has to be a better way, right? Yes!

A parameter is considered statistically significant when the variation it causes in your response is substantially larger than what you’d expect from random noise alone. We quantify this using the so-called p-value.

The p-value tells you the probability that you’d see this large an effect even if the parameter actually had no real impact. Think of it as asking: “If this factor truly doesn’t matter, what’s the chance I’d still see this big a change in my results just by random luck?”

  • Low p-value (typically < 0.05): Very unlikely this effect happened by chance. The parameter is probably significant.
  • High p-value (> 0.05): This effect likely happened by chance and could be easily explained by random variation. The parameter is probably not significant.

The 0.05 threshold means we’re accepting a 5% chance of being wrong—that is, a 5% chance that we’ll conclude a parameter is significant when it actually isn’t. Most of the time, we’re comfortable with this level of risk, but you can be more conservative (use 0.01 for a 1% chance) or more liberal (use 0.10 for a 10% chance) depending on your situation.

Important note: Significant doesn’t always mean relevant. A parameter might have a statistically significant effect but such a tiny practical impact that it’s not worth worrying about. Always consider both statistical significance and practical importance in combination.

How to Perform ANOVA

Choosing the Right Software

First things first: What software do you need to perform ANOVA?

You’ll need some kind of statistics software. There are plenty of choices for all kinds of budgets:

  • Commercial software: JMP, Minitab, Design Expert, and MODDE are industry standards. They’re powerful and offer much more functionality than just ANOVA. The drawback is their cost, which can be worth it but might not fit every budget.
  • Budget-friendly option: I personally like and recommend Datatab for its simplicity and affordability. It handles most DoE analyses without the complexity of bigger packages.
  • Free option: Programming languages like Python or R can handle ANOVA perfectly well. They’re versatile and offer limitless functionality. The only drawback is that you need to be somewhat familiar with programming. But here’s a pro tip: with AI evolving, it’s easier than ever to get started. In fact, you can already do it in tools like ChatGPT without needing to learn a programming language. However, if you want to keep control over your data, I’ve made a tutorial on performing ANOVA with Python here.

No matter which software you choose, the workflow is more or less the same.

The Basic Workflow

  1. Build your initial model: Start with a mathematical model that includes all the parameters you want to test (main effects, interactions, quadratic terms, etc.).
  2. Run the ANOVA: Your software calculates the statistical significance of each parameter and presents the results in an ANOVA table.
  3. Examine the p-values: Look at each parameter’s p-value in the ANOVA table.
  4. Make decisions: Keep parameters with p-values below your significance threshold (typically 0.05), and eliminate those above it.
  5. Repeat if necessary: Remove non-significant parameters and re-run the analysis until all p-values are below your threshold. This is your final model.

This process involves some trial and error, but there are two more systematic approaches I recommend.

Systematic Approaches to Testing Parameters

You have two main approaches for building your model:

Approach 1: Backward Elimination

Start with everything—all main effects, all interactions, even higher-order terms if you have them. Then systematically remove the weakest performers:

  1. Run ANOVA on the full model.
  2. Identify the parameter with the highest p-value (least significant).
  3. Remove that parameter and refit the model.
  4. Repeat until only significant parameters remain.

This approach ensures you don’t accidentally miss important effects. It’s like starting with a fully loaded toolbox and gradually removing the tools you don’t actually need.

Approach 2: Forward Selection

Start with just the main effects, then add parameters you think might be significant:

  1. Begin with a simple model (main effects only).
  2. Test adding remaining parameters individually.
  3. Keep them if they meet your significance criteria; drop them if they don’t.
  4. Repeat until no additional parameters meet your significance criteria.

Visualizing your results often gives you a good idea of which effects and interactions might be significant. Use ANOVA to confirm your intuition.

Example: Filtration Rate Model Building

Let’s apply both approaches to our filtration rate example with Temperature (T), Pressure (P), Formaldehyde concentration (CoF), and Stirring rate (RPM).

Backward Elimination Example

Step 1: Start with the full model including all main effects and interactions:

ANOVA Results (Initial):

SourceDFSum of SquaresMean SquareF-ratiop-value
T118711871247.30.040
P139395.170.264
T:P10.060.060.010.942
CoF139039051.60.088
T:CoF113141314173.80.048
P:CoF122.622.62.980.334
T:P:CoF114.114.11.860.403
RPM1856856113.10.060
T:RPM111061106146.20.053
P:RPM10.560.560.070.830
T:P:RPM168.168.19.000.205
CoF:RPM15.065.060.670.563
T:CoF:RPM~~1 ~~~~10.6 ~~~~10.6 ~~~~1.40 ~~~~0.447 ~~
P:CoF:RPM127.627.63.640.307
Residual17.567.56NaNNaN

If you are not sure about how to read an ANOVA table, take a look at this blog post „ANOVA table explained“

Step 2: Work from the highest order interactions down to the lowest. At each step, remove the term with the highest p-value. In this case, we first remove the three-way interaction T×CoF×RPM since it has the highest p-value out of all the three way interactions. Then refit the model and repeat.

ANOVA Results (2nd step):

SourceDFSum of SquaresMean SquareF-ratiop-value
T118711871206.40.005
P139394.30.174
T:P10.060.060.010.941
CoF139039043.00.023
T:CoF113141314145.00.007
P:CoF122.622.62.50.255
T:P:CoF114.114.11.60.339
RPM185685694.40.010
T:RPM111061106122.00.008
P:RPM10.560.560.060.827
T:P:RPM168.168.17.50.111
CoF:RPM15.065.060.560.533
P:CoF:RPM127.627.63.00.223
Residual218.19.1NaNNaN

Step 3: Continue removing non-significant terms (P, RPM, and other interactions) until only significant parameters are left.

ANOVA Results (final):

SourceDFSum of SquaresMean SquareF-ratiop-value
T11871187195.9< 0.001
CoF139039020.00.001
RPM185685643.8< 0.001
T:CoF11314131467.3< 0.001
T:RPM11106110656.7< 0.001
Residual1019519.5NaNNaN

This is your final model with an R2 of 0.97:

Filtration Rate = 70.1 + 10.8·T + 4.9·CoF + 7.3·RPM − 9.1·(T×CoF) + 8.3·(T×RPM)`

Forward Selection Example

Step 1: Start with main effects only:

ANOVA Results (Initial):

SourceDFSum of SquaresMean SquareF-ratiop-value
T1187118718.00.017
P139390.170.691
CoF13903901.70.223
RPM18568563.70.082
Residual112576234NaNNaN

Step 2: Test adding interactions. Start with those that the visualization suggested that are significant. In this case that was T×CoF and TxRPM.

ANOVA Results (2nd step):

SourceDFSum of SquaresMean SquareF-ratiop-value
T118711871107.9< 0.001
P139392.30.168
CoF139039022.50.001
RPM185685649.3< 0.001
T:CoF11314131475.8< 0.001
T:RPM11106110663.8< 0.001
Residual915617.3NaNNaN

Step 3: Add other interactions that you think could be significant. For example also the three way interaction between TxCoFxRPM.

ANOVA Results (3rd step):

SourceDFSum of SquaresMean SquareF-ratiop-value
T118711871102.8< 0.001
P139392.10.181
CoF139039021.40.00169
RPM185685647.0< 0.001
T:CoF11314131472.3< 0.001
T:RPM11106110660.8< 0.001
T:CoF:RPM110.610.60.60.468
Residual8145.518.2NaNNaN

But as we see, we find no other significant interactions and we can even remove the main effect of pressure as it also has a p-value that is higher than our threshold. So we conclude the final model is the same as with the backward elimination approach:

Filtration Rate = 70.1 + 10.8·T + 4.9·CoF + 7.3·RPM − 9.1·(T×CoF) + 8.3·(T×RPM)

The Final Model: Summary and Conclusion

Our final model gives us a clean, statistically justified equation for predicting filtration rate. Every parameter in the model has earned its place through rigorous statistical testing.

Let’s compare how well our streamlined model performs against a model that includes all the original parameters:

Statistical Model (only significant parameters):

Filtration Rate = 70.1 + 10.8·T + 4.9·CoF + 7.3·RPM − 9.1·(T×CoF) + 8.3·(T×RPM)

Full Model (all parameters):

Filtration Rate = 70.1 + 10.8·T + 1.6·P + 0.1·(T×P) + 4.9·CoF − 9.1·(T×CoF) + 1.2·(P×CoF) + 0.9·(T×P×CoF) + 7.3·RPM + 8.3·(T×RPM) − 0.2·(P×RPM)

TPCoFRPMMeasuredFull modelOnly significant params
-1-1-1-1454446
1-1-1-1717267
-11-1-1484949
11-1-1656470
-1-11-1686972
1-11-1605960
-111-1807975
111-1656664
-1-1-11434442
1-1-1110099100
-11-11454445
11-11104105103
-1-111757472
1-111868790
-1111707175
1111969593

The full model provides slightly more accurate predictions, but it’s likely not general and risks overfitting. It might perform worse on new data.

A Critical Caveat: ANOVA Assumptions

Before you rush to apply these steps to your dataset, there’s an important disclaimer: ANOVA only gives reliable results when certain assumptions are met. These assumptions are the foundation of the entire statistical analysis. If they’re violated, your p-values and conclusions can be wrong.

These assumptions are:

  • Normality: Your residuals (prediction errors) should follow a normal distribution.
  • Independence: Each measurement should be independent of the others.
  • Equal variance: The scatter in your data should be consistent across all conditions.

Getting these assumptions right is just as important as running ANOVA itself. Therefore we cover them thoroughly in the next blog post.

Up next:

<< Testing ANOVA Assumptions>>

<< How to Perform ANOVA with Python >>