Brown-Forsythe test for equality of means in R

Renesh Bedre    3 minute read

Introduction

ANOVA is a widely used method for comparing the means of k independent groups. ANOVA test is valid and more powerful when it meets three basic assumptions including independence of observations within and between groups, homogeneity of variances, and normal distribution of observations.

However, most of the time, assumptions of homogeneity of variances and normality are not satisfied, and the inferences derived from ANOVA under these circumstances may not be valid. ANOVA is less powerful (poor control over type I and II error rates) if the assumption of homogeneity of variances is not satisfied.

Brown-Forsythe test for equality of means is an alternative to ANOVA when the assumption of homogeneity of variance is not satisfied for the ANOVA test.

Brown-Forsythe test hypothesis

Null hypothesis: All group means are equal (no variation in means of groups)
H0: μ12=…=μk (where k is number of groups)

Alternative hypothesis: At least, one group mean is different from other groups
Ha: All μ are not equal

Learn more about hypothesis testing and interpretation

Calculate Brown-Forsythe test in R

We will use the onewaytests R packages for this tutorial.

Get dataset

We will use the iris dataset to check if the sepal lengths of plant species are significantly different or not.

# R version 4.1.2 (2021-11-01) 
# load iris dataset
data("iris")
head(iris, 2)
# output
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa

Check the assumption of homogeneity of variances

We can use ANOVA to compare the means if assumption of homogeneity of variances is satisfied.

We will use the Bartlett’s homogeneity test to check the assumption of equal variance.

bartlett.test(Sepal.Length ~ Species, data = iris)

# output
	Bartlett test of homogeneity of variances

data:  Sepal.Length by Species
Bartletts K-squared = 16.006, df = 2, p-value = 0.0003345

Bartlett’s homogeneity test indicates that variances are not equal among the plant species as p value is significant [χ2 = 16.006, p = 0.00033].

As the assumption of homogeneity of variances is not satisfied, we will use the Brown-Forsythe test for comparing sepal length means among the iris plant species.

Perform Brown-Forsythe test for equal means

We will use the bf.test function from onewaytests package to perform the Brown-Forsythe test

Pass the following parameters to bf.test function,

  • formula : Specify the formula of the form a ~ b, where a (dependent variable), b (treatment groups)
  • data : data frame for formula
library(onewaytests)
bf.test(formula = Sepal.Length ~ Species, data = iris)

# output

  Brown-Forsythe Test (alpha = 0.05) 
------------------------------------------------------------- 
  data : Sepal.Length and Species 

  statistic  : 119.2645 
  num df     : 2 
  denom df   : 123.9255 
  p.value    : 1.317059e-29 

  Result     : Difference is statistically significant. 
------------------------------------------------------------- 

The Brown-Forsythe test results indicate that sepal lengths are significantly different [FBF = 119.26, p < 0.001] among different iris plant species. Hence, we reject the null hypothesis (as p < 0.05) that group (iris plant species) means are equal.

Note: Brown-Forsythe test for equality of means is different than the Brown-Forsythe test for equality of variances. The later test can be performed using the brown.forsythe.test function from the vGWAS package.

Enhance your skills with statistical courses using R

References

If you have any questions, comments, corrections, or recommendations, please email me at reneshbe@gmail.com


This work is licensed under a Creative Commons Attribution 4.0 International License

Some of the links on this page may be affiliate links, which means we may get an affiliate commission on a valid purchase. The retailer will pay the commission at no additional cost to you.