The mean square (MS) is the average of the squared deviations of a set of values from their mean, calculated by dividing the sum of squares by its degrees of freedom. In short, it measures the average squared distance between each data point and the group average, and it is the key quantity used in ANOVA and regression to compare variances.
in n | Number of groups | - | 3 | 2 | 100 in df | Degrees of freedom | - | 2 | 1 | 1000 in ss | Sum of squares | - | 40 | 0 | 1000000 out ms | Mean square | - | ss / df | 2 out sd | Std deviation (if df=n-1) | - | sqrt(ss / df) | 2
Formula
The mean square is defined as:
MS = SS / df
Where:
- MS = mean square (unit is the square of the original data unit)
- SS = sum of squares (the total of squared deviations from the mean)
- df = degrees of freedom (the number of independent pieces of information used to calculate SS)
In a simple sample variance, df = n − 1, so MS = SS/(n−1), which is exactly the sample variance. In ANOVA, you compute two mean squares: the mean square between groups (MSB) and the mean square within groups (MSW). The F-ratio is then MSB/MSW.
Worked Example
Using the calculator defaults: 3 groups, df = 2, SS = 40.
- Write the formula: MS = SS / df
- Plug in the numbers: MS = 40 / 2
- Compute: MS = 20
The calculator shows 20.00 as the mean square. The standard deviation (if those 2 degrees of freedom came from n−1 with n=3) would be sqrt(20) = 4.47, which matches the second output.
Why Mean Square Matters
Mean squares are the building blocks of analysis of variance (ANOVA). ANOVA compares the variance between group means to the variance within groups. If the between-group mean square is much larger than the within-group mean square, the group means are unlikely to be equal by chance. The F-test uses this ratio to compute a p-value. In regression, the mean square regression and mean square error are used to test whether the model explains a significant amount of variance.
How to Choose the Right Degrees of Freedom
The degrees of freedom depend on the context:
- Sample variance: df = n − 1 (one parameter, the mean, is estimated)
- One-way ANOVA between groups: df = k − 1, where k is the number of groups
- One-way ANOVA within groups: df = N − k, where N is the total number of observations
- Regression (model): df = p (number of predictors)
- Regression (residual): df = n − p − 1
Using the wrong df is the most common error. For example, if you have 30 observations and 3 groups, the between df is 2, not 29. The within df is 27, not 30.
Common Mistakes and Misconceptions
One frequent mistake is confusing mean square with mean squared error (MSE). In regression, MSE is the residual mean square, but in ANOVA, “mean square” alone usually refers to the between-group MS. Another error is using the total sum of squares divided by n instead of n−1 when estimating variance from a sample. That gives the population variance, which is slightly smaller and biased for samples.
Also, the mean square is not the same as the root mean square (RMS). RMS is the square root of the mean of the squares, often used for signal amplitudes. In contrast, the mean square in statistics is the mean of the squared deviations from the mean, not from zero. For a set of numbers like 2, 4, 6, the RMS is sqrt((4+16+36)/3) = 4.32, while the sample variance mean square is ((2−4)²+(4−4)²+(6−4)²)/2 = 4.
Limitations and When Not to Use
Mean squares assume the data are measured on an interval or ratio scale. They are highly sensitive to outliers because squaring amplifies large deviations. If your data have extreme values, the mean square can be misleading. Also, mean squares are not directly interpretable in the original units—they are in squared units. To get back to the original unit, you take the square root (the standard deviation).
Do not use mean squares to compare groups if the variances are wildly different (heteroscedasticity) or if the data are not approximately normally distributed for small samples. In those cases, consider a nonparametric test like Kruskal–Wallis.
Frequently Asked Questions
What is the difference between mean square and variance?
They are the same when the degrees of freedom are n−1. Variance is defined as the sum of squared deviations divided by n−1 (sample) or n (population). The mean square is a more general term used in ANOVA and regression, where the denominator can be other values of df, not just n−1.
How do I calculate mean square from standard deviation?
Square the standard deviation. If you have a sample standard deviation s, then the mean square (sample variance) is s². For example, if s = 5, then MS = 25. Remember that the standard deviation is the square root of the mean square.
Can mean square be negative?
No. Since squares are always non-negative and degrees of freedom are positive, the mean square is always zero or positive. A negative mean square indicates an error in calculation or an invalid formula.
Why is mean square used in ANOVA instead of variance?
ANOVA partitions the total variance into components (between and within groups). Each component has its own sum of squares and degrees of freedom. The mean square standardizes these sums so they can be compared via the F-ratio. Using raw sums of squares would be misleading because they depend on the number of observations.
What does a large mean square indicate?
A large between-group mean square relative to the within-group mean square suggests the group means are different. However, the absolute size depends on the measurement units. Always compare it to the within-group mean square, not to the raw value.
Alternatives to Mean Square
If your data are not normally distributed or contain outliers, consider using the median absolute deviation (MAD) or the interquartile range (IQR) as robust measures of spread. For comparing groups without assuming equal variances, Welch’s ANOVA uses a different calculation. For regression, you might use the adjusted R², which accounts for the number of predictors, instead of relying solely on mean squares.