Your first linear fit: preview and calibration checks

Fit a straight line to synthetic observations, read the parameters and residuals, compare the statistical measures with an independent calculation, and see how a preview differs from an accepted result.

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

Exercise objective

The previous chapter covered filters and point selection. Here you will fit a straight line for the first time. You can verify the workflow by starting from the original Dataset, choosing the linear model, running Preview fit, reading the results, and checking them with an independent calculation.

We use fully simulated rather than experimentally measured data. The Dataset contains eleven observations of time t in seconds and voltage U in volts. The nominal model is:

U(t) = a + b · t, with a = 0.25 V and b = 0.15 V/s.

The nominal values include small positive and negative deterministic deviations so that the example has nonzero residuals. The deviations sum to zero and have zero linear correlation with time, so the least-squares line retains the nominal coefficients exactly.

Prepare the source curve

  1. Open a Session containing the example Dataset c06_calibration_line, published with the canonical GX-TXT Dataset API.
  2. Open Curve Fitter from the Viewers tab.
  3. In the Dataset and variables section set Dataset on c06_calibration_line, X on Time (s) and Y on Voltage (V).
  4. Do not add filters: we want to use all eleven observations. Press Add Dataset curve.
  5. Check that the Source curves table contains the source1 source and that the original series is visible in the chart.
Figure 1. The data loaded into Curve Fitter before the analysis. The blue line represents the observations, not a fit result.

Choose the model, fit points, and output domain

In the Fit model and configuration scrolling section, use these settings:

ControlValueReason
Fit orientationY = f(X)Voltage is fitted as a function of time.
ModellinearThe proposed model is a straight line with a slope and an intercept.
Fit pointsallAll eleven valid rows of the source are used.
Output domainsourceThe estimated curve is evaluated at the source X values.

These choices are separate from the graphical selection of the previous chapter. No subset was selected here: all eleven observations take part in the estimate.

Preview the fit

Select Preview fit in the viewer toolbar or in the Fit menu (default shortcut: F5). GX-TXT calculates the model and overlays a preview line on the original points. The bottom bar invites you to accept the fit or publish a Dataset separately.

Figure 2. The linear Preview, dashed green, passes close to the source points. It is a calculated result, but not yet accepted or published.

The distinction is essential: Preview lets you check the fit; Accept is a later action, and publishing a Dataset is a further explicit operation. In this chapter we stop at the Preview to interpret the results before accepting them.

Read the intercept and slope

Open the Parameters & Statistics tab. The observed result, rounded to the appropriate significant figures for the example, is:

U(t) = 0.2500 V + (0.1500 V/s) · t.

ParameterGX-TXT estimateReported standard errorUnit
Intercept a0.25000.0090174V
b Slope0.15000.0015242V/s
Figure 3. Parameters, units and indicators actually displayed by GX-TXT. Confidence intervals are unavailable: the interface requires an explicit assumption about the noise model to make them available.

For a line with the independent variable in seconds and the response in volts, the intercept is in volts, while the slope is in V/s . Assigning the units correctly is part of scientific validation, not a mere graphical choice.

The program table shows the standard errors. On their own they are not guaranteed confidence intervals: their inferential interpretation depends on the statistical assumptions. In this test no Gaussian noise model was specified, and GX-TXT correctly leaves the corresponding intervals unavailable.

Interpret the residuals plot and table

Open the Residuals tab. For each observation the residual is the difference between the observed voltage and the voltage predicted by the model:

ri = Ui,observed − Ui,fitted.

The residuals therefore keep the unit of the response, i.e. volts. A positive residual indicates an observation above the fitted line; a negative residual indicates a value below it. The markers in the residuals plot are not the points chosen for the fit and must not be read as a new selection.

Figure 4. Residuals of the first linear Preview. The table lists the 11 Dataset rows and the observed − fitted residuals. The plot separates positive and negative deviations from the zero line.

For example, at 0 s the simulated observed voltage is 0.270 V, while the line predicts 0.250 V: the residual is +0.020 V. At 3 s the observed value is 0.680 V and the fitted value 0.700 V: the residual is −0.020 V. In this example the deviations were built on purpose, not measured.

RMSE, R² and degrees of freedom

GX-TXT reports eleven observations and two free parameters. The residual degrees of freedom are therefore 11 − 2 = 9. The main indicators of the Preview are:

IndicatorValueMeaning
Sum of squared residuals (SSE)0.002300 V²Sum of the squared observed − fitted differences.
RMSE0.014460 VSquare root of SSE divided by the number of observations (11), in the reported metric.
R²0.99907157Fraction of the variability of Y around its mean explained by the regression.
Residual degrees of freedom9Eleven observations minus two estimated parameters.

The RMSE above must not be confused with the residual standard deviation, computed with 9 degrees of freedom and equal, for these data, to about 0.015986 V. The denominators differ, so the values must be kept apart as well.

An R² close to 1 is not universal proof of the physical validity of the model: you also need to read the residuals, units, point selection, noise assumptions and problem conditions. That is exactly why the Preview is useful before acceptance.

Independent verification of results

To check the calculation without using the Viewer results as a reference, we read the eleven numerical pairs directly from the canonical CSV and recomputed the linear regression with the ordinary least-squares formulas:

b = Σ[(ti − t̄)(Ui − Ū)] / Σ[(ti − t̄)²]

a = Ū − b · t̄

The independent check returns a = 0.2500 V, b = 0.1500 V/s, SSE = 0.002300 V², RMSE = 0.0144599761 V and R² = 0.9990715699. The differences from the Preview are limited to numerical rounding. We also compared each of the eleven rows of the residuals table and the two parameter standard errors, with consistent results.

This check is independent of the Viewer software: it uses only the canonical example data and the linear-regression formulas. The numerical agreement concerns the demonstration case and does not extend to nonlinear models or other statistical assumptions.

Read the technical details with care

The Technical Details tab summarizes the formula, observations, indicators and information on the current result. In the test the solver status field reports unavailable — Numerical provider did not report convergence. This means that the numerical run returned the estimates, but the provider did not explicitly report convergence: it would be wrong to turn it into a generic “solver converged”.

Figure 5. Diagnostic summary of the Preview. The editorial crop shows only the values needed for the explanation and omits internal technical identifiers not relevant to the guide.

The exposed model also shows an automatic X offset of the order of 10 −14 s. This is a tiny numerical shift tied to the internal representation of the calculation, not a measured time delay or a physical change introduced into the synthetic experiment.

When should you accept the fit?

In a complete scientific workflow, deciding to accept a fit requires checking that the model is appropriate, that the source and units are correct, that the set of points matches the intended analysis and that the diagnostics are read with care. In our example these basic checks gave a line consistent with how the Dataset was built.

However, we did not press Accept fit or Publish as Dataset…. The dashed curve remains a Preview, not an accepted or published result. Later chapters cover alternative models, solver configurations and the explicit handling of accepted results.