for any fertilizer type.
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:
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.
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.
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:
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:
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.
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.
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:
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.
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:
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).
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.
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:
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.
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.
Methodology
Research 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.
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:
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 .
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/
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.
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:
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:
And we would like to answer the following questions:
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.
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.
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:
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:
She performs a two-way ANOVA in Excel and ends up with the following output:
The last table shows the result of the two-way ANOVA. We can observe the following:
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.
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
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.
> > 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.
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.
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).
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).
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?
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.
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.
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.
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.
Assumptions.
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 |
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 | ||||
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 |
Content preview.
Arcu felis bibendum ut tristique et egestas quis:
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
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.
After completing this module, the student will be able to:
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:
where k = the number of independent comparison groups.
In this example, the hypotheses are:
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.
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)
For the scenario depicted here, the decision rule is: Reject H 0 if F > 2.87.
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
The ANOVA table above is organized as follows.
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.
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.
H 0 : μ 1 = μ 2 = μ 3 = μ 4 H 1 : Means are not all equal α=0.05
The test statistic is the F statistic for ANOVA, F=MSB/MSE.
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.
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 |
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?
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?
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.
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).
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).
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.
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.
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:
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.
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".
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:
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.
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 .
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 .
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 .
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.
Go to the next page for the SPSS Statistics output, discussion of simple main effects and an explanation of the output.
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.
Investopedia / Danie Drankwalter
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 .
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.
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 ."
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.
Stay up to date on the topics that matter to you
Analysis of variance (anova) allows comparisons to be made between three or more groups of data..
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 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
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.
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.
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.
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
Statistics Definitions > ANOVA Contents :
What is manova, what is factorial anova, how to run an anova, anova vs. t test.
Watch the video for an introduction to 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:
One-way or two-way refers to the number of independent variables (IVs) in your Analysis of Variance test.
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:
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.
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.
There are two main types: one-way and two-way. Two-way tests can be with or without replication.
Back to Top
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.
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.
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
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.
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.
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:
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.
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.
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.
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.
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.
A two-way factorial ANOVA would help you answer the following questions:
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 :
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:
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
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.
The results from your repeated measures ANOVA will be valid only if the following assumptions haven’t been violated:
Watch the video for the steps:
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.
Step 7: Click “Plots” and use the arrow keys to transfer the factor from the left box onto the Horizontal Axis box.
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:
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 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:
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
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.
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.
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 ).
Now you may have another categorical variable that you want to include as well. You might be interested in whether:
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:
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.
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. |
For a two-way analysis of variance to be calculated without repeated measures, the following assumptions must be met:
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.
To calculate a two-way ANOVA, the following formulas are needed. Let's look at this with an example.
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."
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.
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.
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.
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.
The required degrees of freedom are as follows:
Together with the sums of squares and the degrees of freedom, the variance can now be calculated:
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.
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.
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.
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.
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.
Next come the results of the 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.
But what exactly does interaction mean? Let us first have a look at this diagram.
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.
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.
"Super simple written"
"It could not be simpler"
"So many helpful examples"
Cite DATAtab: DATAtab Team (2024). DATAtab: Online Statistics Calculator. DATAtab e.U. Graz, Austria. URL https://datatab.net
Statistics By Jim
Making statistics intuitive
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.
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.
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
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 .
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.
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
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:
For this example, the popup should look like this:
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.
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 .
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.
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!
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 .
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.
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.
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. ??
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.
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.
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.
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!
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.
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
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?
April 25, 2021 at 7:29 am
It helped me a alot thank much sir
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
October 21, 2020 at 6:57 am
Great post – very clear! Many thanks
September 12, 2020 at 12:03 am
Jim, where does Standard Error of the Means come in for the Two-way ANOVA with replications?
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!
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.
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.
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
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!
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.
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.
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
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!
November 14, 2019 at 9:02 am
November 13, 2019 at 9:05 pm
Hi Jim! I appreciate it. Very nice
November 12, 2019 at 8:47 am
Very good exposition to Two way anova
IMAGES
VIDEO
COMMENTS
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.
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.
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 ...
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 ...
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.
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 ...
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 ...
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.
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 ...
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).
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 ...
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.
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 ...
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.
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
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...
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 ...
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.