+34 616 71 29 85 carsten@dataz4s.com

Two-way ANOVA

Two-way ANOVA explores if the means of two different factors are all equal. We wish to determine if Factor A or Factor B or both Factor A and Factor B have significant effect on the scores.


One-way ANOVA vs. Two-way ANOVA

In one-way ANOVA we only analyze for only one factor. In the example below, this factor has 3 levels (0mg, 50mg, 100mg).

In two-way ANOVA one more factor is added. In this example, this factor has 2 levels (Women, Men).

One-way ANOVA vs Two-way ANOVA tables


Factor A and Factor B can also be seen labeled:

  • ‘Factor 1’ and ‘Factor 2’
  • ‘Rows’ and ‘Columns’
  • ‘Sample’ and ‘Columns’

In two-way ANOVA we wish to determine if Factor A or Factor B or both Factor A and Factor B have significant effect on the scores. So, this leads to three null hypotheses.


How to interpret the null hypotheses?

In two-way ANOVA we make inference on the effect of three factor combinations: Factor A, Factor B and the interaction of Factor A and Factor B, so A, B and AB. Therefore, we have three sets of hypotheses:

3 sets of hypotheses in two-way ANOVA



If, for example, we reject all three null hypotheses, we would say:


The H0 for Factor a, rows: Gender

There is sufficient evidence that Factor A (gender) does have significant effect on the scores

The H0 for Factor b, columns, Dosages

There is sufficient evidence that Factor B (dosage) does have significant effect on the scores

The H0 for Interaction (Factor a & b):

There is sufficient evidence that the interaction between Factor A and Factor B (gender and dosage) does have significant effect on the scores.


Below, I we will do a practical example.


The 2-way ANOVA table

The two-way ANOVA table summarizes the values needed for our hypothesis tests:

Two-way ANOVA table

The F-crit is the critical value of the F-table and the F-score is our test statistic. As we know it from other test statistic inferences, we reject the null hypothesis when our test statistic falls beyond the critical value.



  • Normally distributed: Samples are drawn from populations that are normally or approximately normally distributed
  • Independence: The samples must be independent
  • Equal variances: The population variances must be equal
  • Same n: The groups must have the same sample size


The story

In the following we will run through the calculations for each of the values in the table using a fictive example:

Statisticians in a researchers’ group are to make a test for a new medication. They measure the relevant levels in 18 participants on 0mg, 50mg and 100mg dosages. Apart from the effect of the different dosages, the researchers also wish to know if the medication has different effects on gender. Consequently, they divide data as per gender (Factor A) and dosage (Factor B). The effect is measured as to a rating scale of 1-10, being the 10 maximum effect.


Calculations of Sum of Squares (SS)

Statistical software returns the two-way ANOVA table without having to do any calculations and knowing how to interpret the table we can make the inferences. But understanding the values and the calculations can contribute to a deeper understanding of the procedure. So, let’s go through it:

Different procedures and notations

In ANOVA there are different notations and different procedures to calculate the values. I will be following this procedure:

  • Define hypotheses and alpha
  • Calculate test statistics:
    • Step 1): Sample data
    • Step 2): Means table for SS Factor A
    • Step 3): SS Factor B
    • Step 4): SS Both. Interaction
    • Step 5): SS Total
    • Step 6): SS Error. Within
    • Step 7): MS, F-values, critical values
  • State results
  • State conclusions



Calculation of test statistics

Above, we defined our three hypotheses and we displayed sample data, so next step is to calculate test statistics. I find it helpful to see the formulas and calculations together with the different tables:


Step 1: Sample data

We start off by displaying sample data:

Two-way ANOVA data set for analysis


Step 2: Means table for Sum of Squares, Factor A (rows)

We calculate the sum of squares for factor A (SSA), with a means table:

Means table for sum of squares rows


Step 3: Sum of Squares, Factor B (columns)

Sum of Squares Columns


Step 4: Sum of Squares, Both. Interaction

Sum of Squares_ both. interaction


Step 5: Sum of Squares total

Sum of Squares total


Step 6: Sum of Squares Error. Within

As shown in the two-way ANOVA table, the SS for Error (Within), can be calculated through the values that we already have:

Sum of Squares Error. Within


Step 7: Sum of Squares Error. Within

Degrees of freedom df


Step 8: Mean squares, test statistic and critical values

Mean squares, test statistic, critical F-values




Let’s recall our three null hypotheses:

Two-way ANOVA hypotheses sets

We will now hold our F-score up against the respective critical F-values and we will interpret our p-values for factor 1 and 2 and for the interaction of both:


Factor A, rows (gender)

Our F-score (2.5) falls beyond the critical F-value with a p-value of 0.1398. The estimated p-value shows nearly 14% probability of obtaining as extreme a test statistic as the one we have obtained (2.5), assuming that the null hypothesis is true.

We fail to reject H0 and conclude that the two means between gender are equal. There is evidence supporting the null hypothesis.


Factor B, columns (treatment)

Our F-score (76.3) falls ‘way’ beyond the critical F-value (3.9) with a p-value close to zero. So, there is nearly no probability that we will obtain a result as extreme as the one we obtained (76.3) assuming that all three means should be equal.

We therefore reject H0. There is clear evidence that not all three means are equal.


Both factors, (gender and treatment)

Our F-score (9.1) falls also ‘way’ beyond the critical F-value (3.9) with a p-value of 0.0039. There is approximately 0.39% probability that we will obtain a result as extreme as the one we obtained (9.1) assuming that there is no interaction between gender and dosage.

We reject H0. There is strong evidence that an interaction between gender and dosage is present.


Multiple comparison procedures

When we reject H0 in ANOVA, we can only say that not all means are equal. But that means that some of the means can still be equal. For example, if we are comparing four means, and we reject, we three out of the four means can still be equal.

In Multiple comparison, I list a few procedures that help solve for this.



Two-way ANOVA in Excel

In Excel we can use Data >> Data Analysis >> Anova: Two-Factor With Replication. The ‘With Replication’ is when the participants do more than one sample. In our case, there 6 persons and each take three (>1) dosages. Therefore, we choose ‘With Replication’.

The groups, or each row factor must have the same number of rows. In our example, ‘Women’ has three rows and ‘Men’ has three rows.

Two-way ANOVA in Excel


Learning statistics

Learning material that I find very useful for two-way ANOVA:


Carsten Grube

Carsten Grube

Freelance Data Analyst


  1. Ida

    Wow, that’s what I was seeking for, what a material! present here at this web site, thanks admin of this site.

  2. comment obtenir des crédits gratuits dans badoo

    Admiring the commitment you put into your blog and detailed information you offer.
    It’s good to come across a blog every once in a while that
    isn’t the same old rehashed material. Wonderful
    read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

  3. aime tiktok gratuit

    Howdy, i read your blog from time to time and i
    own a similar one and i was just curious if you get a lot of spam remarks?
    If so how do you stop it, any plugin or anything you can advise?

    I get so much lately it’s driving me crazy so any support is very much

  4. icône tiktok gratuite

    I have read so many articles or reviews on the topic of the
    blogger lovers however this article is actually a pleasant article, keep
    it up.

  5. Odessa

    I am genuinely grateful to the owner of this web site who has shared this enormous article at here.

  6. Dwayne

    I’m not that much of a online reader to be honest but your blogs really nice, keep it
    up! I’ll go ahead and bookmark your site to come back later.
    All the best

  7. Clayton

    Hi there friends, good piece of writing and good arguments commented
    at this place, I am truly enjoying by these.

  8. Sima

    I pay a visit everyday some web sites and information sites to read articles or reviews, except
    this web site offers feature based articles.

  9. essayez l'essai gratuit de Tinder Gold

    I just could not leave your site prior to suggesting that I actually enjoyed the usual info an individual provide
    to your guests? Is gonna be back continuously to check up on new posts

  10. comment obtenir de l'or gratuit Tinder 2020 reddit

    I have to thank you for the efforts you have put in penning this
    site. I really hope to see the same high-grade content by you in the
    future as well. In fact, your creative writing abilities has motivated me
    to get my very own website now 😉

  11. inde sans or amadou

    I was wondering if you ever thought of changing the page layout of your website?
    Its very well written; I love what youve got
    to say. But maybe you could a little more
    in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having one or 2 pictures.
    Maybe you could space it out better?

  12. Parthenia

    Hmm is anyone else encountering problems with the images on this
    blog loading? I’m trying to determine if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  13. Sonja

    Awesome blog you have here but I was curious if you knew of any message boards
    that cover the same topics discussed here?
    I’d really love to be a part of online community where I can get responses from other experienced people that share
    the same interest. If you have any recommendations, please let me know.

  14. or amadou gratuit légitime

    Hey there! I could have sworn I’ve been to this blog before but after reading through some
    of the post I realized it’s new to me. Anyways, I’m definitely glad I found it and I’ll be
    bookmarking and checking back often!

  15. Demetra

    I’m curious to find out what blog platform you have been using?

    I’m having some minor security issues with my latest site and
    I’d like to find something more risk-free. Do you have any solutions?

  16. Sherman

    Good day! I know this is kinda off topic but I was wondering if you knew where I could get a captcha plugin for
    my comment form? I’m using the same blog platform as yours and I’m having trouble finding one?
    Thanks a lot!

  17. application de téléchargement gratuit tinder gold

    What i don’t realize is actually how you are no longer really
    much more neatly-preferred than you might be now.
    You are very intelligent. You know thus considerably in relation to this subject, produced me individually believe it from
    numerous numerous angles. Its like men and women don’t seem to be fascinated except it’s something to do
    with Woman gaga! Your own stuffs great. Always deal with
    it up!

Submit a Comment

+34 616 71 29 85

Call me

Spain: Ctra. 404, km 2, 29100 Coín, Malaga


Denmark: c/o Musvitvej 4, 3660 Stenløse

Drop me a line

What are you working on just now? Can I help you, and can you help me? 

About me

Learning statistics. Doing statistics. Freelance since 2005. Dane. Living in Spain. With my Spanish wife and two children. 

What they say

20 years in sales, analysis, journalism and startups. See what my customers and partners say about me.