Advanced Octave A35 — Comparing model families and complexity

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 06

A model with multiple parameters can better adapt to the points used for fit, but numerical improvement is not enough to demonstrate its scientific plausibility. We compare two nested polynomials on the same data and consult the Curve Family catalogue.

Objectives and data

The introductory course introduced regression and residues. Here we compare degrees of freedom and sum of squares on six synthetic points without physical units assigned. The test uses GX-TXT dev112-P011-bis and Octave 9.4.0.

Catalogue and numerical comparison

Import confronta_modelli.m, register it and run it in the Runner.

The first call interrogates CURVE_FAMILY_API_v1/models, which lists the registered models for the service of families. Then, separately, two NUMERIC_API_v1/polynomial_fit calls adapt a grade one and one grade two polynomial to the same vectors. Consultation of the catalog does not perform a family fit; the comparison shown uses the numerical API of polynomials.

In the test the catalog returns an element. For the record the sum of the squares of the residues is about 0,00419048 with four degrees of freedom; for the square polynomial is about 0,00228571 with three. The grade two model contains the straight as a special case with zero square coefficient, so it is a more flexible nested model.

Interpreting the difference

The square has a lower square sum on the points used to fit it, but has an additional parameter. This result does not show that the curvature is real or that it improves the forecasts on new data: it could also adapt to random fluctuations. The reduced number limits the conclusions.

More in-depth comparisons can use appropriate criteria or tests, residue controls and separate data for evaluation, provided hypotheses and conditions are declared. Do not compare a metric between fit performed on different data or weights as if the problem was identical. The availability of a family in the catalogue does not guarantee its physical suitability.

Exercise

  1. Why are the two models nested?
  2. Which one has less degrees of residual freedom in the test?
  3. Does a smaller SSE automatically demonstrate a better physical model?

Worked solution

  1. The square becomes a straight when the coefficient of the second degree term is zero.
  2. The square: three against four.
  3. No. Complexity, hypotheses, residues and behavior on other data must be evaluated.

Download the Module 06 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *