Understanding Mean Squared Error
Mean squared error represents the average of squared residuals—the differences between actual observations and predicted values. When residuals are squared before averaging, the metric becomes sensitive to large outliers while remaining unaffected by the direction of error.
In regression analysis and forecasting, MSE serves as a primary goodness-of-fit measure. A smaller MSE indicates predictions cluster tightly around actual values, whilst a larger MSE signals systematic bias or high variability. Unlike mean absolute error (MAE), which uses absolute differences, MSE penalises large errors more heavily, making it particularly valuable when outliers are costly mistakes.
The squared units of MSE can obscure interpretation—for instance, predicting temperatures yields MSE in °C². To recover the original scale, practitioners often report root mean squared error (RMSE) instead, which restores dimensional consistency.
Mean Squared Error Formula
Given observed values x1, x2, ..., xn and predicted values y1, y2, ..., yn, the mean squared error is calculated as the average of squared differences:
MSE = (1/n) × Σ(xi − yi)²
SSE = Σ(xi − yi)²
MSE = SSE / n
RMSE = √MSE
n— Number of observations or data pointsx<sub>i</sub>— Observed or actual value at position iy<sub>i</sub>— Predicted value at position iSSE— Sum of squared errors; the numerator before division by nRMSE— Root mean squared error; MSE converted back to original units
Calculating MSE Step by Step
To compute MSE manually, follow this straightforward process:
- Step 1: Calculate the residual for each observation by subtracting the predicted value from the actual value:
residuali = xi − yi - Step 2: Square every residual:
residuali² - Step 3: Sum all squared residuals to obtain SSE
- Step 4: Divide the sum by the sample size n to yield MSE
- Step 5: Optional—take the square root of MSE to obtain RMSE in original units
For example, if actual values are [10, 12, 15] and predictions are [9, 14, 14], residuals are [1, −2, 1], squared residuals are [1, 4, 1], SSE is 6, and MSE is 6 ÷ 3 = 2. The corresponding RMSE is √2 ≈ 1.41.
Common Pitfalls and Practical Considerations
Avoid these frequent mistakes when calculating and interpreting mean squared error.
- Confusing predicted and observed values — Ensure you subtract predictions from observations, not the reverse. The direction matters for interpretation, though squaring eliminates the sign. Consistently label which column contains actuals and which contains forecasts to prevent reversal errors during calculation.
- Forgetting to square before summing — MSE requires squaring individual errors before aggregation. Summing unsquared residuals can yield near-zero totals even when prediction accuracy is poor, since positive and negative errors cancel out. This is precisely why squaring is essential.
- Misinterpreting MSE units — MSE is expressed in squared units of your original data. A temperature MSE of 4 °C² does not mean a 4-degree error. Convert to RMSE (√4 ≈ 2 °C) to report accuracy in the same units as the data, which is more intuitive for stakeholders.
- Using MSE to compare models across different scales — MSE values are only directly comparable when applied to identical datasets with identical target scales. Comparing MSE from a revenue forecast in pounds to an MSE from a revenue forecast in millions requires normalisation. Percentage-based metrics like MAPE or scaled alternatives are more appropriate for cross-dataset comparisons.