How to Perform Scheffe’s Test in R

Spread the love

The Scheffe’s test is a statistical method used to make pairwise comparisons among group means in a one-way ANOVA test. It’s especially useful when you have multiple groups and you want to perform post hoc analysis to see which specific groups are different from each other. While it is considered more conservative than other post hoc tests like Tukey’s HSD, it allows for any number of comparisons, including complex contrasts among means.

In this article, we will cover the detailed steps to perform Scheffe’s Test in R. We will look into how to input data, run one-way ANOVA tests, and finally conduct Scheffe’s post hoc analysis. Sample code snippets will be provided at every step to make the process comprehensible and easy to follow.

Table of Contents

  1. Prerequisites
  2. Data Preparation
  3. Performing One-way ANOVA
  4. Running Scheffe’s Test
  5. Interpretation of Results
  6. Advantages and Disadvantages
  7. Conclusion

1. Prerequisites

Software Requirements

  • R (version 3.6.0 or later)
  • RStudio (optional, but recommended)


  • agricolae

You can install the agricolae package from CRAN by running the following command:


Understanding of One-way ANOVA

A basic understanding of one-way ANOVA is recommended, as Scheffe’s test is usually applied after a significant one-way ANOVA result.

2. Data Preparation

Input Data

Ensure your data is well-structured, usually in a .csv file or a data frame. The data should consist of at least two variables – one categorical (the group identifier) and one continuous (the dependent variable).

Import Data into R

To read a .csv file:

data <- read.csv("your_file_path.csv")

Or, create a data frame:

data <- data.frame(Group = c("A", "A", "B", "B", "C", "C"), Score = c(85, 90, 78, 88, 92, 97))

3. Performing One-way ANOVA

Before running Scheffe’s Test, you should first perform a one-way ANOVA test to see if there are any overall significant differences among the groups.

anova_result <- aov(Score ~ Group, data=data)

4. Running Scheffe’s Test

Load the Package


Perform Scheffe’s Test

To perform Scheffe’s Test:

scheffe_result <- scheffe.test(anova_result, "Group")

Print Results


5. Interpretation of Results

Look at the output to identify pairs with significant differences. You’ll mainly focus on the p-value. If it is less than your alpha level (commonly 0.05), you reject the null hypothesis for that pair, concluding that there is a statistically significant difference between those groups.

6. Advantages and Disadvantages


  • Allows for any number of pairwise comparisons.
  • More flexible in testing complex hypotheses about the means.


  • More conservative, i.e., less powerful, than other post hoc tests.
  • Assumes equal variances and normality in the groups, similar to ANOVA.

7. Conclusion

The Scheffe’s test in R is a powerful method for post hoc analysis following a one-way ANOVA test. It is highly versatile and allows for any number of comparisons, albeit at the cost of reduced test power. Understanding how to execute and interpret this test correctly can offer valuable insights into your data, particularly when dealing with multiple groups. By following this guide, you should be well-equipped to perform Scheffe’s Test in R and interpret the results to identify statistically significant differences between group means.

Posted in RTagged

Leave a Reply