*34*

A two-way ANOVAÂ 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 factors.

The purpose of a two-way ANOVA is to determine how two factors impact a response variable, and to determine whether or not there is an interaction between the two factors on the response variable.

This tutorial explains how to conduct a two-way ANOVA in Stata.

**Example: Two-Way ANOVA in Stata**

In this example we will use the built-in Stata dataset calledÂ *systolicÂ *to perform a two-way ANOVA. This dataset contains the following three variables for 58 different individuals:

- Drug used
- Patientâ€™s disease
- Change in systolic blood pressure

We will use the following steps to perform a two-way ANOVA to find out if the type of drug used and the patientâ€™s disease type has a significant impact in the change in systolic blood pressure.

**Step 1: Load the data.**

First, load the data by typingÂ **webuse systolicÂ **in the command box and clicking Enter.

**StepÂ ****2: View the raw data.**

Before we perform a two-way ANOVA, letâ€™s first view the raw data. Along the top menu bar, go toÂ **Data > Data Editor > Data Editor (Browse)**. This will show us the actual data for all 58 patients:

**Step 3: Perform a two-way ANOVA.**

Along the top menu bar, go toÂ **Statistics > Linear models and related > ANOVA/MANOVA > Analysis of variance and covariance**.

For Dependent variable, chooseÂ *systolic*. Then, click the three dotsÂ â€¦Â next to the dropdown arrow underÂ *Model*.

You will be presented with a new screen. KeepÂ *Factor variableÂ *selected. For Specification, chooseÂ *2-way full factorial* since we are conducting a two-way ANOVA. For variable 1, chooseÂ *drugÂ *and useÂ *DefaultÂ *for the Base. For variable 2, chooseÂ *diseaseÂ *and useÂ *DefaultÂ *for the Base. Then, clickÂ *Add to varlistÂ *at the bottom. Then, clickÂ *OK*.

The original window will appear with drug##disease now filled in underÂ *Model*. You donâ€™t need to do anything here again. Simply clickÂ *OK*.

The results of the two-way ANOVA will automatically appear:

From the output we can observe the following:

- There is no significant interaction between drug and disease (p-value = 0.3958)
- Disease has no significant effect on systolic blood pressure (p-value = 0.1637)
- Drug has a statistically significant effect on systolic blood pressure (0.0001)

**Step 4: Report the results.**

Lastly, we will report the results of our two-way ANOVA analysis. Here is an example of how to do so:

A two-way ANOVA was conducted on 58 individuals to examine the effect that drug and disease has on systolic blood pressure.

Â

There was no significant interaction between the effects of drug and disease on systolic blood pressure (p = 0.3958). There was no significant effect of disease on systolic blood pressure (p = 0.1637). There was a significant effect of drug on systolic blood pressure (0.0001).Â