*56*

**Welch’s ANOVA** is an alternative to the typical one-way ANOVA when the assumption of equal variances is violated.

The following step-by-step example shows how to perform Welch’s ANOVA in R.

**Step 1: Create the Data**

To determine if three different studying techniques lead to different exam scores, a professor randomly assigns 10 students to use each technique (Technique A, B, or C) for one week and then makes each student take an exam of equal difficulty.

The exam scores of the 30 students are shown below:

#create data frame df frame(group = rep(c('A','B', 'C'), each=10), score = c(64, 66, 68, 75, 78, 94, 98, 79, 71, 80, 91, 92, 93, 85, 87, 84, 82, 88, 95, 96, 79, 78, 88, 94, 92, 85, 83, 85, 82, 81)) #view first six rows of data frame head(df) group score 1 A 64 2 A 66 3 A 68 4 A 75 5 A 78 6 A 94

**Step 2: Test for Equal Variances**

Next, we can perform Bartlett’s test to determine if the variances between each group is equal.

If the p-value of the test statistic is less than some significance level (like α = .05) then we can reject the null hypothesis and conclude that not all groups have the same variance.

To perform Bartlett’s test we can use the **bartlett.test** function in base R, which uses the following syntax:

**bartlett.test(formula, data)**

Here’s how to use this function in our example:

#perform Bartlett's test bartlett.test(score ~ group, data = df) Bartlett test of homogeneity of variances data: score by group Bartlett's K-squared = 8.1066, df = 2, p-value = 0.01737

The p-value (**.01737**) from Bartlett’s test is less than α = .05, which means we can reject the null hypothesis that each group has the same variance.

Thus, the assumption of equal variances is violated and we can proceed to perform Welch’s ANOVA.

**Step 3: Perform Welch’s ANOVA**

To perform Welch’s ANOVA in R, we can use the **oneway.test()** function from base R as follows:

#perform Welch's ANOVA oneway.test(score ~ group, data = df, var.equal = FALSE) One-way analysis of means (not assuming equal variances) data: score and group F = 5.3492, num df = 2.00, denom df = 16.83, p-value = 0.01591

The overall p-value (**.01591**) from the ANOVA table is less than α = .05, which means we can reject the null hypothesis that the exam scores are equal between the three studying techniques.

We can then perform a post-hoc test to determine which group means are different. Refer to the following tutorials to see how to perform various post-hoc tests in R:

- How to Perform a Bonferroni Correction in R
- How to Perform Tukey’s Test in R
- How to Perform Scheffe’s Test in R

Reference this tutorial to determine which post-hoc test is best to use depending on your situation.

**Additional Resources**

How to Conduct a One-Way ANOVA in R

How to Conduct a Two-Way ANOVA in R

How to Conduct a Repeated Measures ANOVA in R