Residuals: interpret deviations and spot systematic errors

A fit is not judged only by how close the curve is to the data or by the value of R². The residuals plot shows which errors remain after the fit, and the table lets you reconstruct each numerical difference and link it to its original observation.

Reference interface: GX-TXT DEV112-P011 · Dataset Curve Fit.

What is a residual?

For a regression in which the response is Y=f(X), the residual of an observation is the difference between the observed value and the value predicted by the model at the same X coordinate:

rᵢ = Yᵢ − Ŷ(Xᵢ).

The sign is important. A positive residual indicates that the observed point lies above the model; a negative residual indicates that it lies below the fitted curve. The residual is zero when observation and model coincide exactly.

If Y is a voltage in volts, the residuals are also in volts. For an inverse regression X=f(Y), however, the residual refers to the X variable and is expressed in its unit. For geometric or implicit curves the residual has a different meaning and must be read according to the chosen model.

An example: fitting a line to curved data

Open the synthetic Dataset c16_curve_13, which has thirteen observations. Select X = Time (s) and Y = Voltage (V), press Add Dataset curve, then configure Model = linear, Fit orientation = Y=f(X) and Fit points = all.

Press Preview fit and open the Residuals tab. The regression produced a line with:

U(t) ≈ ( 0.227390 V/s) · t + 0.115659 V, RMSE = 0.174106 V and R² = 0.959808.

Figure 1. The thirteen residuals of the linear model. The U shape is not a random scatter around zero: it shows that the line cannot describe the curved trend of the observations.

The dashed horizontal line marks zero residual. Points above the line mean the model underestimates the voltage, while points below mean it overestimates it.

In the example the residuals are positive at the start and end of the range but become negative near the middle. This pattern is consistent with a curvature of the original signal that the linear function does not represent.

Read the exact residuals table

Below the plot you will find the table of observations, with the columns Dataset row, Source X, Source Y, Fitted Y and Y residual (observed − fitted).

The columns are not just a transcription of the displayed curve: they keep the numerical values associated with the source rows. Each residual can therefore be checked by subtracting the fitted value from the original one.

Rowt (s)Observed U (V)Fitted U (V)Residual (V)
000.4380000.115659+0.322341
661.2840001.480000−0.196000
12123.1390002.844341+0.294659

For example, at row 6 the residual is 1.284 − 1.480 = −0.196 V: the line predicts a voltage 0.196 V higher than the original value. This is not the same as saying that the measurement itself is wrong; the residual compares the data with the chosen model.

Inspect a single observation

Select a table row or click one of the points in the residuals plot. Curve Fitter highlights the corresponding observation and shows the reference to the source row.

Figure 2. Row 6 is highlighted in the plot. Inspection identifies the point without automatically changing the observations used in the fit.

Inspecting is not the same as selecting points for a new fit. The Use inspected row for fitting command below the table is an explicit action that passes the inspected row to the data selection system.

This distinction avoids changing the numerical problem by accident while you are only examining the residuals.

Residuals versus X and versus the predicted response

In the Results → Model comparison and diagnostics menu there are two modes of representation: Residuals vs source coordinate and Residuals vs predicted response.

The first plots the residuals against the source coordinate; in our example, time. The second uses the predicted value of the response, i.e. the voltage estimated by the model.

Figure 3. The residuals are the same, but the variable on the horizontal axis changes. Here it is the predicted voltage, not the observed time.

Plotting residuals against predicted values helps you spot changes in spread as the response varies. A fan shape, for example, may suggest that the error variability is not constant. A curved or cyclic pattern, on the other hand, may indicate that the chosen function does not capture all the structure of the data.

For a linear regression with positive slope, the two views often keep a similar ordering of the points, but they do not share the same physical axis and should not be treated as interchangeable.

When the Dataset contains hundreds of observations

For a denser series we use c16_curve_421, with 421 observations over the same 0–12 s time interval. The signal is still synthetic and slightly curved, with small superimposed oscillations. Load the Dataset, select the X/Y variables and request a Preview of the linear model.

The Residuals tab shows a more detailed U shape, with a continuous trend owing to the larger number of observations. The fit returns RMSE = 0.153098 V and R² = 0.963916.

Figure 4. Residuals of 421 observations. With many points the systematic trend of the residuals relative to the linear regression becomes evident.

The two Datasets have different sizes and perturbations. A difference in RMSE or R² alone should therefore not be used to conclude that the same model is intrinsically better on one series than on the other.

Browse the table with Previous, Next, First and Last

The residuals table shows the results in pages of 200 rows. The Previous, Next, First and Last buttons move between blocks while keeping the reference to the original Dataset rows.

For 421 observations the sequence is:

PageRange shown in the counterSource rows (indices)
First1–200 / 4210–199
Second201–400 / 421200–399
Third401–421 / 421400–420

The row counter displayed starts from 1, while the identifier shown in the Dataset row column starts from 0. These are two different conventions: the first is meant for reading the page, the second identifies the original row.

Figure 5. The second page keeps the correspondence with the original Dataset rows, along with the observed and fitted values and the residuals.
Figure 6. The last page contains only 21 rows: the navigator neither loses nor invents observations to fill a block of 200.

You can select a row even after moving to the last page. The Viewer highlights the corresponding point in the plot and keeps available the Preview from which the residuals derive.

Leave more room for the residuals plot

The control is in the Samples and presentation panel. Turning it off lets the plot take more space. Turning it back on shows the table again with the same numerical values.

Figure 7. The plot uses the full available height when the exact table is hidden. The choice only affects presentation.

This option is useful when the plot contains many points and you want to see the pattern of the residuals. To check a specific residual, show the table again and select the corresponding row.

Distinguish systematic error from an outlier

A set of small residuals scattered without a recognizable pattern is compatible with a model that leaves no evident systematic trend. Conversely, a U shape like the one in our examples suggests that the chosen law is missing a curved component.

A single point far from the others may be an outlier, but it should not be excluded automatically. Before deciding, check for transcription errors, special experimental conditions and the uncertainties of the measurement. Even a real, correct data point can look anomalous because the model is inadequate.

Other possible clues are spread increasing with the predicted value, consecutive residuals with the same sign and periodic oscillations. The interpretation depends on the order of the measurements, the noise assumptions and the nature of the phenomenon.

RMSE and R² summarize the result, while the residuals plot shows how the model fails. A complete scientific assessment needs both, together with knowledge of the units and of the domain of validity.