Mean Squared Error — Definition, Formula & Example
Mean squared error (MSE) is the average of the squared differences between predicted values and actual values. Because each error is squared, one big miss raises the MSE far more than several small misses that add up to the same total.
For observed values with predictions , the MSE is the mean of the squared residuals, . It is always , and it equals only when every prediction is exact. For an estimator of a parameter , . In regression output, the row labeled MSE often divides the sum of squared residuals by the degrees of freedom ( for simple linear regression) instead of by .
Key Formula
Where:
- = number of data points
- = actual (observed) value for data point i
- = predicted value for data point i
- = residual (prediction error) for data point i
Worked Example
Problem: A shipping company tests two models that predict package weights. Four packages actually weigh 10, 15, 20, and 25 pounds. Model A predicts 12, 13, 22, and 23 pounds. Model B predicts 10, 15, 20, and 17 pounds. Both models have a mean absolute error of 2 pounds. Find the MSE of each model.
Step 1: Find each residual, actual minus predicted. Model A misses every package by 2 pounds. Model B is perfect on three packages and misses the last one by 8 pounds.
Step 2: Square each residual for Model A, then average.
Step 3: Do the same for Model B. The single 8-pound miss becomes 64 once it is squared.
Answer: Model A has an MSE of 4 square pounds, and Model B has an MSE of 16 square pounds. The mean absolute errors are tied, but MSE ranks Model A as better because squaring heavily penalizes Model B's one large miss.
Why It Matters
The least-squares regression line in AP Statistics is, by definition, the line that makes the sum of squared residuals, and therefore the MSE, as small as possible. MSE is also the standard loss function used to train regression models in machine learning. When you compare a biased estimator with an unbiased one, MSE shows the trade-off between bias and variance.
Common Mistakes
Mistake: Reading an MSE of 16 as "the predictions are typically off by 16 pounds."
Correction: MSE is measured in squared units, here square pounds. Take the square root to get the root mean squared error (RMSE), which is back in pounds. In the example, Model B's RMSE is pounds.
