Regression
GX-TXT DEV112 P011-bis
Configure regressions and compare coefficients, fit indicators and outputs of linear and polynomial examples.
Generate the measurements and check the units
Create a Session Standalone with Session → New Session → Generate Session → Weighted Regression. The public Generator prepares regression.linear and regression.polynomial. In Configuration → Modules enable Regression. Open the polynomial Dataset and check in Canonical table the columns x, y, sigma_y and weight_inv_variance. When a choice requires the ID, you can get it from Dataset → Variables or Technical Details.

In the tested release, the column x has no unit in either Generator Dataset and the run is rejected (bug 149). In Dataset → Variables choose x, open the variable editor, assign 1 to Unit and save. This exercise treats x as dimensionless. For a physical axis always use its actual unit. y and sigma_y have unit V.


Set X, Y, model, weights and numerical validity
- In Analysis → Regression set the source to
primaryand give Independent X variable and Measured Y variable. Data selection can restrict the samples to an already saved X interval.Noneuses all available rows. - Choose
linearin Regression model for intercept and slope.polynomialuses the degree given in Polynomial degree. The cubic test uses degree 3 with 61 valid rows. Check that there are enough distinct X values. - In Statistical weight or measurement uncertainty gives the column required by Explicit weight semantics. With
noneleaves the field empty. Withstatistical_weightchoose a dimensionless, non-negative relative weight. A zero weight excludes the row from the estimate. Forinverse_variance_uncertaintypass the known standard deviation of Y, for examplesigma_yin V. The module computes 1/σ². Passing the already weighted fieldweight_inv_varianceas a statistical weight is rejected because it carries the unit V⁻². - Set Measurement noise assumption on
unspecifiedwhen the assumption is not justified. Useindependent_gaussian_known_sigmato interpret the reduced χ² only if the errors are independent and Gaussian and the σ are known in an absolute sense. - In NaN / Inf policy,
omitexcludes the rows made incompatible by non-finite values.errorstops the estimate. With Rank-deficient fit policy → error a rank-deficient design is rejected.minimum_normcan publish the minimum-norm solution when the coefficients are not uniquely identifiable. Read Numerical rank and do not interpret the individual coefficients as identified estimates when the rank is deficient. - Choose Output Dataset ID prefix distinct for each model. Turn on or off Create fit and residual graphs according to the exercise. Tick Run / recalculate now, update the plan in Run, start and check the state and the Datasets in Results.

Check coefficients, predictions, residuals and quality
In Results open .fit for the observed, fitted and residual values on the input rows, and .curve for the curve produced by the model. .coefficients gives the powers in order and the physical units of the coefficients. .covariance describes the covariance of the coefficients when applicable. .metrics and the report include counts, errors, rank, conditioning, degrees of freedom and the state of the conditional metrics.
The cubic with known σ has terms from degree 3 to degree 0 of about 0.49710, −1.99483, 1.51102 and 2.98601. R² is 0.999774, the rank is 4 and the reduced χ² is 1.18082 with 57 residual degrees of freedom. Interpret R² together with the residuals to check for systematic structure or poor coverage of the domain. The reduced χ² compares the normalized residuals with the known σ. With only relative weights the absolute reference for this interpretation is missing. Check the labels and the weighting semantics of the metrics before comparing numbers between reports and tables.
In Plots choose the fit or residuals plot of the regression concerned and open it with Graph → Open PNG 1:1. The fit allows a visual comparison between data and curve. In the residuals look for a trend with X, changing spread and influential points. The data of .fit let you check them by original index.


Compare ordinary and weighted linear fits
In a new Session with the public Generator Statistics, use statistics.source. Check the units of sample, value and weight and set 1 for sample if it is missing. In the module assign X=sample and Y=value. First run linear with weights none, the weight variable field empty and prefix regressione.ordinaria. Repeat with statistical_weight, column weight and prefix regressione.statistica. Both use omit for non-finite values.
The ordinary regression has 11 valid observations and R² about 0.92372. The weighted comparison has 10 valid observations, a slope of about 1.44245 V per unit of sample, R² about 0.88810; the report declares the reduced χ² not applicable. The two models minimize different objective functions. The relative weights change the contribution of the rows to the estimate.
To isolate the rank deficiency, use Descriptive Statistics Student Lab with X=constant_V and Y=voltage_V. The mode error reports that X has too few distinct values for degree 1. Set minimum_norm, sel_001, omit and turn off the plots. The test publishes the solution on 9 observations and rank 1. With constant X, slope and intercept are not separately identifiable.

