Table of Contents
In advanced statistics, the Analysis of Variance (ANOVA) serves as a powerful inferential tool. It is fundamentally utilized to ascertain whether the means of three or more independent groups differ significantly from one another. By partitioning the total variability observed in a dataset, ANOVA allows researchers to rigorously test hypotheses regarding population means. This statistical procedure is critical across numerous fields, including experimental psychology, biology, and quality control, whenever multiple treatments or conditions are compared simultaneously.
The core mechanism behind ANOVA relies on the concept of variability, which is quantified through three distinct measures known collectively as the Sum of Squares (SS). These values represent different sources of variation within the data. By calculating and comparing these sums of squares, we can derive the F-statistic, which ultimately determines the statistical significance of the differences between our group means. Understanding how to calculate these components is the first and most crucial step in performing an ANOVA test.
Deconstructing the Three Types of Sum of Squares
When conducting a standard one-way ANOVA, three specific Sum of Squares values must always be computed. These components are essential as they form the numerator and denominator for the Mean Squares (MS) calculation, which in turn leads to the F-ratio. Each sum of squares addresses a unique source of variation: the variation explained by the model, the unexplained residual variation, and the total overall variation.
The three fundamental measures of variation used in the ANOVA framework are detailed below. It is important to note the specific reference point used for calculating the squared difference in each case, as this distinction is what allows us to partition the variance effectively.
- Sum of Squares Regression (SSR)
- Also frequently referred to as the Sum of Squares Between Groups or Sum of Squares Treatment, this metric quantifies the variation attributable to the differences between the group means. Specifically, it measures the sum of the squared differences between each group mean and the grand mean.
- Sum of Squares Error (SSE)
- This value, often called Sum of Squares Within Groups or Residual Sum of Squares, represents the unexplained variation in the data. It is the sum of the squared differences between each individual observation and the mean of its respective group. Essentially, SSE captures the variability inherent within each group that is not explained by the difference in treatments.
- Sum of Squares Total (SST)
- The total variation present in the entire dataset, irrespective of group membership. The SST is calculated as the sum of the squared differences between each individual observation and the overall grand mean. The critical relationship in ANOVA is that SST must equal the sum of SSR and SSE (SST = SSR + SSE).
Each of these three calculated values is systematically organized and presented in the final ANOVA table. This table is the culmination of the analysis, providing the necessary metrics—including the Mean Squares and the F-value—to determine conclusively whether a statistically significant difference exists among the group means.
Practical Example: Setting up the One-Way ANOVA Study
To illustrate the calculation process for these sums of squares, consider a typical research scenario. Suppose we are investigating whether three distinct exam preparation programs yield significantly different average scores on a standardized test. This constitutes a classic one-way ANOVA design, where the independent variable is the prep program (with three levels) and the dependent variable is the exam score.
For this study, we recruit a total of 30 students to participate. These students are randomly assigned to one of the three available prep programs, resulting in three groups of 10 students each (n=10 per group). Random assignment helps ensure that any pre-existing differences between students are balanced across the treatment groups, strengthening the internal validity of our findings.
Over the course of three weeks, students exclusively utilize their assigned preparation program. At the conclusion of this period, all 30 students take the same final exam. The data collected consists of the individual exam scores, grouped according to the specific preparation program used. The raw scores for each group are displayed in the image below, providing the foundation for our subsequent calculations:

The subsequent steps demonstrate the meticulous process required to calculate each of the critical Sum of Squares values necessary for this one-way ANOVA analysis.
Step-by-Step Calculation of Sum of Squares (SSR, SSE, SST)
Before we can calculate the individual sums of squares, it is mandatory to establish the foundational means required for the formulas. This involves calculating the mean score for each specific group (Xj) and determining the grand mean (X..) of all 30 observations combined. These means serve as the reference points against which deviations are measured and squared.
Step 1: Calculate the Group Means and the Grand Mean. The calculation results for the mean of Group 1, Group 2, Group 3, and the overall grand mean are summarized in the following figure:

Step 2: Calculate Sum of Squares Regression (SSR). The Sum of Squares Regression (SSR), which measures the variation between groups, is calculated by summing the squared difference between each group mean and the grand mean, weighted by the sample size (n) of each group. The general formula is:
nΣ(Xj – X..)2
Where:
- n: Represents the uniform sample size of group j (n=10 in this case).
- Σ: The Greek symbol Sigma, denoting the operation of summation.
- Xj: The mean score of group j.
- X..: The overall grand mean of all observations.
Applying this formula to our example, the calculation yields the following result: SSR = 10(83.4-85.8)2 + 10(89.3-85.8)2 + 10(84.7-85.8)2 = 192.2
Step 3: Calculate Sum of Squares Error (SSE). Next, we quantify the unexplained variance by calculating the Sum of Squares Error (SSE). This is achieved by summing the squared difference between each individual observation (Xij) and its respective group mean (Xj), across all groups. This value represents the random error within each treatment condition. The formula is written as:
Σ(Xij – Xj)2
Where:
- Σ: The summation symbol.
- Xij: The ith individual observation within group j.
- Xj: The mean score specific to group j.
The detailed calculation for SSE requires finding the within-group variation for each of the three groups and then summing them up:
Group 1: (85-83.4)2 + (86-83.4)2 + (88-83.4)2 + (75-83.4)2 + (78-83.4)2 + (94-83.4)2 + (98-83.4)2 + (79-83.4)2 + (71-83.4)2 + (80-83.4)2 = 640.4
Group 2: (91-89.3)2 + (92-89.3)2 + (93-89.3)2 + (85-89.3)2 + (87-89.3)2 + (84-89.3)2 + (82-89.3)2 + (88-89.3)2 + (95-89.3)2 + (96-89.3)2 = 208.1
Group 3: (79-84.7)2 + (78-84.7)2 + (88-84.7)2 + (94-84.7)2 + (92-84.7)2 + (85-84.7)2 + (83-84.7)2 + (85-84.7)2 + (82-84.7)2 + (81-84.7)2 = 252.1
The total SSE is the sum of these within-group values: SSE = 640.4 + 208.1 + 252.1 = 1100.6
Step 4: Calculate Sum of Squares Total (SST). Finally, the Sum of Squares Total (SST), which represents the total variability in the entire dataset, can be calculated efficiently by summing the SSR and SSE values, confirming the fundamental partitioning principle of ANOVA:
SST = SSR + SSE
Using the previously calculated values, we find that SST = 192.2 + 1100.6 = 1292.8
Constructing and Interpreting the Final ANOVA Table
Once the three critical Sum of Squares values (SSR, SSE, and SST) have been calculated, they are used alongside their corresponding Degrees of Freedom (df) to determine the Mean Squares (MS) and, ultimately, the F-value. The ANOVA table provides a standardized format for presenting these intermediate and final results, allowing for systematic hypothesis testing.
The table below summarizes the results derived from the calculations in our exam prep program example:
| Source | Sum of Squares (SS) | df | Mean Squares (MS) | F-value | p-value |
|---|---|---|---|---|---|
| Regression | 192.2 | 2 | 96.1 | 2.358 | 0.1138 |
| Error | 1100.6 | 27 | 40.8 | ||
| Total | 1292.8 | 29 |
The remaining values in the table—the Mean Squares and the F-value—are derived directly from the Sum of Squares and Degrees of Freedom (df). These derived calculations are crucial for determining the statistical significance of the treatment effect.
The calculations used to complete the ANOVA table are as follows, where k represents the number of groups (k=3) and n represents the total number of observations (n=30):
- df Regression (Between Groups): k – 1 = 3 – 1 = 2
- df Error (Within Groups): n – k = 30 – 3 = 27
- df Total: n – 1 = 30 – 1 = 29
- MS Treatment: SSR / df Regression = 192.2 / 2 = 96.1
- MS Error: SSE / df Error = 1100.6 / 27 = 40.8
- F-value: MS Treatment / MS Error = 96.1 / 40.8 = 2.358
- p-value: This is the probability associated with the calculated F-value (2.358) based on the respective degrees of freedom (2 and 27).
The resulting p-value of 0.1138 is greater than the conventional significance level of 0.05, leading us to conclude that there is insufficient evidence to reject the null hypothesis. Therefore, based on this ANOVA, the mean exam scores across the three prep programs are not statistically different. Further resources are available to guide you on how to correctly interpret the F-value and p-value within the context of the ANOVA table.
Cite this article
Mohammed looti (2025). Understanding Sum of Squares in ANOVA: A Step-by-Step Guide. PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/calculate-sum-of-squares-in-anova-with-example/
Mohammed looti. "Understanding Sum of Squares in ANOVA: A Step-by-Step Guide." PSYCHOLOGICAL STATISTICS, 29 Oct. 2025, https://statistics.arabpsychology.com/calculate-sum-of-squares-in-anova-with-example/.
Mohammed looti. "Understanding Sum of Squares in ANOVA: A Step-by-Step Guide." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/calculate-sum-of-squares-in-anova-with-example/.
Mohammed looti (2025) 'Understanding Sum of Squares in ANOVA: A Step-by-Step Guide', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/calculate-sum-of-squares-in-anova-with-example/.
[1] Mohammed looti, "Understanding Sum of Squares in ANOVA: A Step-by-Step Guide," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, October, 2025.
Mohammed looti. Understanding Sum of Squares in ANOVA: A Step-by-Step Guide. PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.