GLOBAL KNOWLEDGE ARK

Physics · Article

Regression, parameter estimation, and model selection

Fit an explicit model to supplied data, check whether its parameters are identifiable, and compare frozen predictions on held-out points without confusing fit with physical proof.

Previous article: Controls, blinding, and experimental design

Back to Physics

After reading, you can

  • Specify input and output quantities, model parameters, residual signs and units.
  • Explain why a model can curve in its input while remaining linear in its parameters.
  • Calculate an ordinary least-squares line and verify its residuals and minimum.
  • Recognize when the observed inputs cannot identify separate parameters.
  • Compare training fit with a stated held-out prediction criterion for fixed candidates.
  • State the extra assumptions needed for uncertainty, weighted fitting and interpretation of a physical relationship.
01

Specify quantities and the model family

A regression model relates supplied inputs to a numerical response. For this lesson, x is a position coordinate in metres along a stated fixed axis, and y is voltage relative to a fixed electrical reference. The original teaching data are exact stipulated numbers, not readings from an assessed instrument. We first choose the candidate relation ŷ(x) = a + b x on 0 ≤ x ≤ 3 m, where a has units V and b has units V/m.

The parameters are the adjustable constants of the chosen relation. A straight line uses two, a and b. A relation ŷ(x) = a + b x + c x² curves in x but remains linear in the unknown parameters a, b and c; c has units V/m². Squaring an input is different from multiplying or otherwise nonlinearly transforming the unknown parameters.

The choice of model family and fitting criterion is part of the task. A fitted relation may summarize data or predict a response within a stated use, but fitting alone supplies no mechanism, intervention result or proof that the relation holds outside the examined conditions. Keep the data's quantities, domains and provenance with the model.

02

Define residuals and the fitting criterion

For n supplied pairs (x_i, y_i), define the signed residual r_i = y_i − ŷ(x_i): observed response minus fitted prediction. Its unit is V. Ordinary least squares, or OLS, chooses the parameters to minimize Q = Σ r_i², the sum over all fitted observations.

For the same fixed dataset, minimizing Q and minimizing Q/n give the same parameters because n is a positive constant. Q and the training mean squared error Q/n both have units V². Neither is a voltage, a parameter's uncertainty or evidence that residuals are normally distributed. A residual is a difference from the fitted model; it need not equal an unknown instrument error or the model's unobserved random error.

Denote the fitted line parameters by a_fit and b_fit. When S_xx = Σ(x_i − x̄)² is positive, the line's formulas are b_fit = S_xy/S_xx and a_fit = ȳ − b_fit x̄, where S_xy = Σ(x_i − x̄)(y_i − ȳ). S_xx has units m² and S_xy has units m·V, so the slope has units V/m. The positivity condition matters: a formula with a zero denominator does not identify a slope.

03

Fit the original four-point line

Supply these four training pairs only: (0 m, 1 V), (1 m, 2 V), (2 m, 2 V) and (3 m, 5 V). Give every squared residual equal weight. The means are x̄ = 1.5 m and ȳ = 2.5 V; the centered sums are S_xx = 5 m² and S_xy = 6 m·V. Therefore b_fit = 1.2 V/m and a_fit = 0.7 V.

The fitted predictions are 0.7 V, 1.9 V, 3.1 V and 4.3 V. Subtracting them from the supplied outputs gives residuals +0.3 V, +0.1 V, −1.1 V and +0.7 V. They sum to zero, and Σ x_i r_i = 0 m·V. Their squared sum is Q = 1.8 V², giving training mean squared error 0.45 V².

These checks concern the exact OLS problem. They do not say the residuals are independent random errors or that the slope is a measured physical constant. The worked example also verifies the global minimum rather than relying only on a stationary-point calculation. No Gaussian assumption is needed to find this deterministic minimizer.

Original exact training data and the fitted line ŷ = 0.7 V + (1.2 V/m)x; r = y − ŷ.
Position xSupplied voltage yFitted prediction ŷSigned residual r
0 m1 V0.7 V+0.3 V
1 m2 V1.9 V+0.1 V
2 m2 V3.1 V−1.1 V
3 m5 V4.3 V+0.7 V
04

Check parameter identifiability

Identifiability asks whether the supplied inputs distinguish different parameter choices in the chosen family. For a line, at least two distinct input positions distinguish its intercept and slope: if δa + δb x is zero at both positions, subtraction forces δb = 0 and then δa = 0. In matrix language, the corresponding model columns have full column rank.

For a separate original case, place every observation at x = 2 m and supply y = 3 V, 4 V and 5 V. Every prediction then depends only on c = a + (2 m)b. The least-squares choice is c = 4 V, with residuals −1 V, 0 V and +1 V and Q = 2 V². The data cannot distinguish a = 4 V, b = 0 V/m from a = 0 V, b = 2 V/m, or any other pair giving the same c.

More repeats at that same position can inform the combined response there, but cannot create the missing distinction between a and b. Here S_xx = 0 m². At a different position, the indistinguishable parameter pairs can give different predictions; selecting one pair through an extra constraint is an additional modeling choice. Full rank establishes uniqueness for this least-squares parameter problem, not the truth of a physical model.

05

Compare frozen models on held-out points

Training fit uses the observations that determine the parameters. A held-out comparison evaluates fixed predictions on observations not used to fit those parameters. For this supplied comparison, fix two candidate families, their training rule and the validation points before comparing scores; do not refit either candidate using the validation outputs.

The first frozen candidate is the fitted line. The second is the cubic interpolating the same four training pairs: write z = x/(1 m), then ŷ_C(x) = (1 V)[1 + (17/6)z − (5/2)z² + (2/3)z³]. The normalized z is dimensionless, and all four coefficients represent voltage contributions. The cubic's training residuals are zero. Compare both on the stipulated validation pairs (0.5 m, 1.5 V) and (2.5 m, 3.5 V), which lie inside the training input range.

The line predicts 1.3 V and 3.7 V, giving validation mean squared error 0.04 V². The cubic predicts 15/8 V and 23/8 V, giving 17/64 V² = 0.265625 V². The line therefore wins this specified two-candidate validation comparison despite its larger training error. This result establishes the scores on these two points, not universal future performance. Once their outputs guide selection, they are validation data rather than an untouched final test.

Straight lineCubic polynomialn = 4; (xᵢ, yᵢ)n = 2; (0.5 m, 1.5 V), (2.5 m, 3.5 V)rᵢ = yᵢ − ŷ_L(xᵢ)
Which data choose the model?The first frozen candidate is the fitted line. The second is the cubic interpolating the same four training pairs: write z = x/(1 m), then ŷ_C(x) = (1 V)[1 + (17/6)z − (5/2)z² + (2/3)z³]. The normalized z is dimensionless, and all four coefficients represent voltage contributions. The cubic's training residuals are zero. Compare both on the stipulated validation pairs (0.5 m, 1.5 V) and (2.5 m, 3.5 V), which lie inside the training input range.

rᵢ = yᵢ − ŷ_L(xᵢ); r = (+0.3, +0.1, −1.1, +0.7) V

The frozen cubic has zero training error, but its original validation mean squared error is 17/64 V². The line's is 0.04 V². Those two held-out outputs support this comparison and then belong to selection evidence.
Frozen fits and exact scores for the original four training pairs and two separate validation pairs; no validation refitting.
CandidateFitted parameters pTraining mean squared errorValidation mean squared error
Straight line20.45 V²0.04 V²
Cubic polynomial40 V²17/64 V² = 0.265625 V²
06

Separate residual spread from uncertainty

Statistical interpretation needs more than minimization. One sufficient model for the usual residual-variance estimate assumes fixed error-free inputs, a correctly specified linear mean, and independent mean-zero response errors with the same finite variance σ². With full column rank, p fitted parameters and n > p, s² = Q/(n − p) estimates that common variance. Finding the OLS minimum itself requires no probability distribution.

For the original line, the arithmetic gives s² = (1.8 V²)/(4 − 2) = 0.9 V² and s = √(0.9 V²) ≈ 0.948683 V. The supplied table establishes no actual stochastic error process, so these numbers alone cannot establish its population variance, a parameter's standard uncertainty or a confidence interval. A slope's uncertainty would have units V/m and depend on the input geometry as well as the error model. Distribution-specific interval claims need additional justified assumptions.

The interpolating cubic has n = p = 4. Its zero training residuals do not show that observation noise or parameter uncertainty is zero; Q/(n − p) is undefined there. In a rank-deficient family, merely counting parameter labels is also insufficient: the number of independently fitted directions must be established. Keep descriptive fit scores, conditional statistical calculations and actual measurement uncertainty distinct.

07

State weights and input-error limits

Equal weights are a specified criterion in our original fits. A weighted criterion instead minimizes Q_w = Σ w_i r_i², with supplied positive dimensionless relative weights w_i. When a response-error model justifies unequal variances, relative weights can be chosen proportional to σ_ref²/σ_i², where σ_ref is a common reference scale. Such a choice needs evidence about those variances; NIST also discusses the limitations of estimated weights.

For a small separate weighted exercise, use outputs 1 V and 3 V and fit a constant c with exact weights 4 and 1. The criterion is 4(1 V − c)² + (3 V − c)². Its minimizer is c = 1.4 V, rather than the unweighted mean 2 V. These weights are stipulated choices, not measured standard uncertainties. Multiplying both weights by the same positive factor changes the criterion's scale but leaves its minimizer unchanged.

Our main example treats positions as exact inputs. If the measured positions have relevant error, the task of estimating an underlying physical relation changes; weighting response residuals does not generally resolve input error. Likewise, weighting alone does not establish independence, remove unknown drift or make a wrong model correct. Identify the input and response error models appropriate to the intended use.

08

Preserve the selection and physical scope

Keep the data split, quantities and units, candidate families, fitted parameters, transformations, fitting criterion and held-out scoring rule in the record. Scaling or other transformations learned from data belong in the fitting procedure. If validation outputs are repeatedly used to change candidates, a final performance claim requires separate evaluation rather than relabeling those same outputs as untouched test data.

A positive fitted slope describes the chosen relation in the supplied data. It does not show that intervening on position would cause that voltage change, or that the fitted polynomial is a physical law. Such conclusions need the mechanism, experimental design and conditions relevant to the question. The preceding lesson's controls and design remain separate evidence; prediction scores cannot substitute for them.

The three exact cases teach fitting, identifiability and a bounded model comparison. They establish no real sensor calibration, Gaussian error law or universal ranking of straight lines and cubics. The next subject, Laboratory safety, reproducibility, and replication, connects experimental work to its conditions and repeatability; retaining a complete modeling record helps others inspect and reproduce an analysis.

Worked examples

Calculate and verify the OLS line

Fit ŷ = a + b x by equal-weight ordinary least squares to the exact original pairs (0 m, 1 V), (1 m, 2 V), (2 m, 2 V), (3 m, 5 V). Calculate the parameters, residuals and Q, then verify that the result is the unique global minimum.

  1. The means are x̄ = (0 + 1 + 2 + 3)m/4 = 1.5 m and ȳ = (1 + 2 + 2 + 5)V/4 = 2.5 V.
  2. The centered squared-input sum is S_xx = (2.25 + 0.25 + 0.25 + 2.25)m² = 5 m². The centered input-response sum is S_xy = (2.25 + 0.25 − 0.25 + 3.75)m·V = 6 m·V.
  3. Thus b_fit = (6 m·V)/(5 m²) = 1.2 V/m and a_fit = 2.5 V − (1.2 V/m)(1.5 m) = 0.7 V.
  4. Predictions are 0.7, 1.9, 3.1 and 4.3 V; residuals are +0.3, +0.1, −1.1 and +0.7 V. Their squared sum is (0.09 + 0.01 + 1.21 + 0.49)V² = 1.8 V². Both Σ r_i and Σ x_i r_i vanish.
  5. Let δa = a − a_fit and δb = b − b_fit. Expansion using those vanishing sums gives Q(a,b) = 1.8 V² + 4[δa + (1.5 m)δb]² + (5 m²)(δb)². The added terms are nonnegative and are both zero only when δb = 0 and δa = 0. This proves the unique global minimum.

a_fit = 0.7 V, b_fit = 1.2 V/m and Q_min = 1.8 V². The residuals have voltage units and give training mean squared error 0.45 V². The positive centered input sum ensures a unique line for this specified criterion.

Compare the frozen line and cubic

Keep the original OLS line and cubic ŷ_C = (1 V)[1 + (17/6)z − (5/2)z² + (2/3)z³], with z = x/(1 m), fitted only to the four original training pairs. Compare their mean squared residuals on the separate validation pairs (0.5 m, 1.5 V) and (2.5 m, 3.5 V). Do not refit using these validation outputs.

  1. At the four training inputs, the cubic gives 1, 2, 2 and 5 V, so its training mean squared error is zero. The line's is 1.8 V²/4 = 0.45 V².
  2. At x = 0.5 m and 2.5 m, the line predicts 1.3 V and 3.7 V. Its observed-minus-predicted residuals are +0.2 V and −0.2 V.
  3. The line's validation squared sum is (0.04 + 0.04)V² = 0.08 V². Dividing by the two validation points gives 0.04 V².
  4. At z = 1/2 and 5/2, the cubic predicts 15/8 V and 23/8 V. Its residuals are −3/8 V and +5/8 V, giving squared sum (9 + 25)/64 V² = 17/32 V² and mean 17/64 V².
  5. Since 0.04 V² < 0.265625 V², the line has the smaller score on this fixed validation record. The cubic's perfect training fit does not overturn that comparison, and two validation points do not establish a universal model ranking.

The line's validation mean squared error is 0.04 V², while the cubic's is 17/64 V² = 0.265625 V². Choose the line under this stated two-candidate validation criterion; its future physical performance remains a separate question.

Identify only the observed parameter combination

For a new exact dataset, all three inputs are x = 2 m and outputs are 3 V, 4 V and 5 V. Fit the line family ŷ = a + b x. Which parameter combination is identified, and are its separate intercept and slope unique?

  1. At every supplied input, the prediction is the single combined voltage c = a + (2 m)b. Thus Q depends on a and b only through c.
  2. The criterion is Q(c) = (3 V − c)² + (4 V − c)² + (5 V − c)² = 2 V² + 3(c − 4 V)².
  3. This is minimized uniquely in the combined value at c = 4 V. The residuals are −1 V, 0 V and +1 V, and Q_min = 2 V².
  4. Both (a,b) = (4 V, 0 V/m) and (0 V, 2 V/m) give that same prediction at x = 2 m. Every pair satisfying a + (2 m)b = 4 V is a minimizer.
  5. The input mean is 2 m and S_xx = 0 m², so the line-slope formula cannot separate the parameters. At x = 1 m the displayed pairs predict 4 V and 2 V respectively, showing why the missing distinction matters for other inputs.

Only c = a + (2 m)b is identified, with fitted value 4 V. The minimum squared sum is 2 V², but the separate intercept and slope are not unique for these inputs.

Try it yourself

  1. Express the original four positions as 0, 100, 200 and 300 cm, with the same outputs. Give the fitted intercept and slope in V/cm, and predict the output at 50 cm. Should the fitted voltages and residuals change merely because the position unit changed?

    Show the answer and reasoning

    The intercept is 0.7 V and slope is 0.012 V/cm. At 50 cm the prediction is 1.3 V. The physical predictions and voltage residuals stay the same.

    One metre is 100 cm, so 1.2 V/m is 0.012 V/cm. Multiplying that slope by 50 cm gives 0.6 V above the intercept. Input units change the slope's numerical representation, not the fitted physical relation.

  2. For the original line, use Q = 1.8 V², n = 4 and p = 2. Calculate Q/n, Q/(n − p) and √[Q/(n − p)] with units. Does arithmetic on this stipulated table establish a Gaussian error law or a confidence interval for the slope?

    Show the answer and reasoning

    Q/n = 0.45 V², Q/(n − p) = 0.9 V² and the square root is approximately 0.948683 V. These values alone establish neither a Gaussian error law nor a slope confidence interval.

    The first denominator defines the training mean squared score; the second is the residual-spread convention under a full-rank statistical model with positive residual degrees of freedom. Interpreting the latter statistically and assessing a slope's uncertainty need justified error assumptions and input geometry. The slope's uncertainty would have units V/m.

  3. Keep the repeated-position pairs (2 m, 3 V), (2 m, 4 V), (2 m, 5 V), and add (0 m, 1 V). Use equal-weight OLS in the line family. Find the fitted intercept, slope and Q. Does the new input distinguish the two parameters?

    Show the answer and reasoning

    The fitted intercept is 1 V, slope is 1.5 V/m and Q = 2 V². The distinct input now identifies a unique intercept and slope for this criterion.

    Write c = a + (2 m)b. The criterion becomes (1 V − a)² + 2 V² + 3(c − 4 V)², minimized at a = 1 V and c = 4 V. Hence b = (4 V − 1 V)/(2 m). Two distinct input positions restore the line's full column rank; they do not prove a physical law.

  4. For a separate specified validation comparison, retain both original frozen fits and the two original validation pairs, then add (1.5 m, 2.5 V). Calculate each new validation mean squared error over the three points. Keep all fitted coefficients unchanged.

    Show the answer and reasoning

    The line's new score is 2/75 V². The cubic's is 59/192 V². The line still has the smaller score on this specified three-point record.

    At 1.5 m the line predicts 2.5 V, adding zero squared residual to its original 0.08 V² sum. The cubic predicts 15/8 V, adding (5/8 V)² = 25/64 V² to its original 17/32 V² sum. Divide each total by three; the candidates are evaluated, not refitted.

  5. Fit a constant c to outputs 1 V and 3 V with positive dimensionless weights 4 and 1. Find the minimizer and Q_w there. What happens to the minimizer if both weights are multiplied by nine? No uncertainty model is supplied for the weights.

    Show the answer and reasoning

    c_fit = 7/5 V = 1.4 V and Q_w,min = 16/5 V² = 3.2 V². Multiplying both weights by nine leaves c_fit unchanged and multiplies the minimum criterion by nine.

    The derivative condition gives c = (4 × 1 V + 1 × 3 V)/5. The residuals are −0.4 V and +1.6 V, so Q_w = 4(0.16 V²) + 2.56 V². A common positive factor does not alter which c minimizes the criterion; stipulated weights establish no measured uncertainties.

  6. An analyst changes candidate formulas after inspecting the two original held-out output values, then reports the improved score on those same values as an untouched final test. Is that interpretation supported? Would a lower prediction score alone establish that changing position causes a voltage change?

    Show the answer and reasoning

    Neither interpretation is supported. The reused outputs have influenced selection, so their score is not an untouched final test; lower prediction error alone establishes no causal effect.

    An independent final assessment must account for the data used to choose the model and the conditions under which predictions will be made. A fitted predictive relation does not supply intervention evidence or the physical mechanism needed for a causal claim. Both limits apply even if the reported fitting arithmetic is correct.

What to carry forward

  • Regression requires a declared model family, quantities and units, a fitting criterion and an intended use.
  • The original equal-weight line has intercept 0.7 V, slope 1.2 V/m and squared residual sum 1.8 V²; residuals are observed minus predicted voltages.
  • Full column rank distinguishes fitted parameters. Repeats at x = 2 m identify only a + (2 m)b, not a and b separately.
  • The original cubic fits training data exactly, while the line has lower error on the two specified validation points; that comparison is bounded to the stated record.
  • Q/n is a training score. Q/(n − p) requires a full-rank statistical interpretation with n > p to estimate common error variance; it supplies no automatic uncertainty or Gaussian inference.
  • Weights and noisy predictors need explicit models. Preserve selection and evaluation roles, and keep predictive fit separate from causal evidence.

References

Sources for the concepts and teaching approaches in this article.

  1. NIST/SEMATECH e-Handbook — Least squares and modeling assumptionsNIST/SEMATECH — e-Handbook of Statistical MethodsReference guide4.1.4.1. Linear Least Squares Regression4.4.3.1. Least Squares4.2.1. What are the typical underlying assumptions in process modeling?itl.nist.gov
  2. 2. Regression — Introduction to Machine LearningMIT 6.390 course staff — Massachusetts Institute of TechnologyCourse notesintroml.mit.eduRead source
  3. Calculation practice: regression by least squares分寺杏介 / Kyosuke Bunji — Kobe University, JapanTeaching resourcewww2.kobe-u.ac.jpRead source