$ontext Linear Least Squares Regression NIST test data Erwin kalvelagen, dec 2004 Reference: http://www.itl.nist.gov/div898/strd/lls/lls.shtml Eberhardt, K., NIST. Model: Linear Class 1 Parameter (B1) y = B1*x + e Model: Linear Class 1 Parameter (B1) y = B1*x + e Certified Regression Statistics Standard Deviation Parameter Estimate of Estimate B1 0.727272727272727 0.420827318078432E-01 Residual Standard Deviation 0.369274472937998 R-Squared 0.993348115299335 Certified Analysis of Variance Table Source of Degrees of Sums of Mean Variation Freedom Squares Squares F Statistic Regression 1 40.7272727272727 40.7272727272727 298.6666666666667 Residual 2 0.272727272727273 0.136363636363636 $offtext set i 'cases' /i1*i3/; table data(i,*) y x i1 3 4 i2 4 5 i3 4 6 ; * * note:no constant term * $onecho > ls.opt add_constant_term 0 $offecho variables b1 sse 'sum of squared errors' ; equation fit(i) 'equation to fit' sumsq ; sumsq.. sse =n= 0; fit(i).. data(i,'y') =e= b1*data(i,'x'); option lp = ls; model leastsq /fit,sumsq/; leastsq.optfile=1; solve leastsq using lp minimizing sse; option decimals=8; display b1.l; scalar B1cert / 0.727272727272727 /; scalar err "Sum of squared errors in estimates"; err = sqr(b1.l-B1cert); display err; abort$(err>0.0001) "Solution not accurate";