Home » How to Perform a One-Way ANOVA in Stata

# How to Perform a One-Way ANOVA in Stata

one-way ANOVA is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups.

This type of test is called a one-way ANOVA because we are analyzing how one predictor variable impacts a response variable. If we were instead interested in how two predictor variables impact a response variable, we could conduct a two-way ANOVA.

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

## Example: One-Way ANOVA in Stata

In this example we will use the built-in Stata dataset called systolic to perform a one-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 one-way ANOVA to find out if the type of drug used leads to a significant impact in the change in systolic blood pressure.

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 one-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: Visualize the data.

Next, let’s visualize the data. We’ll create boxplots to view the distribution of systolic blood pressure values for each category of drug.

Along the top menu bar, go to Graphics > Box plot. Under variables, choose Systolic: Then, in the Categories subheading under Grouping variable, choose drug: Click OK. A chart with four boxplots will automatically be displayed: We can immediately see that the distribution of changes in systolic blood pressure vary between the drug categories, but a one-way ANOVA will tell us if these differences are statistically significant.

Step 4: Perform a one-way ANOVA.

Along the top menu bar, go to Statistics > Linear models and related > ANOVA/MANOVA > One-Way ANOVA.

Under response variable, choose systolic. Under factor variable, choose drug. Then click the box next to Produce summary table so that we can see some basic descriptive statistics for each group. Then click OK. The following output will be displayed: The F-statistic is 9.09 and the corresponding p-value is 0.0001. Since the p-value is less than alpha = 0.05, we can reject the null hypothesis that the mean change in systolic blood pressure for each group is equal.

In other words, there is a statistically significant difference in the mean change in systolic blood pressure between at least two of the drug groups.

Step 5: Perform multiple comparison tests.

Next, we can perform multiple comparison tests to actually find out which group means are different from each other.

Along the top menu bar, go to Statistics > Summaries, tables, and tests > Summary and descriptive statistics > Pairwise comparisons of means.

For Variable, choose the response variable systolic. For Over, choose the explanatory variable drug. For Multiple comparisons adjustment, choose Tukey’s method. Then, under the Reporting subheading click the button next to Effects tables and check the box next to Show effects table with confidence intervals and p-values. Then click OK. The following results will be displayed: Each row represents a comparison between two specific drug groups. For example, the first row compares the mean systolic blood pressure change between drug group 2 and drug group 1. The p-value for this comparison is 0.999, which is extremely high and not smaller than 0.05. This means there is no statistically significant difference between drug groups 1 and 2.

However, we can see that the p-values for the following comparisons are all less than 0.05:

• drug 3 vs. 1 | p-value = 0.001
• drug 4 vs. 1 | p-value = 0.010
• drug 3 vs. 2 | p-value = 0.001
• drug 4 vs. 2 | p-value = 0.015

This means that the difference in mean systolic blood pressure change is statistically significant between each of these groups.

Step 6: Report the results.

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

A one-way ANOVA was performed to determine if four different types of drugs had different impacts on systolic blood pressure.

The following table summarizes the number of participants in each group along with the mean change in systolic blood pressure and the standard deviation in systolic blood pressure for each group: A one-way ANOVA revealed that there was a statistically significant difference between at least two groups (F(3, 54) = 9.09, p = 0.001).

Tukey’s test for multiple comparisons found that the change in systolic blood pressure was statistically significantly higher for drug 3 compared to drug 1 (17.32 +/- 4.15, p = 0.001), for drug 3 compared to drug 2 (16.78 +/- 4.15, p = 0.001), for drug 4 compared to drug 1 (12.57 +/- 3.85, p = 0.010), and for drug 4 compared to drug 2 (12.03 +/- 3.85, p = 0.015).

There was no statistically significant difference between drug groups 1 and 2 (.533 +/- 3.91, p = 0.999) or between drug groups 3 and 4 (4.75 +/- 4.09, p = 0.654).