From Individual Prediction Errors to RMSE
A prediction metric summarizes how far a model’s predictions are from the outcomes that were actually observed. Root mean squared error, usually abbreviated RMSE, makes this summary in two stages: it squares each prediction error, averages the squared errors, and then takes the square root. Carrying out those steps case by case helps prevent sign errors and makes clear how the final number relates to the prediction errors.
For this calculation, suppose there are \(n\) matched pairs: an observed outcome \(y_i\) and a prediction \(\hat{y}_i\) for the same case \(i\). The outcomes and predictions must use the same measurement scale. For example, an observed waiting time in minutes must be compared with a prediction in minutes, not with a prediction in hours. We will define the signed difference as prediction minus observation. Reversing that convention would change the signs, but not the squared errors or RMSE.
The signed error records both direction and size: a positive value means the prediction is above the observed outcome, while a negative value means it is below. RMSE squares the signed errors, so both directions contribute nonnegative values. It is therefore a summary of error size, not a measure of whether predictions tend to be too high or too low. The square root returns the result to the same units as the outcomes.
A Reliable Calculation Sequence
For a small dataset, a table is the clearest way to organize the arithmetic. For each case, calculate \(d_i=\hat{y}_i-y_i\), then \(|d_i|\) and \(d_i^2\). Add the squared errors, divide by the number of cases, and take the nonnegative square root. Keep the absolute-error and squared-error columns separate: they answer different arithmetic questions, and RMSE uses the squared-error column.
Make sure the prediction and observed value belong to the same case and are expressed in the same units.
Find \(d_i=\hat{y}_i-y_i\), and then record the absolute error \(|d_i|\) if it is useful for checking the case-by-case size.
Calculate \(d_i^2\) for every case. Do this before averaging; the mean signed error is not RMSE.
Sum the squared errors, divide by \(n\), and take the square root of that mean squared error.
The observed outcome is sometimes written first when defining an error, as \(y_i-\hat{y}_i\). That alternative changes every signed error’s sign, but not its square: \((y_i-\hat{y}_i)^2=(\hat{y}_i-y_i)^2\). Thus, the RMSE is unchanged, provided the same pairs are used.
Worked Example: Four Predictions in Kilograms
Suppose a hypothetical model predicts the weight of four packages. The observed weights are 10, 12, 15, and 18 kg, and the corresponding predictions are 12, 11, 13, and 20 kg. Calculate RMSE, showing how the unsquared and squared errors differ.
| Case | Observed \(y_i\) (kg) | Predicted \(\hat{y}_i\) (kg) | \(d_i=\hat{y}_i-y_i\) (kg) | \(|d_i|\) (kg) | \(d_i^2\) (kg²) |
|---|---|---|---|---|---|
| 1 | 10 | 12 | 2 | 2 | 4 |
| 2 | 12 | 11 | -1 | 1 | 1 |
| 3 | 15 | 13 | -2 | 2 | 4 |
| 4 | 18 | 20 | 2 | 2 | 4 |
The signed errors are \(2,-1,-2,2\) kg. Their absolute values are \(2,1,2,2\) kg, while their squares are \(4,1,4,4\) kg². The total squared error is \(4+1+4+4=13\) kg². There are \(n=4\) paired cases, so
For these four predictions, the RMSE is about 1.803 kg. This describes the overall error size under the squared-error calculation; it does not say that each prediction is 1.803 kg from its outcome. In this dataset, the individual absolute errors are 2, 1, 2, and 2 kg.
What the Arithmetic Does to the Errors
The middle quantity, the mean squared error, is measured in squared outcome units. If the outcome is measured in kilograms, each \(d_i^2\) and their mean are measured in kg². Taking the square root changes the units back to kilograms. More generally, if outcomes are in minutes, mean squared error is in min² and RMSE is in minutes. This is one reason to report RMSE rather than only the intermediate mean squared error when describing typical prediction error in context.
Here is a brief justification of the calculation’s structure. Each difference \(d_i\) has the outcome’s units. Multiplication by itself gives \(d_i^2\) squared units; adding and averaging quantities in those same squared units preserves those units. The square root then reverses the squaring of the units. Since every \(d_i^2\) is nonnegative, their mean is nonnegative, so its nonnegative square root is defined, including when every prediction is exact.
Squaring also affects how strongly different-sized errors contribute. An error of 6 units contributes \(6^2=36\) squared units, while an error of 2 units contributes \(2^2=4\) squared units. The first contributes nine times as much to the sum of squared errors, even though its magnitude is only three times as large. The square root at the end restores the outcome units; it does not undo the fact that larger errors contributed more heavily to the average of squares.
Worked Example: Waiting-Time Predictions
Suppose predictions are made for three hypothetical appointment waiting times. The observed waits are 20, 35, and 40 minutes; the predictions are 18, 40, and 34 minutes. Calculate RMSE in minutes and distinguish the case-by-case error sizes from the squared values used in the calculation.
| Case | Observed wait (min) | Predicted wait (min) | Signed error (min) | Absolute error (min) | Squared error (min²) |
|---|---|---|---|---|---|
| 1 | 20 | 18 | -2 | 2 | 4 |
| 2 | 35 | 40 | 5 | 5 | 25 |
| 3 | 40 | 34 | -6 | 6 | 36 |
The signed differences are \(18-20=-2\), \(40-35=5\), and \(34-40=-6\) minutes. The absolute errors are 2, 5, and 6 minutes. The corresponding squares are \(4\), \(25\), and \(36\) min², for a total of \(65\) min². Divide by three and take the square root:
The RMSE is approximately 4.655 minutes for these three predictions. The largest absolute error, 6 minutes, contributes 36 min² to the total, while the 2-minute error contributes 4 min². The reported RMSE is in minutes, not minutes squared, and it is not the error for any one specific appointment.
Comparing Two Sets of Predictions
The same arithmetic can summarize predictions from different models when both sets are evaluated on the same observed outcomes. Using matched cases makes the comparison direct: each model is measured against the same outcomes. In the example below, the calculations show how two sets of errors can have different distributions while still being summarized by a single RMSE each.
Worked Example: Two Models on the Same Four Cases
For four hypothetical outcomes measured in points, the observed values are 8, 10, 12, and 14. Model A predicts 9, 11, 11, and 13. Model B predicts 8, 10, 12, and 17. Calculate each model’s RMSE from these four matched cases.
| Case | Observed (points) | Model A prediction | Model A signed error | Model A squared error | Model B prediction | Model B signed error | Model B squared error |
|---|---|---|---|---|---|---|---|
| 1 | 8 | 9 | 1 | 1 | 8 | 0 | 0 |
| 2 | 10 | 11 | 1 | 1 | 10 | 0 | 0 |
| 3 | 12 | 11 | -1 | 1 | 12 | 0 | 0 |
| 4 | 14 | 13 | -1 | 1 | 17 | 3 | 9 |
For Model A, the squared errors sum to \(1+1+1+1=4\) points². Thus,
For Model B, the squared errors sum to \(0+0+0+9=9\) points². Thus,
On these four matched cases, Model A has the smaller RMSE: 1 point, compared with 1.5 points for Model B. Model B predicts three of the outcomes exactly, but its 3-point error contributes \(9\) points². The comparison is specifically about these four predictions and this metric; it does not by itself establish how either model will perform on other cases.
Common Mistakes and Checks
A correct result depends on using the right quantities in the right order. Before interpreting RMSE, check that the observed outcomes and predictions are paired case by case, that they use the same units, and that every included case has a usable observed value and prediction. State which cases were included if some were omitted; changing the included cases changes the calculation.
- Stopping at the mean squared error. The mean of the squared errors is not yet RMSE. Take its square root before reporting the metric in outcome units.
- Using signed errors without squaring. Positive and negative errors can offset in a signed sum. RMSE squares each error, so opposing signs cannot cancel.
- Dividing by the wrong number. For a prediction metric calculated over \(n\) evaluation cases, divide the squared-error sum by \(n\), the number of included pairs.
- Calling RMSE the error on every case. RMSE is one summary of all included cases. Individual errors can be both smaller and larger than it.
- Confusing outcome units with squared units. Individual squared errors and mean squared error use squared units; RMSE uses the original outcome units.
The denominator is worth particular attention. Here RMSE summarizes prediction errors over a specified set of cases, so the mean squared error is \(\sum d_i^2/n\). A different residual summary used in a model-fitting setting may apply a degrees-of-freedom adjustment for a different purpose. Do not substitute such an adjustment into this prediction-metric calculation.
Check Your Understanding
Use the definition and calculation steps to answer the following questions.
- For an observed value of 25 units and a prediction of 22 units, what are the signed error, absolute error, and squared error under the convention used here?
- A set of five cases has a total squared error of 80 kg². Calculate its RMSE, including the units.
- Why does reversing the signed-error convention leave RMSE unchanged?
- A model’s RMSE is 4 minutes. Does that mean every prediction differs from its observed value by exactly 4 minutes? Explain.
- Two models are compared using RMSE. Why is it useful to evaluate both on the same matched cases?