Have a language expert improve your writing

Run a free plagiarism check in 10 minutes, generate accurate citations for free.

  • Knowledge Base
  • Two-Way ANOVA | Examples & When To Use It

Two-Way ANOVA | Examples & When To Use It

Published on March 20, 2020 by Rebecca Bevans . Revised on June 22, 2023.

ANOVA (Analysis of Variance) is a statistical test used to analyze the difference between the means of more than two groups.

A two-way ANOVA is used to estimate how the mean of a quantitative variable changes according to the levels of two categorical variables. Use a two-way ANOVA when you want to know how two independent variables, in combination, affect a dependent variable.

Table of contents

When to use a two-way anova, how does the anova test work, assumptions of the two-way anova, how to perform a two-way anova, interpreting the results of a two-way anova, how to present the results of a a two-way anova, other interesting articles, frequently asked questions about two-way anova.

You can use a two-way ANOVA when you have collected data on a quantitative dependent variable at multiple levels of two categorical independent variables.

A quantitative variable represents amounts or counts of things. It can be divided to find a group mean.

A categorical variable represents types or categories of things. A level is an individual category within the categorical variable.

You should have enough observations in your data set to be able to find the mean of the quantitative dependent variable at each combination of levels of the independent variables.

Both of your independent variables should be categorical. If one of your independent variables is categorical and one is quantitative, use an ANCOVA instead.

Receive feedback on language, structure, and formatting

Professional editors proofread and edit your paper by focusing on:

  • Academic style
  • Vague sentences
  • Style consistency

See an example

hypothesis of 2 way anova

ANOVA tests for significance using the F test for statistical significance . The F test is a groupwise comparison test, which means it compares the variance in each group mean to the overall variance in the dependent variable.

If the variance within groups is smaller than the variance between groups, the F test will find a higher F value, and therefore a higher likelihood that the difference observed is real and not due to chance.

A two-way ANOVA with interaction tests three null hypotheses at the same time:

  • There is no difference in group means at any level of the first independent variable.
  • There is no difference in group means at any level of the second independent variable.
  • The effect of one independent variable does not depend on the effect of the other independent variable (a.k.a. no interaction effect).

A two-way ANOVA without interaction (a.k.a. an additive two-way ANOVA) only tests the first two of these hypotheses.

Null hypothesis (H ) Alternate hypothesis (H )
There is no difference in average yield
for any fertilizer type.
There is a difference in average yield by fertilizer type.
There is no difference in average yield at either planting density. There is a difference in average yield by planting density.
The effect of one independent variable on average yield does not depend on the effect of the other independent variable (a.k.a. no interaction effect). There is an interaction effect between planting density and fertilizer type on average yield.

To use a two-way ANOVA your data should meet certain assumptions.Two-way ANOVA makes all of the normal assumptions of a parametric test of difference:

  • Homogeneity of variance (a.k.a. homoscedasticity )

The variation around the mean for each group being compared should be similar among all groups. If your data don’t meet this assumption, you may be able to use a non-parametric alternative , like the Kruskal-Wallis test.

  • Independence of observations

Your independent variables should not be dependent on one another (i.e. one should not cause the other). This is impossible to test with categorical variables – it can only be ensured by good experimental design .

In addition, your dependent variable should represent unique observations – that is, your observations should not be grouped within locations or individuals.

If your data don’t meet this assumption (i.e. if you set up experimental treatments within blocks), you can include a blocking variable and/or use a repeated-measures ANOVA.

  • Normally-distributed dependent variable

The values of the dependent variable should follow a bell curve (they should be normally distributed ). If your data don’t meet this assumption, you can try a data transformation.

The dataset from our imaginary crop yield experiment includes observations of:

  • Final crop yield (bushels per acre)
  • Type of fertilizer used (fertilizer type 1, 2, or 3)
  • Planting density (1=low density, 2=high density)
  • Block in the field (1, 2, 3, 4).

The two-way ANOVA will test whether the independent variables (fertilizer type and planting density) have an effect on the dependent variable (average crop yield). But there are some other possible sources of variation in the data that we want to take into account.

We applied our experimental treatment in blocks, so we want to know if planting block makes a difference to average crop yield. We also want to check if there is an interaction effect between two independent variables – for example, it’s possible that planting density affects the plants’ ability to take up fertilizer.

Because we have a few different possible relationships between our variables, we will compare three models:

  • A two-way ANOVA without any interaction or blocking variable (a.k.a an additive two-way ANOVA).
  • A two-way ANOVA with interaction but with no blocking variable.
  • A two-way ANOVA with interaction and with the blocking variable.

Model 1 assumes there is no interaction between the two independent variables. Model 2 assumes that there is an interaction between the two independent variables. Model 3 assumes there is an interaction between the variables, and that the blocking variable is an important source of variation in the data.

By running all three versions of the two-way ANOVA with our data and then comparing the models, we can efficiently test which variables, and in which combinations, are important for describing the data, and see whether the planting block matters for average crop yield.

This is not the only way to do your analysis, but it is a good method for efficiently comparing models based on what you think are reasonable combinations of variables.

Running a two-way ANOVA in R

We will run our analysis in R. To try it yourself, download the sample dataset.

Sample dataset for a two-way ANOVA

After loading the data into the R environment, we will create each of the three models using the aov() command, and then compare them using the aictab() command. For a full walkthrough, see our guide to ANOVA in R .

This first model does not predict any interaction between the independent variables, so we put them together with a ‘+’.

In the second model, to test whether the interaction of fertilizer type and planting density influences the final yield, use a ‘ * ‘ to specify that you also want to know the interaction effect.

Because our crop treatments were randomized within blocks, we add this variable as a blocking factor in the third model. We can then compare our two-way ANOVAs with and without the blocking variable to see whether the planting location matters.

Model comparison

Now we can find out which model is the best fit for our data using AIC ( Akaike information criterion ) model selection.

AIC calculates the best-fit model by finding the model that explains the largest amount of variation in the response variable while using the fewest parameters. We can perform a model comparison in R using the aictab() function.

The output looks like this:

AIC model selection table, with best model listed first

The AIC model with the best fit will be listed first, with the second-best listed next, and so on. This comparison reveals that the two-way ANOVA without any interaction or blocking effects is the best fit for the data.

You can view the summary of the two-way model in R using the summary() command. We will take a look at the results of the first model, which we found was the best fit for our data.

Model summary of a two-way ANOVA without interaction in R.

The model summary first lists the independent variables being tested (‘fertilizer’ and ‘density’). Next is the residual variance (‘Residuals’), which is the variation in the dependent variable that isn’t explained by the independent variables.

The following columns provide all of the information needed to interpret the model:

  • Df shows the degrees of freedom for each variable (number of levels in the variable minus 1).
  • Sum sq is the sum of squares (a.k.a. the variation between the group means created by the levels of the independent variable and the overall mean).
  • Mean sq shows the mean sum of squares (the sum of squares divided by the degrees of freedom).
  • F value is the test statistic from the F test (the mean square of the variable divided by the mean square of each parameter).
  • Pr(>F) is the p value of the F statistic, and shows how likely it is that the F value calculated from the F test would have occurred if the null hypothesis of no difference was true.

From this output we can see that both fertilizer type and planting density explain a significant amount of variation in average crop yield ( p values < 0.001).

Post-hoc testing

ANOVA will tell you which parameters are significant, but not which levels are actually different from one another. To test this we can use a post-hoc test. The Tukey’s Honestly-Significant-Difference (TukeyHSD) test lets us see which groups are different from one another.

Summary of a TukeyHSD post-hoc comparison for a two-way ANOVA in R.

This output shows the pairwise differences between the three types of fertilizer ($fertilizer) and between the two levels of planting density ($density), with the average difference (‘diff’), the lower and upper bounds of the 95% confidence interval (‘lwr’ and ‘upr’) and the p value of the difference (‘p-adj’).

From the post-hoc test results, we see that there are significant differences ( p < 0.05) between:

  • fertilizer groups 3 and 1,
  • fertilizer types 3 and 2,
  • the two levels of planting density,

but no difference between fertilizer groups 2 and 1.

Once you have your model output, you can report the results in the results section of your thesis , dissertation or research paper .

When reporting the results you should include the F statistic, degrees of freedom, and p value from your model output.

You can discuss what these findings mean in the discussion section of your paper.

You may also want to make a graph of your results to illustrate your findings.

Your graph should include the groupwise comparisons tested in the ANOVA, with the raw data points, summary statistics (represented here as means and standard error bars), and letters or significance values above the groups to show which groups are significantly different from the others.

Groupwise comparisons graph illustrating the results of a two-way ANOVA.

If you want to know more about statistics , methodology , or research bias , make sure to check out some of our other articles with explanations and examples.

  • Chi square test of independence
  • Statistical power
  • Descriptive statistics
  • Degrees of freedom
  • Pearson correlation
  • Null hypothesis

Methodology

  • Double-blind study
  • Case-control study
  • Research ethics
  • Data collection
  • Hypothesis testing
  • Structured interviews

Research bias

  • Hawthorne effect
  • Unconscious bias
  • Recall bias
  • Halo effect
  • Self-serving bias
  • Information bias

The only difference between one-way and two-way ANOVA is the number of independent variables . A one-way ANOVA has one independent variable, while a two-way ANOVA has two.

  • One-way ANOVA : Testing the relationship between shoe brand (Nike, Adidas, Saucony, Hoka) and race finish times in a marathon.
  • Two-way ANOVA : Testing the relationship between shoe brand (Nike, Adidas, Saucony, Hoka), runner age group (junior, senior, master’s), and race finishing times in a marathon.

All ANOVAs are designed to test for differences among three or more groups. If you are only testing for a difference between two groups, use a t-test instead.

In ANOVA, the null hypothesis is that there is no difference among group means. If any group differs significantly from the overall group mean, then the ANOVA will report a statistically significant result.

Significant differences among group means are calculated using the F statistic, which is the ratio of the mean sum of squares (the variance explained by the independent variable) to the mean square error (the variance left over).

If the F statistic is higher than the critical value (the value of F that corresponds with your alpha value, usually 0.05), then the difference among groups is deemed statistically significant.

A factorial ANOVA is any ANOVA that uses more than one categorical independent variable . A two-way ANOVA is a type of factorial ANOVA.

Some examples of factorial ANOVAs include:

  • Testing the combined effects of vaccination (vaccinated or not vaccinated) and health status (healthy or pre-existing condition) on the rate of flu infection in a population.
  • Testing the effects of marital status (married, single, divorced, widowed), job status (employed, self-employed, unemployed, retired), and family history (no family history, some family history) on the incidence of depression in a population.
  • Testing the effects of feed type (type A, B, or C) and barn crowding (not crowded, somewhat crowded, very crowded) on the final weight of chickens in a commercial farming operation.

Quantitative variables are any variables where the data represent amounts (e.g. height, weight, or age).

Categorical variables are any variables where the data represent groups. This includes rankings (e.g. finishing places in a race), classifications (e.g. brands of cereal), and binary outcomes (e.g. coin flips).

You need to know what type of variables you are working with to choose the right statistical test for your data and interpret your results .

Cite this Scribbr article

If you want to cite this source, you can copy and paste the citation or click the “Cite this Scribbr article” button to automatically add the citation to our free Citation Generator.

Bevans, R. (2023, June 22). Two-Way ANOVA | Examples & When To Use It. Scribbr. Retrieved August 26, 2024, from https://www.scribbr.com/statistics/two-way-anova/

Is this article helpful?

Rebecca Bevans

Rebecca Bevans

Other students also liked, anova in r | a complete step-by-step guide with examples, one-way anova | when and how to use it (with examples), what is your plagiarism score.

Two-Way ANOVA: Definition, Formula, and Example

A two-way ANOVA  (“analysis of variance”) is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups that have been split on two variables (sometimes called “factors”).

This tutorial explains the following:

  • When to use a two-way ANOVA.
  • The assumptions that should be met to perform a two-way ANOVA.
  • An example of how to perform a two-way ANOVA.

When to Use a Two-Way ANOVA

You should use a two-way ANOVA when you’d like to know how two factors affect a response variable and whether or not there is an interaction effect between the two factors on the response variable.

For example, suppose a botanist wants to explore how sunlight exposure and watering frequency affect plant growth. She plants 40 seeds and lets them grow for two months under different conditions for sunlight exposure and watering frequency. After two months, she records the height of each plant.

In this case, we have the following variables:

  • Response variable:  plant growth
  • Factors:  sunlight exposure, watering frequency

And we would like to answer the following questions:

  • Does sunlight exposure affect plant growth?
  • Does watering frequency affect plant growth?
  • Is there an interaction effect between sunlight exposure and watering frequency? (e.g. the effect that sunlight exposure has on the plants is dependent on watering frequency)

We would use a two-way ANOVA for this analysis because we have  two  factors. If instead we wanted to know how only watering frequency affected plant growth, we would use a one-way ANOVA since we would only be working with one factor.

Two-Way ANOVA Assumptions

For the results of a two-way ANOVA to be valid, the following assumptions should be met:

1. Normality  – The response variable is approximately normally distributed for each group.

2. Equal Variances  – The variances for each group should be roughly equal.

3. Independence  – The observations in each group are independent of each other and the observations within groups were obtained by a random sample.

Two-Way ANOVA: Example

A botanist wants to know whether or not plant growth is influenced by sunlight exposure and watering frequency. She plants 40 seeds and lets them grow for two months under different conditions for sunlight exposure and watering frequency. After two months, she records the height of each plant. The results are shown below:

Two-way ANOVA table in Excel

In the table above, we see that there were five plants grown under each combination of conditions.

For example, there were five plants grown with daily watering and no sunlight and their heights after two months were 4.8 inches, 4.4 inches, 3.2 inches, 3.9 inches, and 4.4 inches:

Two-way ANOVA data in Excel

She performs a two-way ANOVA in Excel and ends up with the following output:

Two-way ANOVA output

The last table shows the result of the two-way ANOVA. We can observe the following:

  • The p-value for the interaction between watering  frequency and sunlight exposure was  0.310898 . This is not statistically significant at alpha level 0.05.
  • The p-value for watering frequency was  0.975975 . This is not statistically significant at alpha level 0.05.
  • The p-value for sunlight exposure was  3.9E-8 (0.000000039) . This is statistically significant at alpha level 0.05.

These results indicate that sunlight exposure is the only factor that has a statistically significant effect on plant height.

And because there is no interaction effect, the effect of sunlight exposure is consistent across each level of watering frequency.

That is, whether a plant is watered daily or weekly has no impact on how sunlight exposure affects a plant.

Additional Resources

The following articles explain how to perform a two-way ANOVA using different statistical software:

How to Perform a Two-Way ANOVA in Excel How to Perform a Two-Way ANOVA in R How to Perform a Two-Way ANOVA in Python How to Perform a Two-Way ANOVA in SPSS How to Perform a Two-Way ANOVA in Stata

Confidence Interval Calculator

Pythagorean triples calculator, related posts, three-way anova: definition & example, two sample z-test: definition, formula, and example, one sample z-test: definition, formula, and example, how to find a confidence interval for a..., an introduction to the exponential distribution, an introduction to the uniform distribution, the breusch-pagan test: definition & example, population vs. sample: what’s the difference, introduction to multiple linear regression, dunn’s test for multiple comparisons.

Please enable JavaScript to view this site.

  • Statistics Guide
  • Curve Fitting Guide
  • Prism Guide
  • Zoom Window Out
  • Larger Text  |  Smaller Text
  • Hide Page Header
  • Show Expanding Text
  • Printable Version
  • Save Permalink URL
> >

Interpreting results: Two-way ANOVA

Scroll Prev Top Next More

Two-way ANOVA determines how a response is affected by two factors. For example, you might measure a response to three different drugs in both men and women.

Source of variation

Two-way ANOVA divides the total variability among values into four components. Prism tabulates the percentage of the variability due to interaction between the row and column factor, the percentage due to the row factor, and the percentage due to the column factor. The remainder of the variation is among replicates (also called residual variation).

These values (% of total variation) are called standard omega squared by Sheskin (equations 27.51 - 27.53,  and R 2 by Maxwell and Delaney (page 295). Others call these values eta squared or the correlation ratio.

ANOVA table

The ANOVA table breaks down the overall variability between measurements (expressed as the sum of squares) into four components:

• Interactions between row and column. These are differences between rows that are not the same at each column, equivalent to variation between columns that is not the same at each row.

• Variability among columns.

• Variability among rows.

• Residual or error. Variation among replicates not related to systematic differences between rows and columns.

The ANOVA table shows how the sum of squares is partitioned into the four components. Most scientists will skip these results, which are not especially informative unless you have studied statistics in depth. For each component, the table shows sum-of-squares, degrees of freedom, mean square, and the F ratio. Each F ratio is the ratio of the mean-square value for that source of variation to the residual mean square (with repeated-measures ANOVA, the denominator of one F ratio is the mean square for matching rather than residual mean square). If the null hypothesis is true, the F ratio is likely to be close to 1.0. If the null hypothesis is not true, the F ratio is likely to be greater than 1.0. The F ratios are not very informative by themselves, but are used to determine P values.

Two-way ANOVA partitions the overall variance of the outcome variable into three components, plus a residual (or error) term. Therefore it computes P values that test three null hypotheses (repeated measures two-way ANOVA adds yet another P value).

Interaction P value

The null hypothesis is that there is no interaction between columns (data sets) and rows. More precisely, the null hypothesis states that any systematic differences between columns are the same for each row and that any systematic differences between rows are the same for each column. Often the test of interaction is the most important of the three tests. If columns represent drugs and rows represent gender, then the null hypothesis is that the differences between the drugs are consistent for men and women.

The P value answers this question:

If the null hypothesis is true, what is the chance of randomly sampling subjects and ending up with as much (or more) interaction than you have observed?

The graph on the left below shows no interaction. The treatment has about the same effect in males and females. The graph on the right, in contrast, shows a huge interaction. the effect of the treatment is completely different in males (treatment increases the concentration) and females (where the treatment decreases the concentration). In this example, the treatment effect goes in the opposite direction for males and females. But the test for interaction does not test whether the effect goes in different directions. It tests whether the average treatment effect is the same for each row (each gender, for this example).

hypothesis of 2 way anova

Testing for interaction requires that you enter replicate values or mean and SD (or SEM) and N. If you entered only a single value for each row/column pair, Prism assumes that there is no interaction, and continues with the other calculations. Depending on your experimental design, this assumption may or may not make sense.

If the test for interaction leads to statistically significant results, you probably won't learn anything of interest from the other two P values. In the example above, a statistically significant interaction means that the effect of the treatment (difference between treated and control) differs  between males and females. In this case, it is really impossible to interpret the overall P value testing the null hypothesis that the treatment has no effect at all. Instead focus on the multiple comparison post tests. Is the effect statistically significant in males? How about females?

Column factor P value

The null hypothesis is that the mean of each column (totally ignoring the rows) is the same in the overall population, and that all differences we see between column means are due to chance. In the example graphed above, results for control and treated were entered in different columns (with males and females being entered in different rows). The null hypothesis is that the treatment was ineffective so control and treated values differ only due to chance. The P value answers this question: If the null hypothesis is true, what is the chance of randomly obtaining column means as different (or more so) than you have observed?

In the example shown in the left graph above, the P value for the column factor (treatment) is 0.0002. The treatment has an effect that is statistically significant.

In the example shown in the right graph above, the P value for the column factor (treatment) is very high (0.54). On average, the treatment effect is indistinguishable from random variation. But this P value is not meaningful in this example. Since the interaction P value is low, you know that the effect of the treatment is not the same at each row (each gender, for this example). In fact, for this example, the treatment has opposite effects in males and females. Accordingly, asking about the overall, average, treatment effect doesn't make any sense.

Row factor P value

The null hypothesis is that the mean of each row (totally ignoring the columns) is the same in the overall population, and that all differences we see between row means are due to chance. In the example above, the rows represent gender, so the null hypothesis is that the mean response is the same for men and women. The P value answers this question: If the null hypothesis is true, what is the chance of randomly obtaining row means as different (or more so) than you have observed?

In both examples above, the P value for the row factor (gender) is very low.

Data Summary Table

This small section on the results sheet provides a summary of:

• The number of columns (Column Factor)

• The number of rows (Row Factor)

• The number of values

Note that using the Factor Names tab to enter descriptive names for the Column Factor and Row Factor will display the entered descriptive names in the Data Summary Table. This feature was added for ordinary two-way ANOVA in Prism 8.2.

Multiple comparisons tests

Note that the three P values produced by two-way ANOVA are not corrected for the three comparisons. It would seem logical to do so, but this is not traditionally (ever?) done in ANOVA.

Multiple comparisons testing is one of the most confusing topics in statistics. Since Prism offers nearly the same multiple comparisons tests for one-way ANOVA and two-way ANOVA, we have consolidated the information on multiple comparisons .

David J. Sheskin. Handbook of Parametric and Nonparametric Statistical Procedures: Third Edition IBSN:1584884401.

© 1995- 2019 GraphPad Software, LLC. All rights reserved.

resize nav pane

  

Stats: Two-Way ANOVA

Assumptions.

  • The populations from which the samples were obtained must be normally or approximately normally distributed.
  • The samples must be independent.
  • The variances of the populations must be equal.
  • The groups must have the same sample size.
  • The population means of the first factor are equal. This is like the one-way ANOVA for the row factor.
  • The population means of the second factor are equal. This is like the one-way ANOVA for the column factor.
  • There is no interaction between the two factors. This is similar to performing a test for independence with contingency tables.

Treatment Groups

  Fert I Fert II Fert III Fert IV Fert V
Seed A-402 106, 110 95, 100 94, 107 103, 104 100, 102
Seed B-894 110, 112 98, 99 100, 101 108, 112 105, 107
Seed C-952 94, 97 86, 87 98, 99 99, 101 94, 98

Main Effect

Interaction effect, within variation, two-way anova table.

A,
a-1
SS / df MS(A) / MS(W)
B,
b-1
SS / df MS(B) / MS(W)
A*B,
(a-1)(b-1)
SS / df MS(A*B) / MS(W)
N - ab,
ab(n-1)
SS / df  
sum of others N - 1,
abn - 1
   
512.8667 2 256.4333 28.283 0.000008 3.682
449.4667 4 112.3667 12.393 0.000119 3.056
143.1333 8 17.8917 1.973 0.122090 2.641
136.0000 15 9.0667      
       

Error in Bluman Textbook

3.920 1 3.920 4.752
9.680 1 9.680 11.733
54.080 1 54.080 65.552
3.300 4 0.825  
70.980 7    

hypothesis of 2 way anova

User Preferences

Content preview.

Arcu felis bibendum ut tristique et egestas quis:

  • Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  • Duis aute irure dolor in reprehenderit in voluptate
  • Excepteur sint occaecat cupidatat non proident

Keyboard Shortcuts

10.4 - two-way anova.

The one-way ANOVA presented in the Lesson is a simple case. In practice, research questions are rarely this “simple.” ANOVA models become increasingly complex very quickly.

The two-way ANOVA model is briefly introduced here to give you an idea of what to expect in practice. Even two-way ANOVA can be too “simple” for practice.

In two-way ANOVA, there are two factors of interest. When there are two factors, the experimental units get a combination of treatments.

Suppose a researcher is interested in examining how different fertilizers affect the growth of plants. However, the researcher is also interested in the growth of different species of plant. Species is the second factor, making this a two-factor experiment. But... those of you with green thumbs say sometimes different fertilizers are more effective on different species of plants!

This is the idea behind two-way ANOVA. If you are interested in more complex ANOVA models, you should consider taking STAT 502 and STAT 503 .

Hypothesis Testing - Analysis of Variance (ANOVA)

Lisa Sullivan, PhD

Professor of Biostatistics

Boston University School of Public Health

hypothesis of 2 way anova

Introduction

This module will continue the discussion of hypothesis testing, where a specific statement or hypothesis is generated about a population parameter, and sample statistics are used to assess the likelihood that the hypothesis is true. The hypothesis is based on available information and the investigator's belief about the population parameters. The specific test considered here is called analysis of variance (ANOVA) and is a test of hypothesis that is appropriate to compare means of a continuous variable in two or more independent comparison groups. For example, in some clinical trials there are more than two comparison groups. In a clinical trial to evaluate a new medication for asthma, investigators might compare an experimental medication to a placebo and to a standard treatment (i.e., a medication currently being used). In an observational study such as the Framingham Heart Study, it might be of interest to compare mean blood pressure or mean cholesterol levels in persons who are underweight, normal weight, overweight and obese.  

The technique to test for a difference in more than two independent means is an extension of the two independent samples procedure discussed previously which applies when there are exactly two independent comparison groups. The ANOVA technique applies when there are two or more than two independent groups. The ANOVA procedure is used to compare the means of the comparison groups and is conducted using the same five step approach used in the scenarios discussed in previous sections. Because there are more than two groups, however, the computation of the test statistic is more involved. The test statistic must take into account the sample sizes, sample means and sample standard deviations in each of the comparison groups.

If one is examining the means observed among, say three groups, it might be tempting to perform three separate group to group comparisons, but this approach is incorrect because each of these comparisons fails to take into account the total data, and it increases the likelihood of incorrectly concluding that there are statistically significate differences, since each comparison adds to the probability of a type I error. Analysis of variance avoids these problemss by asking a more global question, i.e., whether there are significant differences among the groups, without addressing differences between any two groups in particular (although there are additional tests that can do this if the analysis of variance indicates that there are differences among the groups).

The fundamental strategy of ANOVA is to systematically examine variability within groups being compared and also examine variability among the groups being compared.

Learning Objectives

After completing this module, the student will be able to:

  • Perform analysis of variance by hand
  • Appropriately interpret results of analysis of variance tests
  • Distinguish between one and two factor analysis of variance tests
  • Identify the appropriate hypothesis testing procedure based on type of outcome variable and number of samples

The ANOVA Approach

Consider an example with four independent groups and a continuous outcome measure. The independent groups might be defined by a particular characteristic of the participants such as BMI (e.g., underweight, normal weight, overweight, obese) or by the investigator (e.g., randomizing participants to one of four competing treatments, call them A, B, C and D). Suppose that the outcome is systolic blood pressure, and we wish to test whether there is a statistically significant difference in mean systolic blood pressures among the four groups. The sample data are organized as follows:

 

n

n

n

n

s

s

s

s

The hypotheses of interest in an ANOVA are as follows:

  • H 0 : μ 1 = μ 2 = μ 3 ... = μ k
  • H 1 : Means are not all equal.

where k = the number of independent comparison groups.

In this example, the hypotheses are:

  • H 0 : μ 1 = μ 2 = μ 3 = μ 4
  • H 1 : The means are not all equal.

The null hypothesis in ANOVA is always that there is no difference in means. The research or alternative hypothesis is always that the means are not all equal and is usually written in words rather than in mathematical symbols. The research hypothesis captures any difference in means and includes, for example, the situation where all four means are unequal, where one is different from the other three, where two are different, and so on. The alternative hypothesis, as shown above, capture all possible situations other than equality of all means specified in the null hypothesis.

Test Statistic for ANOVA

The test statistic for testing H 0 : μ 1 = μ 2 = ... =   μ k is:

and the critical value is found in a table of probability values for the F distribution with (degrees of freedom) df 1 = k-1, df 2 =N-k. The table can be found in "Other Resources" on the left side of the pages.

NOTE: The test statistic F assumes equal variability in the k populations (i.e., the population variances are equal, or s 1 2 = s 2 2 = ... = s k 2 ). This means that the outcome is equally variable in each of the comparison populations. This assumption is the same as that assumed for appropriate use of the test statistic to test equality of two independent means. It is possible to assess the likelihood that the assumption of equal variances is true and the test can be conducted in most statistical computing packages. If the variability in the k comparison groups is not similar, then alternative techniques must be used.

The F statistic is computed by taking the ratio of what is called the "between treatment" variability to the "residual or error" variability. This is where the name of the procedure originates. In analysis of variance we are testing for a difference in means (H 0 : means are all equal versus H 1 : means are not all equal) by evaluating variability in the data. The numerator captures between treatment variability (i.e., differences among the sample means) and the denominator contains an estimate of the variability in the outcome. The test statistic is a measure that allows us to assess whether the differences among the sample means (numerator) are more than would be expected by chance if the null hypothesis is true. Recall in the two independent sample test, the test statistic was computed by taking the ratio of the difference in sample means (numerator) to the variability in the outcome (estimated by Sp).  

The decision rule for the F test in ANOVA is set up in a similar way to decision rules we established for t tests. The decision rule again depends on the level of significance and the degrees of freedom. The F statistic has two degrees of freedom. These are denoted df 1 and df 2 , and called the numerator and denominator degrees of freedom, respectively. The degrees of freedom are defined as follows:

df 1 = k-1 and df 2 =N-k,

where k is the number of comparison groups and N is the total number of observations in the analysis.   If the null hypothesis is true, the between treatment variation (numerator) will not exceed the residual or error variation (denominator) and the F statistic will small. If the null hypothesis is false, then the F statistic will be large. The rejection region for the F test is always in the upper (right-hand) tail of the distribution as shown below.

Rejection Region for F   Test with a =0.05, df 1 =3 and df 2 =36 (k=4, N=40)

Graph of rejection region for the F statistic with alpha=0.05

For the scenario depicted here, the decision rule is: Reject H 0 if F > 2.87.

The ANOVA Procedure

We will next illustrate the ANOVA procedure using the five step approach. Because the computation of the test statistic is involved, the computations are often organized in an ANOVA table. The ANOVA table breaks down the components of variation in the data into variation between treatments and error or residual variation. Statistical computing packages also produce ANOVA tables as part of their standard output for ANOVA, and the ANOVA table is set up as follows: 

Source of Variation

Sums of Squares (SS)

Degrees of Freedom (df)

Mean Squares (MS)

F

Between Treatments

k-1

Error (or Residual)

N-k

Total

N-1

where  

  • X = individual observation,
  • k = the number of treatments or independent comparison groups, and
  • N = total number of observations or total sample size.

The ANOVA table above is organized as follows.

  • The first column is entitled "Source of Variation" and delineates the between treatment and error or residual variation. The total variation is the sum of the between treatment and error variation.
  • The second column is entitled "Sums of Squares (SS)" . The between treatment sums of squares is

and is computed by summing the squared differences between each treatment (or group) mean and the overall mean. The squared differences are weighted by the sample sizes per group (n j ). The error sums of squares is:

and is computed by summing the squared differences between each observation and its group mean (i.e., the squared differences between each observation in group 1 and the group 1 mean, the squared differences between each observation in group 2 and the group 2 mean, and so on). The double summation ( SS ) indicates summation of the squared differences within each treatment and then summation of these totals across treatments to produce a single value. (This will be illustrated in the following examples). The total sums of squares is:

and is computed by summing the squared differences between each observation and the overall sample mean. In an ANOVA, data are organized by comparison or treatment groups. If all of the data were pooled into a single sample, SST would reflect the numerator of the sample variance computed on the pooled or total sample. SST does not figure into the F statistic directly. However, SST = SSB + SSE, thus if two sums of squares are known, the third can be computed from the other two.

  • The third column contains degrees of freedom . The between treatment degrees of freedom is df 1 = k-1. The error degrees of freedom is df 2 = N - k. The total degrees of freedom is N-1 (and it is also true that (k-1) + (N-k) = N-1).
  • The fourth column contains "Mean Squares (MS)" which are computed by dividing sums of squares (SS) by degrees of freedom (df), row by row. Specifically, MSB=SSB/(k-1) and MSE=SSE/(N-k). Dividing SST/(N-1) produces the variance of the total sample. The F statistic is in the rightmost column of the ANOVA table and is computed by taking the ratio of MSB/MSE.  

A clinical trial is run to compare weight loss programs and participants are randomly assigned to one of the comparison programs and are counseled on the details of the assigned program. Participants follow the assigned program for 8 weeks. The outcome of interest is weight loss, defined as the difference in weight measured at the start of the study (baseline) and weight measured at the end of the study (8 weeks), measured in pounds.  

Three popular weight loss programs are considered. The first is a low calorie diet. The second is a low fat diet and the third is a low carbohydrate diet. For comparison purposes, a fourth group is considered as a control group. Participants in the fourth group are told that they are participating in a study of healthy behaviors with weight loss only one component of interest. The control group is included here to assess the placebo effect (i.e., weight loss due to simply participating in the study). A total of twenty patients agree to participate in the study and are randomly assigned to one of the four diet groups. Weights are measured at baseline and patients are counseled on the proper implementation of the assigned diet (with the exception of the control group). After 8 weeks, each patient's weight is again measured and the difference in weights is computed by subtracting the 8 week weight from the baseline weight. Positive differences indicate weight losses and negative differences indicate weight gains. For interpretation purposes, we refer to the differences in weights as weight losses and the observed weight losses are shown below.

Low Calorie

Low Fat

Low Carbohydrate

Control

8

2

3

2

9

4

5

2

6

3

4

-1

7

5

2

0

3

1

3

3

Is there a statistically significant difference in the mean weight loss among the four diets?  We will run the ANOVA using the five-step approach.

  • Step 1. Set up hypotheses and determine level of significance

H 0 : μ 1 = μ 2 = μ 3 = μ 4 H 1 : Means are not all equal              α=0.05

  • Step 2. Select the appropriate test statistic.  

The test statistic is the F statistic for ANOVA, F=MSB/MSE.

  • Step 3. Set up decision rule.  

The appropriate critical value can be found in a table of probabilities for the F distribution(see "Other Resources"). In order to determine the critical value of F we need degrees of freedom, df 1 =k-1 and df 2 =N-k. In this example, df 1 =k-1=4-1=3 and df 2 =N-k=20-4=16. The critical value is 3.24 and the decision rule is as follows: Reject H 0 if F > 3.24.

  • Step 4. Compute the test statistic.  

To organize our computations we complete the ANOVA table. In order to compute the sums of squares we must first compute the sample means for each group and the overall mean based on the total sample.  

 

Low Calorie

Low Fat

Low Carbohydrate

Control

n

5

5

5

5

Group mean

6.6

3.0

3.4

1.2

We can now compute

So, in this case:

Next we compute,

SSE requires computing the squared differences between each observation and its group mean. We will compute SSE in parts. For the participants in the low calorie diet:  

6.6

8

1.4

2.0

9

2.4

5.8

6

-0.6

0.4

7

0.4

0.2

3

-3.6

13.0

Totals

0

21.4

For the participants in the low fat diet:  

3.0

2

-1.0

1.0

4

1.0

1.0

3

0.0

0.0

5

2.0

4.0

1

-2.0

4.0

Totals

0

10.0

For the participants in the low carbohydrate diet:  

3

-0.4

0.2

5

1.6

2.6

4

0.6

0.4

2

-1.4

2.0

3

-0.4

0.2

Totals

0

5.4

For the participants in the control group:

2

0.8

0.6

2

0.8

0.6

-1

-2.2

4.8

0

-1.2

1.4

3

1.8

3.2

Totals

0

10.6

We can now construct the ANOVA table .

Source of Variation

Sums of Squares

(SS)

Degrees of Freedom

(df)

Means Squares

(MS)

F

Between Treatmenst

75.8

4-1=3

75.8/3=25.3

25.3/3.0=8.43

Error (or Residual)

47.4

20-4=16

47.4/16=3.0

Total

123.2

20-1=19

  • Step 5. Conclusion.  

We reject H 0 because 8.43 > 3.24. We have statistically significant evidence at α=0.05 to show that there is a difference in mean weight loss among the four diets.    

ANOVA is a test that provides a global assessment of a statistical difference in more than two independent means. In this example, we find that there is a statistically significant difference in mean weight loss among the four diets considered. In addition to reporting the results of the statistical test of hypothesis (i.e., that there is a statistically significant difference in mean weight losses at α=0.05), investigators should also report the observed sample means to facilitate interpretation of the results. In this example, participants in the low calorie diet lost an average of 6.6 pounds over 8 weeks, as compared to 3.0 and 3.4 pounds in the low fat and low carbohydrate groups, respectively. Participants in the control group lost an average of 1.2 pounds which could be called the placebo effect because these participants were not participating in an active arm of the trial specifically targeted for weight loss. Are the observed weight losses clinically meaningful?

Another ANOVA Example

Calcium is an essential mineral that regulates the heart, is important for blood clotting and for building healthy bones. The National Osteoporosis Foundation recommends a daily calcium intake of 1000-1200 mg/day for adult men and women. While calcium is contained in some foods, most adults do not get enough calcium in their diets and take supplements. Unfortunately some of the supplements have side effects such as gastric distress, making them difficult for some patients to take on a regular basis.  

 A study is designed to test whether there is a difference in mean daily calcium intake in adults with normal bone density, adults with osteopenia (a low bone density which may lead to osteoporosis) and adults with osteoporosis. Adults 60 years of age with normal bone density, osteopenia and osteoporosis are selected at random from hospital records and invited to participate in the study. Each participant's daily calcium intake is measured based on reported food intake and supplements. The data are shown below.   

1200

1000

890

1000

1100

650

980

700

1100

900

800

900

750

500

400

800

700

350

Is there a statistically significant difference in mean calcium intake in patients with normal bone density as compared to patients with osteopenia and osteoporosis? We will run the ANOVA using the five-step approach.

H 0 : μ 1 = μ 2 = μ 3 H 1 : Means are not all equal                            α=0.05

In order to determine the critical value of F we need degrees of freedom, df 1 =k-1 and df 2 =N-k.   In this example, df 1 =k-1=3-1=2 and df 2 =N-k=18-3=15. The critical value is 3.68 and the decision rule is as follows: Reject H 0 if F > 3.68.

To organize our computations we will complete the ANOVA table. In order to compute the sums of squares we must first compute the sample means for each group and the overall mean.  

Normal Bone Density

n =6

n =6

n =6

 If we pool all N=18 observations, the overall mean is 817.8.

We can now compute:

Substituting:

SSE requires computing the squared differences between each observation and its group mean. We will compute SSE in parts. For the participants with normal bone density:

1200

261.6667

68,486.9

1000

61.6667

3,806.9

980

41.6667

1,738.9

900

-38.3333

1,466.9

750

-188.333

35,456.9

800

-138.333

19,126.9

Total

0

130,083.3

For participants with osteopenia:

1000

200

40,000

1100

300

90,000

700

-100

10,000

800

0

0

500

-300

90,000

700

-100

10,000

Total

0

240,000

For participants with osteoporosis:

890

175

30,625

650

-65

4,225

1100

385

148,225

900

185

34,225

400

-315

99,225

350

-365

133,225

Total

0

449,750

Between Treatments

152,477.7

2

76,238.6

1.395

Error or Residual

819,833.3

15

54,655.5

Total

972,311.0

17

We do not reject H 0 because 1.395 < 3.68. We do not have statistically significant evidence at a =0.05 to show that there is a difference in mean calcium intake in patients with normal bone density as compared to osteopenia and osterporosis. Are the differences in mean calcium intake clinically meaningful? If so, what might account for the lack of statistical significance?

One-Way ANOVA in R

The video below by Mike Marin demonstrates how to perform analysis of variance in R. It also covers some other statistical issues, but the initial part of the video will be useful to you.

Two-Factor ANOVA

The ANOVA tests described above are called one-factor ANOVAs. There is one treatment or grouping factor with k > 2 levels and we wish to compare the means across the different categories of this factor. The factor might represent different diets, different classifications of risk for disease (e.g., osteoporosis), different medical treatments, different age groups, or different racial/ethnic groups. There are situations where it may be of interest to compare means of a continuous outcome across two or more factors. For example, suppose a clinical trial is designed to compare five different treatments for joint pain in patients with osteoarthritis. Investigators might also hypothesize that there are differences in the outcome by sex. This is an example of a two-factor ANOVA where the factors are treatment (with 5 levels) and sex (with 2 levels). In the two-factor ANOVA, investigators can assess whether there are differences in means due to the treatment, by sex or whether there is a difference in outcomes by the combination or interaction of treatment and sex. Higher order ANOVAs are conducted in the same way as one-factor ANOVAs presented here and the computations are again organized in ANOVA tables with more rows to distinguish the different sources of variation (e.g., between treatments, between men and women). The following example illustrates the approach.

Consider the clinical trial outlined above in which three competing treatments for joint pain are compared in terms of their mean time to pain relief in patients with osteoarthritis. Because investigators hypothesize that there may be a difference in time to pain relief in men versus women, they randomly assign 15 participating men to one of the three competing treatments and randomly assign 15 participating women to one of the three competing treatments (i.e., stratified randomization). Participating men and women do not know to which treatment they are assigned. They are instructed to take the assigned medication when they experience joint pain and to record the time, in minutes, until the pain subsides. The data (times to pain relief) are shown below and are organized by the assigned treatment and sex of the participant.

Table of Time to Pain Relief by Treatment and Sex

12

21

15

19

16

18

17

24

14

25

14

21

17

20

19

23

20

27

17

25

25

37

27

34

29

36

24

26

22

29

The analysis in two-factor ANOVA is similar to that illustrated above for one-factor ANOVA. The computations are again organized in an ANOVA table, but the total variation is partitioned into that due to the main effect of treatment, the main effect of sex and the interaction effect. The results of the analysis are shown below (and were generated with a statistical computing package - here we focus on interpretation). 

 ANOVA Table for Two-Factor ANOVA

Model

967.0

5

193.4

20.7

0.0001

Treatment

651.5

2

325.7

34.8

0.0001

Sex

313.6

1

313.6

33.5

0.0001

Treatment * Sex

1.9

2

0.9

0.1

0.9054

Error or Residual

224.4

24

9.4

Total

1191.4

29

There are 4 statistical tests in the ANOVA table above. The first test is an overall test to assess whether there is a difference among the 6 cell means (cells are defined by treatment and sex). The F statistic is 20.7 and is highly statistically significant with p=0.0001. When the overall test is significant, focus then turns to the factors that may be driving the significance (in this example, treatment, sex or the interaction between the two). The next three statistical tests assess the significance of the main effect of treatment, the main effect of sex and the interaction effect. In this example, there is a highly significant main effect of treatment (p=0.0001) and a highly significant main effect of sex (p=0.0001). The interaction between the two does not reach statistical significance (p=0.91). The table below contains the mean times to pain relief in each of the treatments for men and women (Note that each sample mean is computed on the 5 observations measured under that experimental condition).  

Mean Time to Pain Relief by Treatment and Gender

A

14.8

21.4

B

17.4

23.2

C

25.4

32.4

Treatment A appears to be the most efficacious treatment for both men and women. The mean times to relief are lower in Treatment A for both men and women and highest in Treatment C for both men and women. Across all treatments, women report longer times to pain relief (See below).  

Graph of two-factor ANOVA

Notice that there is the same pattern of time to pain relief across treatments in both men and women (treatment effect). There is also a sex effect - specifically, time to pain relief is longer in women in every treatment.  

Suppose that the same clinical trial is replicated in a second clinical site and the following data are observed.

Table - Time to Pain Relief by Treatment and Sex - Clinical Site 2

22

21

25

19

26

18

27

24

24

25

14

21

17

20

19

23

20

27

17

25

15

37

17

34

19

36

14

26

12

29

The ANOVA table for the data measured in clinical site 2 is shown below.

Table - Summary of Two-Factor ANOVA - Clinical Site 2

Source of Variation

Sums of Squares

(SS)

Degrees of freedom

(df)

Mean Squares

(MS)

F

P-Value

Model

907.0

5

181.4

19.4

0.0001

Treatment

71.5

2

35.7

3.8

0.0362

Sex

313.6

1

313.6

33.5

0.0001

Treatment * Sex

521.9

2

260.9

27.9

0.0001

Error or Residual

224.4

24

9.4

Total

1131.4

29

Notice that the overall test is significant (F=19.4, p=0.0001), there is a significant treatment effect, sex effect and a highly significant interaction effect. The table below contains the mean times to relief in each of the treatments for men and women.  

Table - Mean Time to Pain Relief by Treatment and Gender - Clinical Site 2

24.8

21.4

17.4

23.2

15.4

32.4

Notice that now the differences in mean time to pain relief among the treatments depend on sex. Among men, the mean time to pain relief is highest in Treatment A and lowest in Treatment C. Among women, the reverse is true. This is an interaction effect (see below).  

Graphic display of the results in the preceding table

Notice above that the treatment effect varies depending on sex. Thus, we cannot summarize an overall treatment effect (in men, treatment C is best, in women, treatment A is best).    

When interaction effects are present, some investigators do not examine main effects (i.e., do not test for treatment effect because the effect of treatment depends on sex). This issue is complex and is discussed in more detail in a later module. 

Two-way ANOVA in SPSS Statistics

Introduction.

The two-way ANOVA compares the mean differences between groups that have been split on two independent variables (called factors). The primary purpose of a two-way ANOVA is to understand if there is an interaction between the two independent variables on the dependent variable. For example, you could use a two-way ANOVA to understand whether there is an interaction between gender and educational level on test anxiety amongst university students, where gender (males/females) and education level (undergraduate/postgraduate) are your independent variables, and test anxiety is your dependent variable. Alternately, you may want to determine whether there is an interaction between physical activity level and gender on blood cholesterol concentration in children, where physical activity (low/moderate/high) and gender (male/female) are your independent variables, and cholesterol concentration is your dependent variable.

The interaction term in a two-way ANOVA informs you whether the effect of one of your independent variables on the dependent variable is the same for all values of your other independent variable (and vice versa). For example, is the effect of gender (male/female) on test anxiety influenced by educational level (undergraduate/postgraduate)? Additionally, if a statistically significant interaction is found, you need to determine whether there are any "simple main effects", and if there are, what these effects are (we discuss this later in our guide).

Note: If you have three independent variables rather than two, you need a three-way ANOVA . Alternatively, if you have a continuous covariate, you need a two-way ANCOVA .

In this "quick start" guide, we show you how to carry out a two-way ANOVA using SPSS Statistics, as well as interpret and report the results from this test. However, before we introduce you to this procedure, you need to understand the different assumptions that your data must meet in order for a two-way ANOVA to give you a valid result. We discuss these assumptions next.

SPSS Statistics

Assumptions.

When you choose to analyse your data using a two-way ANOVA, part of the process involves checking to make sure that the data you want to analyse can actually be analysed using a two-way ANOVA. You need to do this because it is only appropriate to use a two-way ANOVA if your data "passes" six assumptions that are required for a two-way ANOVA to give you a valid result. In practice, checking for these six assumptions means that you have a few more procedures to run through in SPSS Statistics when performing your analysis, as well as spend a little bit more time thinking about your data, but it is not a difficult task.

Before we introduce you to these six assumptions, do not be surprised if, when analysing your own data using SPSS Statistics, one or more of these assumptions is violated (i.e., is not met). This is not uncommon when working with real-world data rather than textbook examples, which often only show you how to carry out a two-way ANOVA when everything goes well! However, don’t worry. Even when your data fails certain assumptions, there is often a solution to overcome this. First, let’s take a look at these six assumptions:

  • Assumption #1: Your dependent variable should be measured at the continuous level (i.e., they are interval or ratio variables). Examples of continuous variables include revision time (measured in hours), intelligence (measured using IQ score), exam performance (measured from 0 to 100), weight (measured in kg), and so forth. You can learn more about interval and ratio variables in our article: Types of Variable .
  • Assumption #2: Your two independent variables should each consist of two or more categorical , independent groups . Example independent variables that meet this criterion include gender (2 groups: male or female), ethnicity (3 groups: Caucasian, African American and Hispanic), profession (5 groups: surgeon, doctor, nurse, dentist, therapist), and so forth.
  • Assumption #3: You should have independence of observations , which means that there is no relationship between the observations in each group or between the groups themselves. For example, there must be different participants in each group with no participant being in more than one group. This is more of a study design issue than something you would test for, but it is an important assumption of the two-way ANOVA. If your study fails this assumption, you will need to use another statistical test instead of the two-way ANOVA (e.g., a repeated measures design). If you are unsure whether your study meets this assumption, you can use our Statistical Test Selector , which is part of our enhanced guides.
  • Assumption #4: There should be no significant outliers . Outliers are data points within your data that do not follow the usual pattern (e.g., in a study of 100 students' IQ scores, where the mean score was 108 with only a small variation between students, one student had a score of 156, which is very unusual, and may even put her in the top 1% of IQ scores globally). The problem with outliers is that they can have a negative effect on the two-way ANOVA, reducing the accuracy of your results. Fortunately, when using SPSS Statistics to run a two-way ANOVA on your data, you can easily detect possible outliers. In our enhanced two-way ANOVA guide, we: (a) show you how to detect outliers using SPSS Statistics; and (b) discuss some of the options you have in order to deal with outliers.
  • Assumption #5: Your dependent variable should be approximately normally distributed for each combination of the groups of the two independent variables . Whilst this sounds a little tricky, it is easily tested for using SPSS Statistics. Also, when we talk about the two-way ANOVA only requiring approximately normal data, this is because it is quite "robust" to violations of normality, meaning the assumption can be a little violated and still provide valid results. You can test for normality using the Shapiro-Wilk test for normality, which is easily tested for using SPSS Statistics. In addition to showing you how to do this in our enhanced two-way ANOVA guide, we also explain what you can do if your data fails this assumption (i.e., if it fails it more than a little bit).
  • Assumption #6: There needs to be homogeneity of variances for each combination of the groups of the two independent variables . Again, whilst this sounds a little tricky, you can easily test this assumption in SPSS Statistics using Levene’s test for homogeneity of variances. In our enhanced two-way ANOVA guide, we (a) show you how to perform Levene’s test for homogeneity of variances in SPSS Statistics, (b) explain some of the things you will need to consider when interpreting your data, and (c) present possible ways to continue with your analysis if your data fails to meet this assumption.

You can check assumptions #4, #5 and #6 using SPSS Statistics. Before doing this, you should make sure that your data meets assumptions #1, #2 and #3, although you don’t need SPSS Statistics to do this. Just remember that if you do not run the statistical tests on these assumptions correctly, the results you get when running a two-way ANOVA might not be valid. This is why we dedicate a number of sections of our enhanced two-way ANOVA guide to help you get this right. You can find out about our enhanced content as a whole on our Features: Overview page, or more specifically, learn how we help with testing assumptions on our Features: Assumptions page.

In the section, Test Procedure in SPSS Statistics , we illustrate the SPSS Statistics procedure to perform a two-way ANOVA assuming that no assumptions have been violated. First, we set out the example we use to explain the two-way ANOVA procedure in SPSS Statistics.

Testimonials

A researcher was interested in whether an individual's interest in politics was influenced by their level of education and gender. They recruited a random sample of participants to their study and asked them about their interest in politics, which they scored from 0 to 100, with higher scores indicating a greater interest in politics. The researcher then divided the participants by gender (Male/Female) and then again by level of education (School/College/University). Therefore, the dependent variable was "interest in politics", and the two independent variables were "gender" and "education".

Setup in SPSS Statistics

A researcher had previously discovered that interest in politics is influenced by level of education. When participants were classified into three groups according to their highest level of education; namely "school", "college" or "university", in that order; higher education levels were associated with a greater interest in politics. Having demonstrated this, the researcher was now interested in determining whether this effect of education level on interest in politics was different for males and females (i.e., different depending on your gender). To answer this question, they recruited 60 participants: 30 males and 30 females, equally split by level of education (School/College/University) (i.e., 10 participants in each group). The researcher had participants complete a questionnaire that assessed their interest in politics, which they called the "Political Interest" scale. Participants could score anything between 0 and 100, with higher scores indicating a greater interest in politics.

In SPSS Statistics, we separated the individuals into their appropriate groups by using two columns representing the two independent variables, and labelled them gender and education_level . For gender , we coded "males" as 1 and "females" as 2 , and for education_level , we coded "school" as 1 , "college" as 2 and "university" as 3 . The participants' interest in politics – the dependent variable – was entered under the variable name, political_interest . The setup for this example can be seen below:

Data setup for a two-way ANOVA in SPSS

Published with written permission from SPSS Statistics, IBM Corporation.

If you are still unsure how to correctly set up your data in SPSS Statistics to carry out a two-way ANOVA, we show you all the required steps in our enhanced two-way ANOVA guide.

SPSS Statistics procedure for the two-way ANOVA

The General Linear Model > Univariate... procedure below shows you how to analyse your data using a two-way ANOVA in SPSS Statistics when the six assumptions in the previous section, Assumptions , have not been violated. At the end of these 14 steps, we show you how to interpret the results from this test. If you are looking for help to make sure your data meets assumptions #4, #5 and #6, which are required when using a two-way ANOVA and can be tested using SPSS Statistics, you can learn more in our enhanced guides on our Features: Overview page.

Since some of the options in the General Linear Model > Univariate... procedure changed in SPSS Statistics version 25 , we show how to carry out a two-way ANOVA depending on whether you have SPSS Statistics versions 25 , 26 , 27 or 28 (or the subscription version of SPSS Statistics) or version 24 or an earlier version of SPSS Statistics. The latest versions of SPSS Statistics are version 28 and the subscription version . If you are unsure which version of SPSS Statistics you are using, see our guide: Identifying your version of SPSS Statistics .

SPSS Statistics versions 25, 26, 27 and 28 (and the subscription version of SPSS Statistics)

Note: In version 27 , SPSS Statistics introduced a new look to their interface called " SPSS Light ", replacing the previous look for versions 26 and earlier versions , which was called " SPSS Standard ". Therefore, if you have SPSS Statistics versions 27 or 28 (or the subscription version of SPSS Statistics), the images that follow will be light grey rather than blue. However, the procedure is identical .

Two-way ANOVA Menu

Note: You only need to transfer independent variables that have more than two groups into the P ost Hoc Tests for: box. This is why we do not transfer gender .

Two-way ANOVA Post Hoc Variables Transferred

Go to the next page for the SPSS Statistics output, discussion of simple main effects and an explanation of the output. You can ignore the section below, which shows you how to carry out a two-way ANOVA when you have SPSS Statistics version 24 or an earlier version of SPSS Statistics.

SPSS Statistics version 24 and earlier versions of SPSS Statistics

Two-way ANOVA Menu

Go to the next page for the SPSS Statistics output, discussion of simple main effects and an explanation of the output.

  • Search Search Please fill out this field.
  • Business Leaders
  • Math and Statistics

Two-Way ANOVA: What It Is, What It Tells You, vs. One-Way ANOVA

Adam Hayes, Ph.D., CFA, is a financial writer with 15+ years Wall Street experience as a derivatives trader. Besides his extensive derivative trading expertise, Adam is an expert in economics and behavioral finance. Adam received his master's in economics from The New School for Social Research and his Ph.D. from the University of Wisconsin-Madison in sociology. He is a CFA charterholder as well as holding FINRA Series 7, 55 & 63 licenses. He currently researches and teaches economic sociology and the social studies of finance at the Hebrew University in Jerusalem.

hypothesis of 2 way anova

Investopedia / Danie Drankwalter

What Is a Two-Way ANOVA?

ANOVA stands for analysis of variance and tests for differences in the effects of independent variables on a dependent variable. A two-way ANOVA test is a statistical test used to determine the effect of two nominal predictor variables on a continuous outcome variable.

A two-way ANOVA tests the effect of two independent variables on a dependent variable. A two-way ANOVA test analyzes the effect of the independent variables on the expected outcome along with their relationship to the outcome itself. Random factors would be considered to have no statistical influence on a data set, while systematic factors would be considered to have statistical significance .

By using ANOVA, a researcher is able to determine whether the variability of the outcomes is due to chance or to the factors in the analysis. ANOVA has many applications in finance, economics , science, medicine, and social science .

Key Takeaways

  • A two-way ANOVA is an extension of the one-way ANOVA (analysis of variances) that reveals the results of two independent variables on a dependent variable.
  • A two-way ANOVA test is a statistical technique that analyzes the effect of the independent variables on the expected outcome along with their relationship to the outcome itself.
  • ANOVA has many applications in finance, economics, science, medicine, and social science.

Understanding Two-Way ANOVA

An ANOVA test is the first step in identifying factors that influence a given outcome. Once an ANOVA test is performed, a tester may be able to perform further analysis on the systematic factors that are statistically contributing to the data set's variability .

A two-way ANOVA test reveals the results of two independent variables on a dependent variable. ANOVA test results can then be used in an F-test, a statistical test used to determine whether two populations with normal distributions share variances or a standard deviation, on the significance of the regression formula overall.

Analysis of variances is helpful for testing the effects of variables on one another. It is similar to multiple two-sample  t-tests . However, it results in fewer  type 1 errors  and is appropriate for a range of issues. An ANOVA test groups differences by comparing the means of each group and includes spreading out the  variance across diverse sources. It is employed with subjects, test groups, between groups and within groups.

One-Way ANOVA vs. Two-Way ANOVA

There are two main types of analysis of variance: one-way (or unidirectional) and two-way (bidirectional). One-way or two-way refers to the number of independent variables in your analysis of variance test. A one-way ANOVA evaluates the impact of a sole factor on a sole response variable. It determines whether the observed differences between the means of independent (unrelated) groups are explainable by chance alone, or whether there are any statistically significant differences between groups.

A two-way ANOVA is an extension of the one-way ANOVA. With a one-way, you have one independent variable affecting a dependent variable. With a two-way ANOVA, there are two independents. For example, a two-way ANOVA allows a company to compare worker productivity based on two independent variables, such as department and gender. It is utilized to observe the interaction between the two factors. It tests the effect of two factors at the same time.

A three-way ANOVA , also known as three-factor ANOVA, is a statistical means of determining the effect of three factors on an outcome.

Macmillan.com. " Two-Way Analysis of Variance ."

hypothesis of 2 way anova

  • Terms of Service
  • Editorial Policy
  • Privacy Policy

We've updated our Privacy Policy to make it clearer how we use your personal data. We use cookies to provide you with a better experience. You can read our Cookie Policy here.

Informatics

Stay up to date on the topics that matter to you

One-Way vs Two-Way ANOVA: Differences, Assumptions and Hypotheses

Analysis of variance (anova) allows comparisons to be made between three or more groups of data..

A picture of RJ Mackenzie

Complete the form below to unlock access to ALL audio articles.

A key statistical test in research fields including biology, economics and psychology, analysis of variance (ANOVA) is very useful for analyzing datasets. It allows comparisons to be made between three or more groups of data. Here, we summarize the key differences between these two tests, including the assumptions and hypotheses that must be made about each type of test. There are two types of ANOVA that are commonly used, the one-way ANOVA and the two-way ANOVA. This article will explore this important statistical test and the difference between these two types of ANOVA. 

What is a one-way ANOVA?

What are the hypotheses of a one-way anova, what are the assumptions and limitations of a one-way anova, what is a two-way anova, what are the assumptions and limitations of a two-way anova, what are the hypotheses of a two-way anova, interactions in two-way anova, summary: differences between one-way and two-way anova.

One-way vs two-way ANOVA differences char

One-Way Anova Test - Date and Weight

A one-way ANOVA is a type of statistical test that compares the variance in the group means within a sample whilst considering only one independent variable or factor. It is a hypothesis-based test, meaning that it aims to evaluate multiple mutually exclusive theories about our data. Before we can generate a hypothesis, we need to have a question about our data that we want an answer to. For example, adventurous researchers studying a population of walruses might ask “Do our walruses weigh more in early or late mating season?” Here, the independent variable or factor (the two terms mean the same thing) is “month of mating season”. In an ANOVA, our independent variables are organised in categorical groups. For example, if the researchers looked at walrus weight in December, January, February and March, there would be four months analyzed, and therefore four groups to the analysis. A one-way ANOVA compares three or more than three categorical groups to establish whether there is a difference between them. Within each group there should be three or more observations (here, this means walruses), and the means of the samples are compared. 

In a one-way ANOVA there are two possible hypotheses.

  • The null hypothesis (H0) is that there is no difference between the groups and equality between means (walruses weigh the same in different months).
  • The alternative hypothesis (H1) is that there is a difference between the means and groups (walruses have different weights in different months).
  • Normality – that each sample is taken from a normally distributed population
  • Sample independence – that each sample has been drawn independently of the other samples
  • Variance equality – that the variance of data in the different groups should be the same
  • Your dependent variable – here, “weight”, should be continuous – that is, measured on a scale which can be subdivided using increments (i.e. grams, milligrams)

Two-Way ANOVA Example (date, sex and weight)

A two-way ANOVA is, like a one-way ANOVA, a hypothesis-based test. However, in the two-way ANOVA each sample is defined in two ways, and resultingly put into two categorical groups. Thinking again of our walruses, researchers might use a two-way ANOVA if their question is: “Are walruses heavier in early or late mating season and does that depend on the sex of the walrus?” In this example, both “month in mating season” and “sex of walrus” are factors – meaning in total, there are two factors.  Once again, each factor’s number of groups must be considered – for “sex” there will only two groups “male” and “female”. The two-way ANOVA therefore examines the effect of two factors (month and sex) on a dependent variable – in this case weight, and also examines whether the two factors affect each other to influence the continuous variable. 

  • Your two independent variables – here, “month” and “sex”, should be in categorical, independent groups.
  • Variance Equality – That the variance of data in the different groups should be the same
  • Normality – That each sample is taken from a normally distributed population

Because the two-way ANOVA consider the effect of two categorical factors, and the effect of the categorical factors on each other, there are three pairs of null or alternative hypotheses for the two-way ANOVA. Here, we present them for our walrus experiment, where month of mating season and sexare the two independent variables.

  • H0: The means of all month groups are equal
  • H1: The mean of at least one month group is different
  • H0: The means of the sex groups are equal
  • H1: The means of the sex groups are different
  • H0: There is no interaction between the month and gender 
  • H1: There is interaction between the month and gender 

Paired vs Unpaired T-Test: Differences, Assumptions and Hypotheses

Paired vs Unpaired T-Test: Differences, Assumptions and Hypotheses

One-way vs two-way anova differences chart, one-way anova two-way anova definition a test that allows one to make comparisons between the means of three or more groups of data. a test that allows one to make comparisons between the means of three or more groups of data, where two independent variables are considered.  number of independent variables one. two.  what is being compared the means of three or more groups of an independent variable on a dependent variable. the effect of multiple groups of two independent variables on a dependent variable and on each other.  number of groups of samples  three or more. each variable should have multiple samples..

What is a One-Way ANOVA? A one-way ANOVA is a type of statistical test that compares the variance in the group means within a sample whilst considering only one independent variable or factor. It is a hypothesis-based test, meaning that it aims to evaluate multiple mutually exclusive theories about our data.

What are the hypotheses of a One-Way ANOVA? In a one-way ANOVA there are two possible hypotheses. The null hypothesis (H0) is that there is no difference between the groups and equality between means. (Walruses weigh the same in different months) The alternative hypothesis (H1) is that there is a difference between the means and groups. (Walruses have different weights in different months)

What are the assumptions of a One-Way ANOVA? Normality – That each sample is taken from a normally distributed population Sample independence – that each sample has been drawn independently of the other samples Variance Equality – That the variance of data in the different groups should be the same Your dependent variable – here, “weight”, should be continuous – that is, measured on a scale which can be subdivided using increments (i.e. grams, milligrams)

What is a Two-Way ANOVA? A two-way ANOVA is, like a one-way ANOVA, a hypothesis-based test. However, in the two-way ANOVA each sample is defined in two ways, and resultingly put into two categorical groups.

What are the hypotheses of a Two-Way ANOVA? Because the two-way ANOVA consider the effect of two categorical factors, and the effect of the categorical factors on each other, there are three pairs of null or alternative hypotheses for the two-way ANOVA. Here, we present them for our walrus experiment, where month of mating season and gender are the two independent variables. H0: The means of all month groups are equal H1: The mean of at least one month group is different H0: The means of the gender groups are equal H1: The means of the gender groups are different H0: There is no interaction between the month and gender H1: There is interaction between the month and gender

A picture of RJ Mackenzie

ANOVA Test: Definition, Types, Examples, SPSS

Statistics Definitions > ANOVA Contents :

The ANOVA Test

  • How to Run a One Way ANOVA in SPSS

Two Way ANOVA

What is manova, what is factorial anova, how to run an anova, anova vs. t test.

  • Repeated Measures ANOVA in SPSS: Steps

Related Articles

Watch the video for an introduction to ANOVA.

hypothesis of 2 way anova

Can’t see the video? Click here to watch it on YouTube.

An ANOVA test is a way to find out if survey or experiment results are significant . In other words, they help you to figure out if you need to reject the null hypothesis or accept the alternate hypothesis .

Basically, you’re testing groups to see if there’s a difference between them. Examples of when you might want to test different groups:

  • A group of psychiatric patients are trying three different therapies: counseling, medication and biofeedback. You want to see if one therapy is better than the others.
  • A manufacturer has two different processes to make light bulbs. They want to know if one process is better than the other.
  • Students from different colleges take the same exam. You want to see if one college outperforms the other.

What Does “One-Way” or “Two-Way Mean?

One-way or two-way refers to the number of independent variables (IVs) in your Analysis of Variance test.

  • One-way has one independent variable (with 2 levels ). For example: brand of cereal ,
  • Two-way has two independent variables (it can have multiple levels). For example: brand of cereal, calories .

What are “Groups” or “Levels”?

Groups or levels are different groups within the same independent variable . In the above example, your levels for “brand of cereal” might be Lucky Charms, Raisin Bran, Cornflakes — a total of three levels. Your levels for “Calories” might be: sweetened, unsweetened — a total of two levels.

Let’s say you are studying if an alcoholic support group and individual counseling combined is the most effective treatment for lowering alcohol consumption. You might split the study participants into three groups or levels:

  • Medication only,
  • Medication and counseling,
  • Counseling only.

Your dependent variable would be the number of alcoholic beverages consumed per day.

If your groups or levels have a hierarchical structure (each level has unique subgroups), then use a nested ANOVA for the analysis.

What Does “Replication” Mean?

It’s whether you are replicating (i.e. duplicating) your test(s) with multiple groups. With a two way ANOVA with replication , you have two groups and individuals within that group are doing more than one thing (i.e. two groups of students from two colleges taking two tests). If you only have one group taking two tests, you would use without replication.

Types of Tests.

There are two main types: one-way and two-way. Two-way tests can be with or without replication.

  • One-way ANOVA between groups: used when you want to test two groups to see if there’s a difference between them.
  • Two way ANOVA without replication: used when you have one group and you’re double-testing that same group. For example, you’re testing one set of individuals before and after they take a medication to see if it works or not.
  • Two way ANOVA with replication: Two groups , and the members of those groups are doing more than one thing . For example, two groups of patients from different hospitals trying two different therapies.

Back to Top

One Way ANOVA

A one way ANOVA is used to compare two means from two independent (unrelated) groups using the F-distribution . The null hypothesis for the test is that the two means are equal. Therefore, a significant result means that the two means are unequal.

Examples of when to use a one way ANOVA

Situation 1: You have a group of individuals randomly split into smaller groups and completing different tasks. For example, you might be studying the effects of tea on weight loss and form three groups: green tea, black tea, and no tea. Situation 2: Similar to situation 1, but in this case the individuals are split into groups based on an attribute they possess. For example, you might be studying leg strength of people according to weight. You could split participants into weight categories (obese, overweight and normal) and measure their leg strength on a weight machine.

Limitations of the One Way ANOVA

A one way ANOVA will tell you that at least two groups were different from each other. But it won’t tell you which groups were different. If your test returns a significant f-statistic, you may need to run an ad hoc test (like the Least Significant Difference test) to tell you exactly which groups had a difference in means . Back to Top

How to run a One Way ANOVA in SPSS

hypothesis of 2 way anova

A Two Way ANOVA is an extension of the One Way ANOVA. With a One Way, you have one independent variable affecting a dependent variable . With a Two Way ANOVA, there are two independents. Use a two way ANOVA when you have one measurement variable (i.e. a quantitative variable ) and two nominal variables . In other words, if your experiment has a quantitative outcome and you have two categorical explanatory variables , a two way ANOVA is appropriate.

For example, you might want to find out if there is an interaction between income and gender for anxiety level at job interviews. The anxiety level is the outcome, or the variable that can be measured. Gender and Income are the two categorical variables . These categorical variables are also the independent variables, which are called factors in a Two Way ANOVA.

The factors can be split into levels . In the above example, income level could be split into three levels: low, middle and high income. Gender could be split into three levels: male, female, and transgender. Treatment groups are all possible combinations of the factors. In this example there would be 3 x 3 = 9 treatment groups.

Main Effect and Interaction Effect

The results from a Two Way ANOVA will calculate a main effect and an interaction effect . The main effect is similar to a One Way ANOVA: each factor’s effect is considered separately. With the interaction effect, all factors are considered at the same time. Interaction effects between factors are easier to test if there is more than one observation in each cell. For the above example, multiple stress scores could be entered into cells. If you do enter multiple observations into cells, the number in each cell must be equal.

Two null hypotheses are tested if you are placing one observation in each cell. For this example, those hypotheses would be: H 01 : All the income groups have equal mean stress. H 02 : All the gender groups have equal mean stress.

For multiple observations in cells, you would also be testing a third hypothesis: H 03 : The factors are independent or the interaction effect does not exist.

An F-statistic is computed for each hypothesis you are testing.

Assumptions for Two Way ANOVA

  • The population must be close to a normal distribution .
  • Samples must be independent.
  • Population variances must be equal (i.e. homoscedastic ).
  • Groups must have equal sample sizes .

MANOVA is just an ANOVA with several dependent variables. It’s similar to many other tests and experiments in that it’s purpose is to find out if the response variable (i.e. your dependent variable) is changed by manipulating the independent variable. The test helps to answer many research questions, including:

  • Do changes to the independent variables have statistically significant effects on dependent variables?
  • What are the interactions among dependent variables?
  • What are the interactions among independent variables?

MANOVA Example

Suppose you wanted to find out if a difference in textbooks affected students’ scores in math and science. Improvements in math and science means that there are two dependent variables, so a MANOVA is appropriate.

An ANOVA will give you a single ( univariate ) f-value while a MANOVA will give you a multivariate F value. MANOVA tests the multiple dependent variables by creating new, artificial, dependent variables that maximize group differences. These new dependent variables are linear combinations of the measured dependent variables.

Interpreting the MANOVA results

If the multivariate F value indicates the test is statistically significant , this means that something is significant. In the above example, you would not know if math scores have improved, science scores have improved (or both). Once you have a significant result, you would then have to look at each individual component (the univariate F tests) to see which dependent variable(s) contributed to the statistically significant result.

Advantages and Disadvantages of MANOVA vs. ANOVA

  • MANOVA enables you to test multiple dependent variables.
  • MANOVA can protect against Type I errors.

Disadvantages

  • MANOVA is many times more complicated than ANOVA, making it a challenge to see which independent variables are affecting dependent variables.
  • One degree of freedom is lost with the addition of each new variable .
  • The dependent variables should be uncorrelated as much as possible. If they are correlated, the loss in degrees of freedom means that there isn’t much advantages in including more than one dependent variable on the test.

Reference : SFSU. Retrieved April 18, 2022 from: http://online.sfsu.edu/efc/classes/biol710/manova/MANOVAnewest.pdf

A factorial ANOVA is an Analysis of Variance test with more than one independent variable , or “ factor “. It can also refer to more than one Level of Independent Variable . For example, an experiment with a treatment group and a control group has one factor (the treatment) but two levels (the treatment and the control). The terms “two-way” and “three-way” refer to the number of factors or the number of levels in your test. Four-way ANOVA and above are rarely used because the results of the test are complex and difficult to interpret.

  • A two-way ANOVA has two factors ( independent variables ) and one dependent variable . For example, time spent studying and prior knowledge are factors that affect how well you do on a test.
  • A three-way ANOVA has three factors (independent variables) and one dependent variable. For example, time spent studying, prior knowledge, and hours of sleep are factors that affect how well you do on a test

Factorial ANOVA is an efficient way of conducting a test. Instead of performing a series of experiments where you test one independent variable against one dependent variable, you can test all independent variables at the same time.

Variability

In a one-way ANOVA, variability is due to the differences between groups and the differences within groups. In factorial ANOVA, each level and factor are paired up with each other (“crossed”). This helps you to see what interactions are going on between the levels and factors. If there is an interaction then the differences in one factor depend on the differences in another.

Let’s say you were running a two-way ANOVA to test male/female performance on a final exam. The subjects had either had 4, 6, or 8 hours of sleep.

  • IV1: SEX (Male/Female)
  • IV2: SLEEP (4/6/8)
  • DV: Final Exam Score

A two-way factorial ANOVA would help you answer the following questions:

  • Is sex a main effect? In other words, do men and women differ significantly on their exam performance?
  • Is sleep a main effect? In other words, do people who have had 4,6, or 8 hours of sleep differ significantly in their performance?
  • Is there a significant interaction between factors? In other words, how do hours of sleep and sex interact with regards to exam performance?
  • Can any differences in sex and exam performance be found in the different levels of sleep?

Assumptions of Factorial ANOVA

  • Normality: the dependent variable is normally distributed.
  • Independence: Observations and groups are independent from each other.
  • Equality of Variance: the population variances are equal across factors/levels.

These tests are very time-consuming by hand. In nearly every case you’ll want to use software. For example, several options are available in Excel :

  • Two way ANOVA in Excel with replication and without replication.
  • One way ANOVA in Excel 2013 .

how to run anova in excel

ANOVA tests in statistics packages are run on parametric data. If you have rank or ordered data, you’ll want to run a non-parametric ANOVA (usually found under a different heading in the software, like “ nonparametric tests “).

It is unlikely you’ll want to do this test by hand, but if you must, these are the steps you’ll want to take:

  • Find the mean for each of the groups.
  • Find the overall mean (the mean of the groups combined).
  • Find the Within Group Variation ; the total deviation of each member’s score from the Group Mean.
  • Find the Between Group Variation : the deviation of each Group Mean from the Overall Mean.
  • Find the F statistic: the ratio of Between Group Variation to Within Group Variation.

A Student’s t-test will tell you if there is a significant variation between groups. A t-test compares means, while the ANOVA compares variances between populations. You could technically perform a series of t-tests on your data. However, as the groups grow in number, you may end up with a lot of pair comparisons that you need to run. ANOVA will give you a single number (the f-statistic ) and one p-value to help you support or reject the null hypothesis . Back to Top

Repeated Measures (Within Subjects) ANOVA

A repeated measures ANOVA is almost the same as one-way ANOVA, with one main difference: you test related groups, not independent ones.

It’s called Repeated Measures because the same group of participants is being measured over and over again. For example, you could be studying the cholesterol levels of the same group of patients at 1, 3, and 6 months after changing their diet. For this example, the independent variable is “time” and the dependent variable is “cholesterol.” The independent variable is usually called the within-subjects factor .

Repeated measures ANOVA is similar to a simple multivariate design. In both tests, the same participants are measured over and over. However, with repeated measures the same characteristic is measured with a different condition. For example, blood pressure is measured over the condition “time”. For simple multivariate design it is the characteristic that changes. For example, you could measure blood pressure, heart rate and respiration rate over time.

Reasons to use Repeated Measures ANOVA

  • When you collect data from the same participants over a period of time, individual differences (a source of between group differences) are reduced or eliminated.
  • Testing is more powerful because the sample size isn’t divided between groups.
  • The test can be economical, as you’re using the same participants.

Assumptions for Repeated Measures ANOVA

The results from your repeated measures ANOVA will be valid only if the following assumptions haven’t been violated:

  • There must be one independent variable and one dependent variable.
  • The dependent variable must be a continuous variable , on an interval scale or a ratio scale .
  • The independent variable must be categorical , either on the nominal scale or ordinal scale.
  • Ideally, levels of dependence between pairs of groups is equal (“sphericity”). Corrections are possible if this assumption is violated.

One Way Repeated Measures ANOVA in SPSS: Steps

Watch the video for the steps:

hypothesis of 2 way anova

Step 2: Replace the “factor1” name with something that represents your independent variable. For example, you could put “age” or “time.”

Step 3: Enter the “Number of Levels.” This is how many times the dependent variable has been measured. For example, if you took measurements every week for a total of 4 weeks, this number would be 4.

Step 4: Click the “Add” button and then give your dependent variable a name.

repeated measures analysis of variance

Step 7: Click “Plots” and use the arrow keys to transfer the factor from the left box onto the Horizontal Axis box.

repeated measures anova 4

Step 9: Click “Options”, then transfer your factors from the left box to the Display Means for box on the right.

Step 10: Click the following check boxes:

  • Compare main effects.
  • Descriptive Statistics.
  • Estimates of Effect Size .

Step 11: Select “Bonferroni” from the drop down menu under Confidence Interval Adjustment . Step 12: Click “Continue” and then click “OK” to run the test. Back to Top

In statistics, sphericity (ε) refers to Mauchly’s sphericity test , which was developed in 1940 by John W. Mauchly , who co-developed the first general-purpose electronic computer.

Sphericity is used as an assumption in repeated measures ANOVA. The assumption states that the variances of the differences between all possible group pairs are equal. If your data violates this assumption, it can result in an increase in a Type I error (the incorrect rejection of the null hypothesis) .

It’s very common for repeated measures ANOVA to result in a violation of the assumption. If the assumption has been violated, corrections have been developed that can avoid increases in the type I error rate. The correction is applied to the degrees of freedom in the F-distribution .

Mauchly’s Sphericity Test

Mauchly’s test for sphericity can be run in the majority of statistical software, where it tends to be the default test for sphericity. Mauchly’s test is ideal for mid-size samples. It may fail to detect sphericity in small samples and it may over-detect in large samples. If the test returns a small p-value (p ≤.05), this is an indication that your data has violated the assumption. The following picture of SPSS output for ANOVA shows that the significance “sig” attached to Mauchly’s is .274. This means that the assumption has not been violated for this set of data.

You would report the above result as “Mauchly’s Test indicated that the assumption of sphericity had not been violated, χ 2 (2) = 2.588, p = .274.”

If your test returned a small p-value , you should apply a correction, usually either the:

  • Greehouse-Geisser correction.
  • Huynh-Feldt correction .

When ε ≤ 0.75 (or you don’t know what the value for the statistic is), use the Greenhouse-Geisser correction. When ε > .75, use the Huynh-Feldt correction .

Grand mean ANOVA vs Regression

Blokdyk, B. (2018). Ad Hoc Testing . 5STARCooks Miller, R. G. Beyond ANOVA: Basics of Applied Statistics . Boca Raton, FL: Chapman & Hall, 1997 Image: UVM. Retrieved December 4, 2020 from: https://www.uvm.edu/~dhowell/gradstat/psych341/lectures/RepeatedMeasures/repeated1.html

Two-way ANOVA (without repeated measures)

What is a two-way anova.

Two-way (or two factor) analysis of variance tests whether there is a difference between more than two independent samples split between two variables or factors.

Two-way analysis of variance without repeated measures

What is a factor?

A factor is, for example, the gender of a person with the characteristics male and female, the form of therapy used for a disease with therapy A, B and C or the field of study with, for example, medicine, business administration, psychology and math.

What is a factor?

In the case of variance analysis, a factor is a categorical variable. You use an analysis of variance whenever you want to test whether these categories have an influence on the so-called dependent variable.

For example, you could test whether gender has an influence on salary, whether therapy has an influence on blood pressure, or whether the field of study has an influence on the duration of studies. Salary , blood pressure or study duration are then the dependent variables. In all these cases you can check whether the factor has an influence on the dependent variable.

Since you only have one factor in these cases, you would use a one-way analysis of variance in these cases (except of course for the gender, there we have a variable with only two expressions, there we would use the t-test for independent samples ).

Two factors

Now you may have another categorical variable that you want to include as well. You might be interested in whether:

  • in addition to gender, the highest level of education also has an influence on salary.
  • besides therapy, gender also has an influence on blood pressure.
  • in addition to the field of study, the university attended also has an influence on the duration of studies.

One Factorial vs Two Factor ANOVA

In all three cases you would not have one factor, but two factors each. And since you now have two factors, you must use the two-way analysis of variance.

Using the two-way analysis of variance, you can now answer three things:

  • Does factor 1 have an effect on the dependent variable?
  • Does factor 2 have an effect on the dependent variable?
  • Is there an interaction between factor 1 and factor 2?

Therefore, in the case of one-way analysis of variance, we have one factor from which we create the groups. In the case of two-way analysis of variance, the groups result from the combination of the expressions of the two factors.

One factor vs. two factors

Example two-way ANOVA

Here's an example dataset for a two-way ANOVA in medicine. Let's say we are interested in studying the effect of two factors, "Treatment" and "Gender," on the response variable "Blood Pressure."

In this example, we have two levels of the "Treatment" factor (A and B) and two levels of the "Gender" factor (Male and Female). The "Blood Pressure" measurements are recorded for each participant based on their treatment and gender.

To perform a two-way ANOVA on this dataset, we would test the null hypothesis that there is no interaction between the "Treatment" and "Gender" factors and no main effects of each factor on the "Blood Pressure" response variable.

Three statements can be tested with the 2 way ANOVA, so there are 3 null hypotheses and therefore 3 alternative hypotheses.

Null hypotheses Alternative hypotheses
There are significant differences in the mean between the groups (factor levels) of the first factor. There is a significant difference in the mean between the groups (factor levels) of the first factor.
There are significant differences in the mean between the groups (factor levels) of the second factor. There is a significant difference in the mean between the groups (factor levels) of the second factor.
One factor has effect on the effect of the other factor. One factor has an effect on the effect of the other factor.

Assumptions

For a two-way analysis of variance to be calculated without repeated measures, the following assumptions must be met:

  • The scale level of the dependent variable should be metric, and that of the independent variables (factors) nominal.
  • Independence: The measurements should be independent, i.e. the measured value of one group should not be influenced by the measured value of another group. If this were the case, we would need an analysis of variance with repeated measures.
  • Homogeneity: The variances in each group should be approximately equal. This can be checked with Levene's test .
  • Normal distribution: The data within the groups should be normally distributed.

So the dependent variable could be, for example, salary, blood pressure, and study duration. These are all metric variables. And the independent variable should be nominally or ordinally scaled. For example, gender, highest level of education, or a type of therapy. Note, however, that rank order is not used with ordinal variables, so this information is lost.

Calculate two-way ANOVA

To calculate a two-way ANOVA, the following formulas are needed. Let's look at this with an example.

Two-factor ANOVA formula

Let's say you work in the marketing department of a bank and you want to find out if gender and the fact that a person has studied or not have an influence on their attitude towards retirement planning.

In this example, your two independent variables (factors) are gender (male or female) and study (yes or no). Your dependent variable is attitude toward retirement planning, where 1 means "not important" and 10 means "very important."

Two-Factor ANOVA Sample Data

After all, is attitude toward retirement planning really a metric variable? Let's just assume that attitude toward retirement planning was measured using a Likert scale and thus we consider the resulting variable to be metric.

Mean values

In the first step we calculate the mean values of the individual groups, i.e. of male and not studied, which is 5.8 then of male and studied, which is 5.4, we now do the same for female.

Then we calculate the mean of all male and female and of not studied and studied respectively. Finally, we calculate the overall mean as 5.4.

Sums of squares

With this, we can now calculate the required sums of squares. SS tot is the sum of squares of each individual value minus the overall mean.

Two-factor ANOVA Sum of squares

SS btw results from the sum of squares of the group means minus the overall mean multiplied by the number of values in the groups.

The sums of squares of the factors SS A and SS B result from the sum of squares of the means of the factor levels minus the total mean.

Now we can calculate the sum of squares for the interaction. These are obtained by calculating SS btw minus SS A minus SS B .

Finally, we calculate the sum of squares for the error. This will calculate similar to the total sum of squares, so again we use each individual value. Only in this case, instead of subtracting the overall mean from each value, we subtract the respective group mean from each value.

Degrees of freedom

The required degrees of freedom are as follows:

2 way ANOVA Degrees of freedom

Mean squares or variance

Together with the sums of squares and the degrees of freedom, the variance can now be calculated:

Two factorial ANOVA Variance

And now we can calculate the F-values. These are obtained by dividing the variance of factor A, factor B or the interaction AB by the error variance.

Two-way analysis of variance F-value

To calculate the p-value, we need the F-value, the degrees of freedom and the F-distribution. We use the F-distribution p-value calculator on DATAtab. Of course, you can also just calculate the example completely with DATAtab, more about that in the next section.

Two-factor ANOVA p-value and critical F-value

This gives us a p-value of 0.323 for Factor A, a p-value of 0.686 for Factor B, and a p-value of 0.55 for the interaction. None of these p-values is less than 0.05 and thus we retain the respective null hypotheses.

Calculating two-way ANOVA with DATAtab

Calculate the example directly with DATAtab for free:

We take the same example from above. The data is now arranged in the form so that your statistics software can do something with it. In each row is a respondent.

Attitude towards retirement planning Studied Gender
6 no male
4 no male
5 no female
... ... ...
5 yes female
9 yes female
2 yes female
3 yes female

This example consists of only 20 cases, which of course is not much, giving us very low test power, but as an example it should fit.

To calculate a two-way analysis of variance online, simply visit datatab.com and copy your own data into this table.

Then click on Hypothesis tests . Under this tab you will find a lot of hypothesis tests and depending on which variable you select, you will get an appropriate hypothesis test suggested.

Calculate two way ANOVA with DATAtab

When you copy your data into the table, the variables appear under the table, if the correct scale level is not automatically detected, you can simply change it by clicking on the scale level itself.

We want to know if gender and whether you have studied or not has an impact on your attitude towards retirement planning. So we just click on all three variables.

DATAtab will now automatically calculate a two-way analysis of variance without repeated measures. DATAtab outputs the three null and the three alternative hypotheses, then the descriptive statistics and the Levene test of equality of variance. With the Levene test you can check if the variances within the groups are equal. The p-value is greater than 0.05, so we assume equality of variance within groups for these data.

Two factorial ANOVA results

Next come the results of the two-way ANOVA.

Interpreting Two Factorial ANOVA

Interpreting two-way ANOVA

The most important in this table are the three marked rows. With these three rows, you can test whether the 3 null hypotheses we made earlier are kept or rejected.

The first row tests you null hypothesis of whether studied or not studied has an effect on attitude towards retirement planning. The second row tests whether gender has an effect on attitude. Finally the third row tests, the interaction between studied and gender.

You can read the p-value in each case right at the last column. Let's say we set the significance level at 5%. If our calculated p-value is less than 0.05, then the null hypothesis is rejected, and if the calculated p-value is greater than 0.05, the null hypothesis is not rejected.

Thus, in this case, we see that all three p-values are greater than 0.05 and thus we cannot reject any of the three null hypotheses.

Therefore, neither whether one has studied or not nor gender has a significant effect on attitudes toward retirement planning. And there is also no significant interaction between studied and gender in terms of attitudes toward retirement planning.

If you don't know exactly how to interpret the results, you can also just click on Summary in Words . In addition, it is important to check in advance whether the assumptions for the analysis of variance are met at all.

Interaction effect

But what exactly does interaction mean? Let us first have a look at this diagram.

Interaction

The dependent variable is plotted on the y axis, in our example: the attitude towards retirement provision. On the x axis, one of the two factors is plotted, let's just take gender. The other factor is represented by lines with different colors. Green is studied and red is not studied .

The endpoints of the lines are the mean values of the groups, e.g. male and not studied.

In this diagram, one can see that both gender and the variable of having studied or not have an influence on attitudes toward retirement planning. Females have a higher value than males and studied have a higher value than not studied.

But now finally to the interaction effects, for that we compare these two graphs.

Interaction effect

In the first case, we said there is no interaction effect. If a person has studied, he has a value that is, say, 1.5 higher than a person who has not studied.

This increase of 1.5 is independent of whether the person is male or female.

It is different in this case, here studied persons also have a higher value, but how much higher the value is depends on whether one is male or female. If I am male, there is a difference of, let's say for example 0.5 and if I am female, there is a difference of 3.5.

So in this case we clearly have an interaction between gender and study because the two variables affect each other. It makes a difference how strong the influence from studying is depending on whether I am male or female.

In this case, we do have an interaction effect, but the direction still remains the same. So females have higher scores than males and studied have higher scores than non-studied.

Statistics made easy

  • many illustrative examples
  • ideal for exams and theses
  • statistics made easy on 412 pages
  • 5rd revised edition (April 2024)
  • Only 8.99 €

Datatab

"Super simple written"

"It could not be simpler"

"So many helpful examples"

Statistics Calculator

Cite DATAtab: DATAtab Team (2024). DATAtab: Online Statistics Calculator. DATAtab e.U. Graz, Austria. URL https://datatab.net

  • Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar

Statistics By Jim

Making statistics intuitive

How to do Two-Way ANOVA in Excel

By Jim Frost 35 Comments

Use two-way ANOVA to assess differences between the group means that are defined by two categorical factors . In this post, we’ll work through two-way ANOVA using Excel. Even if Excel isn’t your main statistical package, this post is an excellent introduction to two-way ANOVA. Excel refers to this analysis as two factor ANOVA.

Excel logo

In this post, I provide step-by-step instructions for using Excel to perform two factor ANOVA and then interpret the results. Importantly, I also include links to many additional resources I’ve written that you won’t find in Excel’s documentation.

Before proceeding, ensure that Excel’s Data Analysis ToolPak is installed for Excel. Click Data in Excel’s menu along the top and look for Data Analysis in the Analyze section.

Excel menu with Data Analysis ToolPak.

If you don’t see Data Analysis, you need to install it. My post about using Excel to perform t-tests shows how to install the Data Analysis ToolPak. It’s free!

Related post : Hypothesis Testing Overview

Two-Way ANOVA in Excel

To perform this analysis, you’ll need two categorical variables , which analysts also refer to as factors. These factors are your independent variables. The number of factors in your analysis determines the name of the ANOVA analysis. One-way ANOVA uses one factor. Two-way ANOVA has two. And, so on. Each factor has a finite number of possible values, which are known as levels. For example, gender is a categorical factor that has the two levels of male and female.

You also need one continuous outcome variable, which is the dependent variable. The various combinations of values for the two categorical variables divide the continuous data into groups. Two-way ANOVA determines whether the mean differences between these groups are statistically significant.

Additionally, two-way ANOVA determines whether the interaction effect between the two factors is statistically significant. When significant interaction effects are present, it’s crucial to interpret them correctly. Because they can be tricky to understand, I’ll spend a little extra time covering interaction effects.

I’ll run through two examples to explain the differences between cases where the interaction effect is and is not significant. Download the CSV dataset for both examples: Two-Way ANOVA . These data are fictional.

To learn more about ANOVA tests, including the more complex forms, read my ANOVA Overview .

Choose Two Factor ANOVA in Excel

To perform two-way ANOVA in Excel, choose one of the two factor ANOVA options, as shown below. You can choose analyses for designs that either have replications or do not have replications.

Excel's data analysis popup with two-factor ANOVA with replication selected.

Replication in this context refers to collecting multiple observations for each group. For instance, in the first analysis example in this post, we’ll look at gender and college major to determine whether these factors correspond to statistically significant income differences. If we collect only one observation per group (e.g., one female who majors in statistics ), we’d use the “without replication” analysis. However, that produces a tiny sample size. Therefore, we’ll use the “with replication” option so we can have multiple observations per group. For both of the examples, we’ll have 20 observations per group.

Excel can only perform balanced two-way ANOVA. In balanced designs, all groups have an equal number of observations.

Related post : How to do One-Way ANOVA in Excel

Example Two-Way ANOVA without a Significant Interaction

Imagine that we are assessing annual salaries, which is our continuous dependent variable. Our two categorical factors are gender and college major. For this analysis, we’ll use the three majors of statistics, psychology, and political science. The combination of these two factors (2 genders X 3 majors) produces the following six groups. Each group contains 20 observations.

Male / Statistics: $77,743 Female / Statistics: $74,074
Male / Psychology: $69,766 Female / Psychology: $65,320
Male / Political Science: $62,015 Female / Political Science: $55,195

The dollar amount indicates the average income for each group. Two-way ANOVA determines whether the observed differences between means provide strong enough evidence to conclude that the population means are different. Let’s perform the analysis!

In Excel, do the following steps:

  • Click Data Analysis on the Data tab.
  • From the Data Analysis popup, choose Anova: Two-Factor With Replication .
  • Under Input , select the ranges for all columns of data.
  • In Rows per sample , enter 20 . This represents the number of observations per group.
  • Excel uses a default Alpha value of 0.05, which is usually a good value. Alpha is the significance level . Change this value only when you have a specific reason for doing so.

For this example, the popup should look like this:

Excel's two-factor ANOVA popup for this example.

Interpreting Excel’s Two-Way ANOVA Results

Statistical output for this two-way ANOVA example.

First, look in the P-value column in the ANOVA Source of Variation table at the bottom of the output. Because the p-values for both Gender and Major are less than our significance level, these factors are statistically significant. These are the main effects in the model. Note that these p-values are so low that Excel uses scientific notation to represent them. Learn about How to Use Scientific Notation .

On the other hand, the interaction effect is not significant because its p-value (0.151) is greater than our significance level. Because the interaction effect is not significant, we can focus on only the main effects.

The main effects are the portion of the relationship between an independent variable and the dependent variable that does not change based on the values of the other variables in the model. For example, gender’s main effect on average income does not change from one major to another. It’s a consistent effect across majors. Males have a higher average income, and that effect is consistent (plus or minus random error) across majors.

Summary Table Information

The Summary table in the top portion displays mean incomes for our six groups. These means range from a low of $55,191 for female political science majors to a high of $77,743 for male statistics majors. Our sample means are different. Importantly, the significant p-values indicate that our sample data provide strong enough evidence to conclude that the population means of these six groups are not equal.

Overall, males tend to have higher average incomes across the majors. Additionally, statistics majors tend to have the largest average salary.

If we had obtained insignificant p-values for Gender and Major, the sample differences between group means might represent random sampling error rather than differences between the population means.

For more information about the other statistics in the output, click the links for F-value and F critical value , degrees of freedom (df) , average (mean) , variance , p-values , and significance level .

Two-Way ANOVA Example 2 with a Significant Interaction

In the previous example, the interaction effect was not significant. Consequently, it was a simple matter to interpret the main effects. How do you understand interaction effects? To emphasize how these effects work, I’ll use an intentionally silly example to make it more intuitive.

Imagine that we’re performing a taste test, and the dependent variable is Enjoyment. Our two factors are Food and Condiment. We want to determine which condiment produces the most enjoyment. To keep things simple, we’ll include only two foods (ice cream and hot dogs) and two condiments (chocolate sauce and mustard) in our analysis.

I think of interaction effects as an “it depends” effect.

Interaction effects indicate that another variable influences the relationship between an independent and dependent variable. This type of effect makes the model more complex, but if it accurately reflects the real world, it is critical to know how to interpret it. For example, the relationship between condiments and enjoyment probably depends on the type of food.

  • Excel uses a default Alpha value of 0.05, which is usually a good value. Alpha is the significance level. Change this value only when you have a specific reason for doing so.

Excel's two-way ANOVA popup for this example.

First, look in the P-value column in the ANOVA Source of Variation table at the bottom of the output. The p-values indicate that Food is not significant (p = 0.801) , while Condiment is statistically significant (p = 0.001). These are the main effects. The significance of Condiment suggests that a portion of the relationship between Condiment and Enjoyment does not change based on the value of the other independent variable.

However, the extremely low p-value for the interaction effect is also statistically significant. In general, interaction effects indicate that the relationship between an independent variable and a dependent variable changes based on the value of another variable.

For our ANOVA model, the significant interaction indicates that the relationship between Condiment and Enjoyment depends on the type of food. That makes sense when you think about it. You might like chocolate sauce quite a bit, but I bet you’d find it disgusting on hot dogs!

Interaction Effects in Depth

If only the main effects are significant, you’d be able to state that either chocolate sauce or mustard always increased your satisfaction the most and by a consistent amount regardless of the food. But that’s not how it works with food and condiments!

When you have statistically significant interaction effects, you can’t interpret the main effects without considering the interactions. In the previous example, you can’t answer the question about which condiment is better without knowing the type of food. Sometimes mustard is better while other times chocolate sauce is better. Again, “it depends.”

It’s often easiest to interpret an interaction effect using specialized plots known as interaction plots. Unfortunately, Excel can’t create these plots. However, you can look at the means for each group to get an idea of how it works. The hot dog/mustard group (89.6) and the ice cream/chocolate sauce group (93.0) each have relatively high enjoyment scores. Conversely, hot dog/chocolate sauce group (65.3) and ice cream/mustard group (61.3) have lower scores. That makes sense intuitively. However, to explain the changing relationship between Condiment and Enjoyment statistically, you need to include the interaction effect.

To learn more about interaction effects in more detail and with graphs, see my post Understanding Interaction Effects .

What Excel Does Not Include

While it’s fantastic that Excel allows you to perform two-way ANOVA, it doesn’t have all the features that a full-blown statistical package provides. As I mentioned, the easiest way to understand interaction effects is by using interaction plots. Unfortunately, Excel can’t create them.

Excel can analyze only balanced designs. If your groups have an unequal number of observations, you’ll need to use other software.

If you need to control for a covariate, you’ll need to perform an Analysis of Covariance (ANCOVA) instead. Unfortunately, that’s not an option in Excel.

Additionally, significant ANOVA results only indicate that not all group means are equal. If you want to determine whether the mean differences between specific pairs of groups are statistically significant, you’ll need to use a post hoc analysis .

It’s always good practice to check the residual plots to be sure you’re not violating an assumption. Unfortunately, Excel can’t create them.

Share this:

hypothesis of 2 way anova

Reader Interactions

' src=

July 15, 2024 at 6:49 am

I would like to learn how to do a two-factor ANOVA, with repeated measures on one factor, in Excel.

Using your example data (statisticsbyjim.com/anova/two-way-anova-excel), I can repeat your well-structured and pedagogical tutorial in Excel on my computer.

However, I’m having problems with my own data. Here’s a link to my data (CSV-formatted): https://drive.google.com/file/d/1heLpfN3xuwX2Su3U_CufGk4CryD0aabr/view?usp=sharing

I make it work in SPSS and jamovi but fail to repeat it in Excel. I describe my problem at timestamp 0:49 in this video: https://www.youtube.com/watch?v=JfueFlLcKtg

Any input is greatly appreciated.

' src=

May 9, 2024 at 1:46 am

Hi Jim, in this example the gender factor is significant, yet we say there is no variation in the mean income given gender. While new to interpretation of ANOVA, I would think that with a significant result for the gender factor, we would reject the null and accept the alternative hypothesis that says the mean incomes in the gender factor are different. ??

' src=

May 9, 2024 at 4:41 pm

Hi Brandon,

Yes, that is correct that gender is significant. For these data, males have a consistently higher mean income across the majors.

I think what you’re referring to is that the interaction effect between gender and major is not significant. So, mean male income is consistently higher across majors, indicating that the mean difference in genders does not change by major. If the interaction between gender and major had been significant, then the mean difference between male and female incomes would depend (or vary) based on major. But it doesn’t for these data.

I hope that makes that distinction clear. The main effects of gender and major are significant but the interaction effect between them is not significant.

' src=

May 7, 2024 at 3:36 pm

Jim This post would be a lot more useful if you gave us the sample data set up. For example, you have three categories of degrees, but your data input has four columns. Is one of those columns a category for gender? It just seems like you’re missing some information for us.

May 7, 2024 at 9:01 pm

Michael, it appears that you need to read the article more carefully. I’ve included a link to download the dataset and the article tells you exactly what you need to do in Excel, including how to fill in the popup boxes. I have both written instructions and screenshots showing what you need to do. I don’t what more you need.

' src=

April 12, 2022 at 3:47 am

Hi I am trying to use the two-way ANOVA for my research project where I am trying to asses if the interaction of both student personalit and teacher personality have an effect on student GPA. So I have two categorical values that affect quantitative values. I have 2 groups for teacher personality, introversion and extroversion, and 3 groups for student personality; so, sx, sp. I followed the exact instruction on this website and also other websites to carry out the tests but I am just not sure if my results are accurate and there is no one to help me asses the accuracy of these results or how to interprete it even if they are accurate. While doing the test I first put the teacher categories to the first column then the student categories to the first row and put down the GPA’s of students that fit into these categories that I have collected with a form but Excel game me #NUM ! for sample and interaction. I then ran the tests by putting the teachers in first column, then the students in the second column, and gpas in the third column but when I did that Excel didn’t let me put words into the second column so I performed it by assigning numbers to the student personalities that gave me the most accurate looking table (to my opinion, because I only look at the p-values and if there has been any error or not because I don’t know what any of the data mean) by many variations of how to write these data. So in short, I don’t if the problem is how I write my data, how I run the test, if my data is even appropriate for ANOVA or something else. I’ll appreciate any type of feedback, thanks already.

' src=

March 28, 2022 at 9:39 pm

Regarding the the Food and Condiment example, how were the enjoyment scores calculated? Was there a scale included (i.e., how were the responses coded)?

March 28, 2022 at 9:43 pm

The data are entirely fictional. In my head, I imagined some sort of survey. I knew someone who did statistical studies for food manufacturers, and they did taste tests with surveys and created their own scales for those purposes. I don’t know the details about that, but the food industry uses measurements like that.

So, that’s what I was thinking about when writing that example. But, in reality, I don’t think you would need to ask people about how much they liked mustard on sundaes and chocolate sauce on hot dogs! If you did, they would probably give you a strange look and probably refuse!

I just wanted to find some visceral examples that would drive the point home. You can love mustard and you can love chocolate sauce, but if someone asks you which one you’d want on your next bit of food? You’d have to say it depends on the food!

I just figured the repugnant combinations would make the idea of an interaction effect easier to understand before getting into a more scientific example.

I’m so glad to hear that you’re enjoying my book! That makes my day!

' src=

March 16, 2022 at 11:17 am

I can not find Data Analysis in my Excel. Where is it?

March 22, 2022 at 11:19 pm

Hi Michael,

I show you where to find it at the top of this post. If it’s not there, find the directions for how to add it in my post about using Excel with T-Tests , where I cover that near the beginning.

' src=

August 12, 2021 at 5:16 am

Hi Jim. I have one question please. I have scale dependent variable and 2 independent variables, one with 2 categories and the other with 3 categories (between subjects). Data is not normally distributed and there are outliers. So, in this case, I have to use a nonparametric test equivelant to 2 way ANOVA. What is the nonparametric test equivelant to 2-way ANOVA?

Thank you very much

' src=

June 18, 2021 at 12:42 pm

To Jim Frost Sir. as you have described two way anova, I tried and tried to analyse my researach data two Factor-with replication I am getting thereply Input range contains non numeric data with this dialogue my repeated attempts have gone waste please help to solve this error?

' src=

April 25, 2021 at 7:29 am

It helped me a alot thank much sir

' src=

November 26, 2020 at 7:49 am

Hi Jim! Thanks so much for the useful website! Its a big help now when I’m working on my thesis, since its been many years since I studied statistics! I’ve gotten a nice big data set and I feel its a shame that I don’t really know how to best analyze it. I’m trying to decide what kind of tests are best to use. Did I understand correctly that the results you get for the individual “main effects” are different from what you’d get if you did, for example, a t-test to individually test gender vs. income in example 1? Would you normally do both a t-test and an ANOVA, or is the ANOVA enough to see if there is an effect of gender on income?

Thanks! Melanie

' src=

October 21, 2020 at 6:57 am

Great post – very clear! Many thanks

' src=

September 12, 2020 at 12:03 am

Jim, where does Standard Error of the Means come in for the Two-way ANOVA with replications?

' src=

August 10, 2020 at 1:14 pm

My name is Mohammed Atari, I bought copies of your books Introduction to Statistics and Hypothesis Testing. Very interesting books.

I have a question about comparing a number of concentration-time profiles to check if they are equivalent. Each profile has a number of readings at specific time points. For two profiles, I did a paired-sample t-test, however, I am now at a stage where I would like to compare three or more profiles (different conditions). I understand that ANOVA is the way to do so; this method averages data of all subjects within each condition, then compares their means. However, I would like to look at the differences of individual subjects between the conditions, and compare those between subjects.

Please advise and best wishes, Mohammed.

August 10, 2020 at 1:22 pm

Hi Mohammed,

Thank you so much for supporting my ebooks. I really appreciate it! And, I’m thrilled to hear that you found them to be helpful!

To do what you’d like it to do, you’ll need to use a mixed model (both fixed and random factors). This is a more complex model than in any of my books (yet). You’ll need use an ANOVA model and set the profile and time period as fixed factors. Then, be sure that each subject as a unique identifier, and include subject as a random factor.

I detail some of this process in my post about repeated measures ANOVA . In particular, see the example near the end.

It’s a more complicated model, but a good one to use when needed!

I hope this helps!

' src=

July 27, 2020 at 1:00 pm

Hi Prof Jim, As a Business Analyst who has a goal of morphing into Business Intelligence Analyst, I find myself wanting to refresh myself on statistics I learned in my Six Sigma training and biostatistics class I took in grad school, I’m very happy to come upon this site! Thank you for sharing your knowledge!

On this ANOVA topic, I notice that it goes right into how to do these types of analyses. I haven’t been able to find the basic explanation of WHY an ANOVA is used and WHEN I’d resort to it. Could you write a topic just providing that basic context to help orient ourselves?

July 28, 2020 at 12:29 am

In a nutshell, you use ANOVA to determine whether the means of three or more groups are not equal. In one-way ANOVA, you have one factor that divides the data into groups, such as experimental group. In two-way ANOVA, as shown in this post, there are two factors that divide the data into groups, such college major and gender. Basically, use ANOVA when you want to compare group means. If you have just two group means, you can use a t-test. I’ve actually just released an ebook all about hypothesis testing that goes into the whys and whens for all types of hypothesis tests, include ANOVA. It sounds like it’s exactly what you’re looking for.

' src=

July 15, 2020 at 10:31 am

Thanks Prof Jim

This was really a wonderfull explanation for Two way ANOVA in a very simple format.

' src=

June 11, 2020 at 3:40 am

Hi Jim! your explanations are very nice. As i am not very pro to do analysis, still learning. My very basic question is how to select put range in that input box?

Thanks and Regards

' src=

May 25, 2020 at 2:57 pm

Thank you very much for making it crystal clear! I will study in more detail this aspect (factorial design) of this project to better understand if the most relevant factors are confounded or not by the currently lacking information.

May 26, 2020 at 3:53 am

You’re very welcome, Wagner! Best of luck with your analysis!

' src=

May 25, 2020 at 10:21 am

Hi Professor, Would love to get some doubts cleared from you regarding method of analysis in excel for a 3 Factorial Randomized Block Design consisting of FACTOR A( 2 levels), FACTOR B( 8 levels) and FACTOR C (2 levels) with 3 replications.

Thanks in advance.

May 22, 2020 at 4:51 pm

Sorry I was not clear… The following table better describes which combinations of the independent variables I have and the dashes represent what I don’t have:

gravity Y – Y Y N – N N

training Y – Y N Y – Y N

flow restriction Y – N N Y – N N

so, I don’t have:

gravity Y N

training N N

flow restriction Y Y

I was thinking about your suggestion of nested factors, as I don’t have a group of conditions for flow restriction that is specific for each condition of training. I just don’t have any condition for flow restriction when the training was not applied. I’m rather confused, but I think that would not fit nested ANOVA as well…

Thanks, Wagner.

May 24, 2020 at 4:54 pm

I think formatting issues in the comments and my lack of subject area knowledge are hindering us here. It’s still not clear to me which combinations you have and are missing. I see that your design has 8 possible combinations that you can put in the table like below. While I’m not totally clear on what you have and don’t have, I think I have enough information to answer your question broadly.

Two level factorial design

A full factorial design is where you have measured all possible combinations of factor levels. You have a fractional factorial design, which means that you haven’t measured at all possible levels. It’s contains a subset of the combination of the full factorial design. You can still analyze these designs but they confound some of the main effects and 2-way interactions and they cannot be separated from the effects of other higher-order interactions. That’s often OK because researchers frequently assume the higher-order interactions have a negligible effect.

However, determining the specific limitations of your design is beyond what I can determine here. If you analyze it using software that can handle factorial designs, it should tell you which effects are confounded.

I hope that helps!

May 21, 2020 at 9:41 pm

Thank you for another nice post. If I may ask, I have a question about an experimental design:

I have data from an experiment measuring the amount of one protein in three factors (gravity, training, flow restriction), each presenting two levels (yes/no). Up to here, everything seems fine to use three-way ANOVA. I would have one dependent variable (protein amount) and three independent variables. My problem is that I don’t have data for one of the combinations: The flow restriction is a modification of the training, therefore it only exists when training exists (the combinations below do not exist) gravity = yes gravity = no training = no training = no flow restr. = yes flow restr. = yes

In that case, can I consider the variable “flow restriction” as independent? As it depends on the variable “training” to exist.

How should I analyze this? Is three-way ANOVA appropriate?

I also considered using two-way ANOVA (the variable training would have three levels – “yes with restriction”, “yes without restriction” and “no”), but then I would not be able to evaluate the interaction between flow restriction and the other variables.

Thanks in advance!

May 22, 2020 at 1:54 pm

Just to clarify, you don’t have data for one condition, which means you don’t have data for three combinations of conditions? It’s not really clear from your table. You have 6 treatment combinations. How many of those do you have data for?

Would flow restriction be a factor nested within training? Maybe you have a nested design? Three factors but one nested with another.

' src=

May 12, 2020 at 11:16 pm

If my data involves Experimental and control as well as repeated measure(pre,middle and post) s. Can we use One way ANOVA with repeated measures else what method to be adopted

' src=

February 6, 2020 at 6:21 pm

My data involves 2 independent variables (one of which is categorical (drug doses) and one of which is ordinal (time)), and 1 dependent variable (protein expression). I was able to arrange my data in the format for the 2-way ANOVA with repetition following your example.

My groups are ‘drug dose A/Time 1’ (8 measurements), ‘drug dose B/Time 1’ (8 measurements)… and so on, for a total of 3 drug doses and 18 time points. The p-value indicates that the effect of drug dose on protein expression does not depend on the time point.

However, I want to see if the effect on protein expression is significant between drug doses at each time point.

How would I arrange my data to see this? Would I need to use a different test (if so, which one)?

Thank you for your help (and I really like your explanation above)!

February 8, 2020 at 3:31 pm

It sounds like you need to perform post hoc analysis to determine whether differences between different factor levels are significant. You wouldn’t need to necessarily rearrange your data, but you’d need to perform some tests that, unfortunately, Excel does not include. I’m not sure if you’re using Excel, but all dedicated statistical software will include these tests. Read my post of them to learn more!

' src=

November 14, 2019 at 9:02 am

' src=

November 13, 2019 at 9:05 pm

Hi Jim! I appreciate it. Very nice

' src=

November 12, 2019 at 8:47 am

Very good exposition to Two way anova

Comments and Questions Cancel reply

IMAGES

  1. PPT

    hypothesis of 2 way anova

  2. Two Way ANOVA

    hypothesis of 2 way anova

  3. PPT

    hypothesis of 2 way anova

  4. PPT

    hypothesis of 2 way anova

  5. PPT

    hypothesis of 2 way anova

  6. Two-way ANOVA Test: Concepts, Formula & Examples

    hypothesis of 2 way anova

VIDEO

  1. Two-Way ANOVA: Step-wise explanation

  2. Two-way ANOVA in SPSS Statistics

  3. ANOVA one way

  4. #ANOVA two way Lec 01

  5. One-Way ANOVA

  6. Beyond ANOVA Part-4: Two way ANOVA & Two way ANCOVA

COMMENTS

  1. Two-Way ANOVA

    When to use a two-way ANOVA. You can use a two-way ANOVA when you have collected data on a quantitative dependent variable at multiple levels of two categorical independent variables.. A quantitative variable represents amounts or counts of things. It can be divided to find a group mean. Bushels per acre is a quantitative variable because it represents the amount of crop produced.

  2. Two-Way ANOVA: Definition, Formula, and Example

    A two-way ANOVA ("analysis of variance") is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups that have been split on two variables (sometimes called "factors").. This tutorial explains the following: When to use a two-way ANOVA. The assumptions that should be met to perform a two-way ANOVA.

  3. 4.3: Two-Way ANOVA models and hypothesis tests

    We need to extend our previous discussion of reference-coded models to develop a Two-Way ANOVA model. We start with the Two-Way ANOVA interaction model: yijk = α +τj +γk +ωjk +εijk, (4.3.1) (4.3.1) y i j k = α + τ j + γ k + ω j k + ε i j k, where α α is the baseline group mean (for level 1 of A and level 1 of B), τj τ j is the ...

  4. 11.3: Two-Way ANOVA (Factorial Design)

    Two-way analysis of variance (two-way ANOVA) is an extension of one-way ANOVA that allows for testing the equality of \ ... {\text{A} \times \text{B}} = 89.3667/72/7125 = 1.2290\). Add these to complete the ANOVA table. There are three hypothesis tests that we are performing: the strain of hemp plan has an effect on the mean plant height (row ...

  5. Two-Way ANOVA: Definition, Formula, and Example

    A two-way ANOVA ("analysis of variance") is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups that have been split on two variables (sometimes called "factors").. This tutorial explains the following: When to use a two-way ANOVA. The assumptions that should be met to perform a two-way ANOVA.

  6. PDF Week 7 Lecture: Two-way Analysis of Variance (Chapter 12)

    Two-way ANOVA with Equal Replication (see Zar's section 12.1) This is the most common (and simple) type of two-way ANOVA. The two factors in this design ... significant (p-value = 0.6170 > 0.05). The F-statistic for the null hypothesis of no difference between sexes (Ho2) is also not significant (p = 0.0713 > 0.05). However, the F-statistic ...

  7. PDF Chapter 11 Two-Way ANOVA

    Chapter 11 Two-Way ANOVA. Chapter 11Two-Way ANOVAAn analysis method for a quantitative outcome and two categoric. l explanatory variables.If an experiment has a quantitative outcome and two categorical explanatory variables that are de ned in such a way that each experimental unit (subject) can be exposed to any combination of one level of one ...

  8. The Ultimate Guide to ANOVA

    The null hypothesis for each factor is that there is no significant difference between groups of that factor. All of the following factors are statistically significant with a very small p-value. ... Let's use a two-way ANOVA with a 95% significance threshold to evaluate both factors' effects on the response, a measure of growth.

  9. Two-way anova

    A two-way anova is usually done with replication (more than one observation for each combination of the nominal variables). For our amphipods, a two-way anova with replication means there are more than one male and more than one female of each genotype. You can also do two-way anova without replication (only one observation for each combination ...

  10. 4.10: Two-way Anova

    3.421. 4.275. 3.110. Unlike a nested anova, each grouping extends across the other grouping: each genotype contains some males and some females, and each sex contains all three genotypes. A two-way anova is usually done with replication (more than one observation for each combination of the nominal variables).

  11. Interpreting results: Two-way ANOVA

    Two-way ANOVA partitions the overall variance of the outcome variable into three components, plus a residual (or error) term. Therefore it computes P values that test three null hypotheses (repeated measures two-way ANOVA adds yet another P value). ... The null hypothesis is that the mean of each column (totally ignoring the rows) is the same ...

  12. Stats: Two-Way ANOVA

    Hypotheses. There are three sets of hypothesis with the two-way ANOVA. The null hypotheses for each of the sets are given below. The population means of the first factor are equal. This is like the one-way ANOVA for the row factor. The population means of the second factor are equal. This is like the one-way ANOVA for the column factor.

  13. 10.4

    10. 10.4. 10.4 - Two-Way ANOVA. The one-way ANOVA presented in the Lesson is a simple case. In practice, research questions are rarely this "simple.". ANOVA models become increasingly complex very quickly. The two-way ANOVA model is briefly introduced here to give you an idea of what to expect in practice. Even two-way ANOVA can be too ...

  14. Hypothesis Testing

    The hypothesis is based on available information and the investigator's belief about the population parameters. The specific test considered here is called analysis of variance (ANOVA) and is a test of hypothesis that is appropriate to compare means of a continuous variable in two or more independent comparison groups.

  15. Two-way ANOVA in SPSS Statistics

    The two-way ANOVA compares the mean differences between groups that have been split on two independent variables (called factors). The primary purpose of a two-way ANOVA is to understand if there is an interaction between the two independent variables on the dependent variable. For example, you could use a two-way ANOVA to understand whether ...

  16. Two-Way ANOVA: What It Is, What It Tells You, vs. One-Way ANOVA

    Two-Way ANOVA: A statistical test used to determine the effect of two nominal predictor variables on a continuous outcome variable. A two-way ANOVA test analyzes the effect of the independent ...

  17. Understanding the Null Hypothesis for ANOVA Models

    The following examples show how to decide to reject or fail to reject the null hypothesis in both a one-way ANOVA and two-way ANOVA. Example 1: One-Way ANOVA. Suppose we want to know whether or not three different exam prep programs lead to different mean scores on a certain exam. To test this, we recruit 30 students to participate in a study ...

  18. One-Way vs Two-Way ANOVA: Differences, Assumptions and Hypotheses

    A two-way ANOVA is, like a one-way ANOVA, a hypothesis-based test. However, in the two-way ANOVA each sample is defined in two ways, and resultingly put into two categorical groups. ... The two-way ANOVA therefore examines the effect of two factors (month and sex) on a dependent variable - in this case weight, and also examines whether the ...

  19. ANOVA Test: Definition, Types, Examples, SPSS

    The terms "two-way" and "three-way" refer to the number of factors or the number of levels in your test. Four-way ANOVA and above are rarely used because the results of the test are complex and difficult to interpret. A two-way ANOVA has two factors (independent variables) and one dependent variable. For example, time spent studying and ...

  20. Two-way ANOVA • Simply explained

    What is a two-way ANOVA? Two-way (or two factor) analysis of variance tests whether there is a difference between more than two independent samples split between two variables or factors. ... To perform a two-way ANOVA on this dataset, we would test the null hypothesis that there is no interaction between the "Treatment" and "Gender" factors ...

  21. How to do Two-Way ANOVA in Excel

    Two-way ANOVA is a hypothesis test that allows you to compare group means. Like all hypothesis tests, two-way ANOVA uses sample data to infer the properties of an entire population.. In this post, I provide step-by-step instructions for using Excel to perform two factor ANOVA and then interpret the results.

  22. Two Way ANOVA

    An introduction to Two-Way ANOVA with an example. Interaction and Main Effects are explored. Calculations are provided by computer software, focus is on anal...

  23. Two-Way ANOVA

    Testing Hypothesis Using Two-Way ANOVA. When performing a two-way ANOVA, there are three hypotheses to test. The first two determine whether each factor has an effect on the response variable, and ...

  24. Answered: 3) Considering Problem 1 and 2, answer…

    3) Considering Problem 1 and 2, answer the following questions: a) Construct the ANOVA summary table and fill in all values in the table. b) At the 0.01 level of significance, what is the upper-tail critical value from the F distribution? c) State the decision rule for testing the null hypothesis that all four groups have equal population means.