The two-way analysis of variance, or two-way ANOVA, is a statistical method used to compare the mean values of a continuous dependent variable across groups defined by two independent variables (also called factors). This test not only evaluates the main effects of each factor on the dependent variable but also determines whether there is an interaction effect between the two factors.
Two-way ANOVA is commonly employed when researchers want to examine the influence of two independent variables simultaneously and assess whether their combination has a unique effect on the outcome. Unlike a one-way ANOVA, which deals with a single factor, two-way ANOVA explores scenarios where the interaction between factors is of interest. Like one-way ANOVA, post hoc tests can be performed following a significant result to identify specific group differences.
Two-way ANOVA is a statistical method used in situations where researchers are interested in comparing the mean values across groups defined by two independent variables. For example, a researcher may investigate how education levels (high school and lower, bachelor’s degree, graduate degree) and work experience (novice, experienced) interact to affect income. In this example, education level and work experience are the independent variables, also known as factors, and income is the dependent variable, which is continuous.
In ANOVA, an independent variable is referred to as a factor. A factor is a categorical variable with two or more categories or levels. For instance, education attainment is a factor with three levels: high school and lower, bachelor’s degree, and graduate degree, while work experience might have levels such as novice and experienced. Because ANOVA tests are designed to analyze factors and their levels, experimental designs utilizing ANOVA are called factorial designs. If a research design includes two factors, it is called a two-way ANOVA, a term that encompasses the analysis of interactions between multiple independent variables.
The primary purpose of two-way ANOVA is not only to determine whether the individual factors have a significant effect on the dependent variable, but also to assess whether there is a significant interaction effect between them. If the factors overall are statistically significant, pairwise comparisons may be conducted to identify specific group differences. However, if neither factor nor their interaction is statistically significant, the analysis typically concludes there.
In the following sections, we present an example research scenario where a two-way ANOVA will be used to analyze the data. We will demonstrate how to perform a two-way ANOVA in SPSS step-by-step and how to interpret the SPSS results output.
Does the type of physical therapy affect the recovery time of patients after knee surgery? And does the recovery time depend on the severity of the knee surgery?
A health researcher conducts a study to investigate whether different types of physical therapy and the severity of knee injuries influence the recovery time of patients after undergoing knee surgery. The study includes three groups of patients based on the type of physical therapy:
Patients are further categorized based on the severity of their knee injuries: Moderate or Severe. This creates a total of six subgroups (e.g., Moderate severity patients receiving Standard Physical Therapy, Severe severity patients receiving Standard Physical Therapy, etc.).
After the surgery, the researcher records the number of days it takes for each patient to fully recover. Recovery time is defined as the point at which the physical therapist certifies full recovery and the patient feels comfortable walking. Recovery time is measured in days. Patients are randomly recruited from different sites and randomly assigned to both physical therapy groups and severity subgroups to ensure balanced representation.
In this study design, there are two factors: (1) Physical therapy method, with three categories (Standard physical therapy, Advanced physical therapy, No physical therapy or the Control group), and (2) Knee injury severity, with two categories (Moderate, Severe). The dependent variable, recovery time, is continuous. Therefore, a two-way ANOVA is appropriate to address the research question. The two-way ANOVA will evaluate the main effects of physical therapy method and injury severity, as well as the interaction effect between these two factors.
In statistical terms, an interaction effect can be understood as moderation when the effect of one independent variable on the dependent variable is influenced or altered by a second independent variable. In this context, the second variable, often called the moderator, determines the strength, direction, or nature of the relationship between the primary independent variable and the dependent variable. For instance, the effectiveness of a physical therapy method (primary independent variable) on recovery time (dependent variable) might depend on the severity of the patient’s injury (moderator). Here, the severity of injury "moderates" the relationship between the therapy method and recovery time, indicating that the therapy's impact is not uniform across all levels of injury severity. Detecting significant interaction effects, or moderation, often adds valuable insights into the complexities of the relationships being studied.
If the ANOVA results reveal significant effects, post hoc tests can be conducted to determine which specific groups or combinations of factors differ significantly. This design allows the researcher to understand both the independent and combined effects of physical therapy method and injury severity on recovery time.
Table 1 shows the recovery time in days of six patients in three different physical therapy treatments and two different knee injury severities (moderate, serious).
Patient | Physical Therapy Method | Severity | Recovery Time (days) |
---|---|---|---|
P1 | Control | Moderate | 34 |
P11 | Control | Severe | 33 |
P26 | Standard | Moderate | 24 |
P46 | Standard | Severe | 23 |
P51 | Advanced | Severe | 14 |
P65 | Advanced | Moderate | 17 | ... | ... | ... |
The researcher is interested in understanding whether physical therapy method and knee injury severity have an effect on the recovery time of patients after knee surgery. Additionally, the researcher aims to determine which therapy method is most effective and how the severity of the injury may moderate these effects. Patients are categorized by physical therapy methods (Standard, Advanced, and Control) and knee injury severity (Moderate, Severe), creating six groups overall. Recovery time is recorded in days when the physical therapist certifies full recovery and the patient feels comfortable walking. The data for this example can be downloaded in the SPSS format or in CSV format.
To enter the data in the SPSS program for a two-way ANOVA, first click on the Variable View tab (bottom left) and create four variables under Name: Patient, Method, Severity, and Recovery_Time. Specify the following attributes for each variable:
When defining the variables, specify both the data type and the measurement level for SPSS. The data type is used by the program to interpret the data, while the measurement level informs the statistical algorithm for computation. The Patient variable consists of patient IDs and is not included in computation; therefore, select "String" as the data type and "Nominal" as the measurement level. For the Method and Severity variables, assign numbers to the categories. For Method, use "Numeric" as the data type and "Nominal" as the measurement level. Assign values in the Value column:
Similarly, for Severity, assign values:
Finally, for Recovery_Time, use "Numeric" as the data type and "Scale" as the measurement level. After creating all variables, the Variable View panel in SPSS for your dataset should reflect the definitions and assignments for all four variables. Once the variables are defined, switch to the Data View tab in SPSS to enter the data for the columns: Patient, Method, Severity, and Recovery_Time. Figure 1 shows how to create Method levels (Control, Standard, Advanced) and assign numbers to them. The same steps apply for the Severity variable.
The data type for the variable Recovery_Time is also "Numeric," and for the measurement level, we select "Scale." After creating all variables, the Variable View panel of SPSS for our dataset should look like Figure 2.
Once the variables are created, we can enter the data into the columns Patient, Method, and Recovery_Time in the Data View tab of SPSS program. For Patient, we can enter their names or an ID. For the variable Method, we can either directly type the method name (Control, Standard, Advanced), or the values we assigned them during the variable creation step in the Variable View tab (1, 2, 3). In the latter case, we can enter 1 for “Control”, 2 for the “Standard”, and 3 for “Advanced”. Finally, we enter the days of recovery time in the Recovery_Time column. Figure 3 shows how the data for all three variables should look like in the Data View tab.
Now we are ready to conduct the one-way repeated measures ANOVA in SPSS.
A two-way ANOVA is a statistical method used for comparing the means across groups defined by two independent variables. In our study scenario, the health researcher is interested in determining whether different physical therapy methods (Control, Standard, Advanced) and knee injury severity (Moderate, Severe) have a significant effect on the recovery time (in days) of knee injury patients after surgery. The researcher also seeks to understand whether there is an interaction between these two factors that influences recovery time.
In addition to the Standard and Advanced physical therapy groups, the researcher assigns some patients to the Control group, resulting in three levels for the physical therapy factor (Control, Standard, Advanced). Additionally, patients are categorized based on knee injury severity into two groups: Moderate and Severe. This creates six subgroups in total, reflecting every combination of therapy method and injury severity.
In SPSS, the two-way ANOVA test can be accessed from the menu Analyze / General Linear Model / Univariate. So, as Figure 4 demonstrates, we click on Analyze and then choose General Linear Model and then Univariate.
After clicking on Univariate, a window will appear asking for Dependent Variable and the Fixed Factors (i.e., independent variables). We send Recovery_Time into the Dependent Variable box and Method and Severity into the Fixed Factors box. We do not move the Patient variable. Figure 5 shows how the window should be populated with our dependent and independent variables.
While in this window, we click on the Plots button to ask for a plot of the mean values of recovery time by physical therapy group and by the severity of knee injury. So, as Figure 6 shows, we click on the Plots, and send the Method to the Horizontal Axis and Severity to Separate Line and click on Add button and then on Continue button.
In addition to performing a two-way ANOVA, we are also interested in knowing which physical therapy method produces better results (i.e., shorter recovery time). In other words, we would like to compare Standard method against the Control, Advanced method against the Control, and Advanced method against the Standard method. These pair-wise tests are called post hoc tests because they are performed after the two-way ANOVA general (omnibus) test. So, in the open window, we click on Post Hoc and choose the Tukey test (Figure 7). We send the variable Method only to the Post Hoc Test For box because a post hoc test is performed for a factor that has three or more levels. Severity has only two levels (Moderate, Severe), therefore, we do not send it to the Post Hoc Test For box. We click on Continue to go to the parent window.
Other informative statistics that help us in the interpretation of the data and results are descriptive statistics, effect size, and homogeneity tests. So, in the parent window, we click on Options to open the window that shows several analysis options. We check Descriptive statistics, Estimates of effect size, and Homogeneity tests (Figure 8).
We press Continue and finally press the OK button to run the two-way ANOVA.
In this study, the researcher is interested in investigating the effectiveness of the Standard and Advanced physical therapy methods on knee injury patients’ recovery time (in days) while also considering the impact of injury severity. In addition to the Standard and Advanced physical therapy methods, there is a third group that includes the control patients (patients receiving no physical therapy voluntarily). The researcher performs a two-way ANOVA to compare the mean recovery times across the combinations of the physical therapy methods and the levels of severity. The mean recovery times for different combinations of physical therapy methods and knee injury severity are shown in Figure 9 below.
As Figure 9 shows, the recovery time decreases from Control to Standard Method and to Advanced Method of physical therapy. However, within each physical therapy method, the difference between the mean recovery time for Moderate injury (green bars) and Severe injury does not seem noticeable, except for the Advanced Method where recovery time for patients with Severe knee injury was shorter on average than those with Moderate injury, implying an interaction effect. The interaction effect is more evident in the line plot of Figure 10 below.
As the line plot in Figure 10 shows, the two lines are not parallel and intersect each other, implying the presence of an interaction (moderation) effect. We will look at the numerical results of the two-way ANOVA to see if the interaction is statistically significant.
The results of the SPSS two-way ANOVA include a table for the description and sample size within each factor (Between-Subjects Factors), a table for descriptive statistics (Descriptives), a table for the results of the homogeneity of variance test (Levene’s Test of Equality of Error Variance), the ANOVA table (Tests of Between-Subjects Effects), the table of post hoc tests (Multiple Comparisons) and a table showing the Homogenous Subsets. We will go through each of these tables in the output.
The first table in the out is titled Between-Subjects Factors (Figure 11), which includes the names of the two factors (Method and Severity), the number of categories within each factor (3 and 2, respectively) and the sample size in each category of the factor.
Each category of Method includes 25 patients. The Severity factor includes 38 patients in the Moderate severity category and 37 patients in the Severe category. The total number of patients in Method and Severity factors are equal and identical (the patients are the same, one time categorized by the physical therapy Method they receive, and one time categorized by their Severity of knee injury.)
TThe second table in the output is the Descriptive Statistics table (Figure 12), which includes the mean, standard deviation, and the sample size of the intersection of the two factors (cells).
The descriptive statistics table shows that the recovery time is shortest in the Advanced physical therapy Method, and within the Advanced Method patients with Severe injury recovered faster than patients with Moderate knee injury. To check that such a difference is statistically significant, we need to compute the simple effects, which is not in the current two-way ANOVA test output (will be added in an update to this chapter.).
The next table in the output shows the results of the homogeneity of variance test. In ANOVA, we assume that the variances of the dependent variable values in different groups are equal or homogenous, especially when the sample sizes are unequal. Otherwise, the results could be unreliable. The Levenes’ test of homogeneity of variances shows if the variances across the groups are equal (not statistically significantly different from each other). Figure 13 shows the results of the homogeneity test of variance in our example data set.
According to the Levene's test of equality of error variances in Figure 13, the variances across the groups are not significantly different from each other (p = 0.213), and we conclude that the assumption of homogeneity of variance is satisfied.
The next table (Tests of Between-Subjects Effects) shows the two-way ANOVA test results (Figure 14 below).
The column Source includes the sources of variance in the model. The Corrected Model row shows the overall significance of the model, which is statistically significant (F = 202.867, p < 0.01). The Intercept indicates how different the overall mean is from zero, but we usually do not interpret it in the ANOVA test. What we are mostly interested in is the effect of the two factors and their interaction.
Our first factor is physical therapy Method. According to the table above, Method has a statistically significant effect on the recovery time (F = 495.644, p < 0.01). In addition, the effect size (partial eta squared) is very large (0.935), implying the practical significance of the physical therapy Method.
Severity is our second factor in the model. However, the effect of this factor is not statistically significant (F = 1.548, p = 0.218) with very small effect size (partial eta squared = 0.022).
Because we have two factors, SPSS has also analyzed the effect of the interaction between Method and Severity factors on the recovery time. The Method*Severity interaction effect is statistically significant (F = 3.541, p < 0.05). However, the effect size is very small (partial eta squared=0.093).
The R Squared and the Adjusted R Squared show the amount of variance in the dependent variable (recovery time) explained by the factors in the model. We can see in the lower margin of the table the values of R squared and adjusted R squared are 0.936 and 0.932, respectively. Such a high explained variance means that our model is overall very informative in differentiating the effect of Method and Severy effects on recovery time.
Now, we may ask which physical therapy method is better, the Standard or the Advanced? Of course, the descriptive statistics table showed us an apparent answer. But is the difference between the physical therapy methods statistically significant? We can look at the post hoc test results in the Multiple Comparison table to address this question. The multiple comparison table is shown in Figure 15.
According to the Multiple Comparison table above, there are three pairwise comparisons: between Control and Standard (difference in means = 9.880), between Control and Advanced (difference in means = 18.120), and between Standard and Advanced (difference in means = 8.240). The other comparisons are just repeats of these, with order reversed. According to the Sig. column, all mean differences are statistically significant. It implies that patients in Advanced physical therapy treatment method had statistically and significantly shorter recovery time than patients in the Standard treatment method and the Control group. In addition, patients in the Standard treatment group had a statistically significantly shorter recovery time than the Control group, but not shorter than the Advanced group.
The last table in the one-way ANOVA results is the Homogenous Subsets table. A homogenous subsets table creates subsets (columns) and includes in that column the groups which have similar means (not statistically different). The number of subsets (columns) depends on the number of different sets of similar means. For example, if groups 1 and 2 had similar means and both of them were different from group 3, there would be two columns: in column 1 we would have groups 1 and 2 (because they are similar by their means), and in column 2 we would have group 3 because group 3 is different from the set of groups 1 and 2. In our data set, the homogenous table produces three columns each with only one group (shown by numbers 1, 2, 3). Figure 16 shows the homogenous table for physical therapy data.
As Figure 16 shows, there are three subsets (1, 2, 3) and each includes only one group (shown by their means.) For example, subset 1 includes the mean value 16.48 which corresponds to the Advanced group (groups names are shown in the first column Method). Subset 2 includes the mean value of 24.72 (Standard group) and subset 3 includes the mean value 34.60 (Control group). The subsets themselves are significantly different from each other (alpha = 0.05 means a p value of < 0.05). But within each subset, the groups are not different from each other. In our case, there is only one group within a subset, which is not statistically different from itself (hence Sig.=1.000). Homogenous subsets tables are not often used in reporting multiple comparisons.
In this research, we were interested in evaluating the effectiveness of different physical therapy programs while also considering the impact of injury severity on recovery time. A random sample of participants was recruited and randomly assigned to one of the three physical therapy groups: Control (N = 25), Standard physical therapy (N = 25), and Advanced physical therapy (N = 25). Additionally, participants were categorized based on injury severity as either Moderate or Severe. Full recovery from the knee injury was measured in days, as verified and reported by the physical therapist.
The Control group had mean recovery times (M) of 34.70 (SD = 1.767) for Moderate injuries and 34.53 (SD = 2.446) for Severe injuries. The Standard physical therapy group had mean recovery times (M) of 24.38 (SD = 2.599) for Moderate injuries and 25.08 (SD = 1.443) for Severe injuries. The Advanced physical therapy group had mean recovery times (M) of 17.40 (SD = 2.063) for Moderate injuries and 15.10 (SD = 0.876) for Severe injuries.
A two-way ANOVA was conducted to examine the effects of Method and Severity on mean recovery times. The results revealed significant main effects for the Method effect only (p < 0.05), as well as a significant interaction effect between Method and Severity (p < 0.05). Post hoc comparisons using the Tukey HSD test indicated that the Advanced group had significantly shorter recovery times compared to the Standard and Control groups. Additionally, the Standard group demonstrated significantly shorter recovery times compared to the Control group. The interaction effect suggested that the differences in recovery times between the therapy methods were more pronounced for patients with Severe injuries.
These findings indicate that the Advanced physical therapy program is the most effective in reducing recovery times, regardless of injury severity. Moreover, the results highlight the importance of considering injury severity when selecting a physical therapy method to optimize recovery outcomes. These findings provide valuable guidance for clinicians in tailoring physical therapy programs to individual patient needs.