Choose a mathematical model for your data

A straight line can look convincing and have a high R² while leaving systematic errors. Learn to compare two models in the actual Curve Fitter GUI by checking parameters, residuals and complexity.

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

Look beyond R² when choosing a model

A fit is useful when its mathematical form suits the phenomenon and its deviations from the data can be interpreted. It is not enough for the curve to pass near the points: consider the physical meaning of the parameters, the number of coefficients, the behavior of the residuals and whether the model introduces arbitrary structure.

In Curve Fitter the choice is made with the Model control in the Fit model and configuration section. Several model families are available, but not all suit the same Dataset. Here we make a reproducible comparison between linear and polynomial of degree 2.

A synthetic Dataset with clear curvature

The example uses 13 simulated observations, for times from 0 to 12 seconds. The voltage was generated with a linear component, a small quadratic component and deterministic deviations:

U(t) = 0.42 V + (0.06 V/s) · t + (0.014 V/s²) · t² + ε(t).

The deviations ε(t) are numbers assigned for teaching purposes, not an experimental noise sample. They are small enough for the curvature to remain recognizable. The canonical Dataset is called c07_quadratic_synthetic; the variables are time_s and voltage_v, respectively in seconds and volts.

Open the Viewer, choose the Dataset, set X = Time (s) and Y = Voltage (V), then use Add Dataset curve. The blue line shown represents the original observations, not a fit that has already been calculated.

Figure 1. The source to be analyzed: 13 numerical values of a simulated response with curvature. The plot shows only the source points.

First attempt: linear model

In the left column choose Model → linear, Fit orientation → Y = f(X), Fit points → all and Output domain → source. Request Preview fit, from the Viewer button or from the Fit menu.

Preview returns the approximate relationship:

U(t) ≈ 0.115659 V + (0.227390 V/s) · t.

Figure 2. The dashed green line approximates the average trend but does not follow the original curvature: recognizable deviations remain at the ends and in the middle.

The linear model gets R² = 0.959808 and RMSE = 0.174106 V. These are numerically valid results for the regression performed, but they are not enough to show that the line describes the structure of the response well.

Residuals reveal a systematic structure

Select the Residuals tab. Residuals are defined as U observed − U fitted, so they keep the unit volt. A non-random pattern of residuals along the X axis can indicate that the model is too simple.

Figure 3. The residuals do not simply scatter around zero: they are positive at the ends and negative in the middle. This is a concrete sign that the linear model is underspecified for these data.

This information is more diagnostic than R² alone. Even a regression with a high R² can leave a consistent pattern if the chosen form leaves out an important physical or mathematical term.

Switch to a degree-2 polynomial

Go back to the Model control and select polynomial. The Degree field appears: for this comparison enter 2. Keep the same variables, the same Dataset, Fit points = all and the source output domain.

Figure 4. The quadratic model configuration. Changing from linear to polynomial invalidates the previous Preview: to see the new result you need to request a new one.

In the test Curve Fitter did remove the linear Preview after the model change, preventing a calculation based on previous settings from being read as current. So request Preview fit again.

Second attempt: the quadratic model

The new Preview produces, rounding the estimates:

U(t) ≈ 0.423670 V + (0.0593841 V/s) · t + (0.0140005 V/s²) · t².

Figure 5. The quadratic Preview follows the curvature of the data much more closely than the line. The original points are unchanged: only the fitting function changes.

The value of RMSE drops to 0.011253 V, about fifteen times lower than for the linear regression. R² rises to about 0.999832. There are three parameters, one more than the line: in our example this extra complexity is justified by the curvature already visible in the data and in the pattern of the linear residuals.

Compare the residuals after changing the model

Opening Residualsagain, the residuals are much smaller and no longer show the marked arch pattern of the linear regression. The table keeps the identification of the 13 source rows.

Figure 6. With degree 2 the vertical scale of the residuals shrinks considerably. Since each plot adapts its own scale, the quantitative comparison should also use RMSE and numerical values, not only the look of the panels.

The automatic scale of the plots changes between the two models. If you compare panels with different axes visually, the reduction in residuals can look smaller than it is: read the labels of the vertical axis.

Coefficients and units

The Parameters & Statistics tab shows the three coefficients power_2, power_1 and power_0, corresponding to the quadratic, linear and constant terms respectively.

ParameterGX-TXT estimatePhysical unit
power_20.0140005V/s²
power_10.0593841V/s
power_00.4236703V
Figure 7. The GUI shows three estimates with their units, consistent with the form of the function. Confidence intervals are unavailable without a declared noise model.

Read the coefficient units from the physical form of the function. The t² term requires V/s², the t term requires V/s, and the constant is in V. Here the estimates are close to the nominal values because the Dataset was generated with that model. A polynomial need not represent the underlying physical phenomenon.

Numerical comparison and independent calculation

The Curve Fitter results were recomputed independently by least-squares regression on the original values of the canonical CSV. For both models, coefficients, RMSE and R² were compared within the numerical tolerance.

IndicatorLinearQuadratic
Observations used1313
Free parameters23
RMSE, V0.1741060.011253
R²0.9598080.999832
Residual degrees of freedom1110
Residual patternSystematic curvatureSmall deviations around zero

The RMSE drops by about 15.5 times. Here degree 2 is consistent with the known generating law and with the residuals. In general, however, a model with more parameters tends to reduce the error on the data used: choosing models for real measurements also requires weighing complexity, physical assumptions and, when possible, independent validation data.

In the Viewer the numerical provider did not explicitly report the convergence status, and confidence intervals are unavailable without a specific noise assumption. This does not prevent the numerical comparison verified here, but it limits the inferential conclusions that can be drawn from the Preview alone.

The P011 Curve Fitter selector shows 22 items. We actually used two of them in the comparison; the others are listed to guide your choice, not as functions already tested in this exercise.

FamilyOptions displayed by the GUIWhen to explore it
Simple functionslinear, polynomial, exponential, power_law, gaussianResponses with known laws or specific mathematical assumptions.
Composition and formulascomponents, regions, formula, rational, implicit, complex_response, registeredProblems with several components, specialized representations or declared models.
Interpolation and approximationspchip, smoothing_spline, akima, bspline, fourierSmooth trends, shape constraints, knots or periodic structures.
Geometry and parametric curvescircular_arc, quadratic_bezier, cubic_bezier, parametric_polynomial, parametric_splineTrajectories, contours or curves that cannot necessarily be written as Y = f(X).

The mere presence of an item does not guarantee that it works without additional settings, that it converges on any Dataset or that it produces statistics comparable to a linear regression. Each model needs its own tests and explanations.

A practical model-selection process

Before changing the model, look at the shape of the data and the physical domain. Start with the simplest function that makes sense for the problem, generate the Preview and check the residuals systematically. When a pattern appears in the residuals, consider whether a justified mathematical structure can explain it; do not keep raising the polynomial degree until R² approaches one.

Always keep the same observations and the same selection criterion when comparing two models on the same Dataset. Changing the filters or the points used would change the observed population and make the comparison less direct. The results shown here come from the same 13 rows and the same orientation Y=f(X).

Both runs remained in Preview mode. Accept fit , saving of accepted results and publication of new Datasets were not performed. The next chapter looks more closely at degree, domain and the limits of interpolation and polynomial fitting.