Unit
Regress
SS = Sum [y(k) - ycalc(k)]^2 ,
where y(k) and ycalc(k) are respectively the observed and calculated value of the dependent variable for observation k. ycalc(k) is a function of the regression parameters b(0) and b(1). Here the observed values obey the following equation:
y(k) = b(0) + b(1) * x
i.e
Y = b(0) + b(1)*X.
To calculate additional regression statistical values, use RegressTest routine.
| See Also |
|---|
| MulLinRegress |
| RegressTest |
Uses MtxExpr, MtxVecTee, Regress; procedure Example; var x,y,b,yhat: Vector; begin x.SetIt(false,[1.0, 1.5, 2.3, 3.8, 4.2, 5.0, 5.3, 5.9]); y.SetIt(false,[11, 12, 12.5, 14, 14.3, 15.2, 15.3, 17]); LinRegress(x,y,b,nil,yhat,nil); DrawValues(x,y,Series1,false); // draw original data DrawValues(x,yhat,Series2,false); // draw fitted data end;
#include "MtxVecCpp.h" #include "Regress.hpp" #include "MtxVecTee.hpp" void __fastcall(TLineSeries* series1, TLineSeries* series2) { Vector x,y,b,yhat; x->SetIt(false,TOPENARRAY(TSample,(1.0, 1.5, 2.3, 3.8, 4.2, 5.0, 5.3, 5.9))); y->SetIt(false,TOPENARRAY(TSample,(11, 12, 12.5, 14, 14.3, 15.2, 15.3, 17))); LinRegress(x,y,b,NULL,yhat,NULL); DrawValues(x,y,series1,false); // draw original data DrawValues(x,yhat,series2,false); // draw fitted data }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; using Steema.TeeChart; namespace Dew.Examples { private void Example(Styles.Line series1, Styles.Line series2) { Vector x = new Vector(0); Vector y = new Vector(0); Vector b = new Vector(0); Vector yhat = new Vector(0); x.SetIt(false,new double[] {1.0, 1.5, 2.3, 3.8, 4.2, 5.0, 5.3, 5.9}); y.SetIt(false,new double[] {11, 12, 12.5, 14, 14.3, 15.2, 15.3, 17}); LinRegress(x,y,b,null,yhat,null); MtxVecTee.DrawValues(x,y,series1,false); // draw original data MtxVecTee.DrawValues(x,yhat,series2,false); // draw fitted data } }
| Copyright 2008 Dew Research |