Reference: components

Fit to Data

Updated 3 November 2026 · 2 min read

Fit to Data runs SepalSolver’s Lsqcurvefit to find the values of the constants you tick that make the model match its data series best, and reports each with a ± and each series with an R².

The tab#

PartWhat it does
Data seriesThe model’s measurements, and Add measurements from a CSV
CalibrateEvery constant with a box to tick for fitting, and its current value
Auto-fitRefits a moment after every change to the model
Fit n constants to dataRuns the fit

What the fit does#

  1. It runs the model from the measured start to the last measurement, with the ticked constants as unknowns.
  2. It compares the model with each series at the measured times, dividing each difference by the series’ tolerance.
  3. Lsqcurvefit moves the unknowns, within their Lowest and Highest, to make the sum of the squared differences as small as it can. It works in scaled units, so constants of very different sizes move fairly, and stops after 40 iterations at most.
  4. With two or more unknowns, it also starts from two points spread across the ranges and keeps the best result.
  5. It works out each value’s standard error at the answer, writes the fitted values into the constants, and reruns the model.

Each search starts at the constant’s current value, moved at least 1% of its range in from either end: a search that starts on a bound can’t move off it.

The result#

ShownMeans
value ± rangeThe fitted value, and 1.96 standard errors: about 95% of the time the true value lies within it, if the model is right
The history can’t pin this downThe data hardly depend on this constant, so no range could be worked out
R² seriesHow much of each series’ variation the model now explains
Stopped at its highest (or lowest) allowed valueThe fit ran into the range’s end; the best value may lie beyond it

How the standard errors are worked out, and the three ways they can mislead, is in Calibration, uncertainty and validation.

Time#

A fit runs the model many times, so it takes longer than a run: about a second for one constant on a small model, several seconds for three with their extra starts. Like any run, it must finish within 30 seconds.