Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure MulLinRegress(const Y: TVec; const A: TMtx; const b: TVec; const Weights: TVec; Constant: Boolean; const YCalc: TVec; const ATA: TMtx; Method: TRegSolveMethod); | Multivariante linear regression. |
| 2 | procedure MulLinRegress(const Y: TVec; const A: TMtx; const b: TVec; Constant: Boolean; const YCalc: TVec; const ATA: TMtx; Method: TRegSolveMethod); | Multivariante linear regression. |
Overload 1: procedure MulLinRegress(const Y: TVec; const A: TMtx; const b: TVec; const Weights: TVec; Constant: Boolean; const YCalc: TVec; const ATA: TMtx; Method: TRegSolveMethod);
Multivariante linear regression.
| # | Name | Description |
|---|---|---|
| 1 | Y | Defines vector of dependant variable. |
| 2 | A | Defines matrix of independant (also X) variables. |
| 3 | b | Returns calculated regression coefficiens. |
| 4 | Method | Use QR, SVD, or LU solver. Typically QR will yield best compromise between stability and performance. |
| 5 | Weights | Defines weights (optional). |
| 6 | Constant | If true then intercept term b(0) will be included in calculations. If false, set intercept term b(0) to 0.0. |
| 7 | YCalc | Returns vector of calculated dependant variable, where YCalc = A*b. |
| 8 | ATA | Returns inverse matrix of normal equations i.e [A(T)*A]^-1. |
Result: stored in self (calling object)
Remarks:
Routine fits equations to data by minimizing the sum of squared residuals:
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), b(1) ... Here the observed values obey the following equation:
y(k) = b(0) + b(1) * x(1,k) + b(2) * x(2,k) + ...
i.e
y = A * b.
To calculate additional regression statistical values, use Regress.RegressTest routine.
Overload 2: procedure MulLinRegress(const Y: TVec; const A: TMtx; const b: TVec; Constant: Boolean; const YCalc: TVec; const ATA: TMtx; Method: TRegSolveMethod);
Multivariante linear regression.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Y | TVec | |
| 2 | A | TMtx | |
| 3 | b | TVec | |
| 4 | Constant | Boolean | |
| 5 | YCalc | TVec | |
| 6 | ATA | TMtx | |
| 7 | Method | TRegSolveMethod |
Result: stored in self (calling object)
Examples
Uses Regress, MtxExpr;
procedure Example;
var y,b,w,yhat, resid, bstd: Vector;
A, ATA : Matrix;
RegStat : TRegStats;
begin
A.SetIt(4,2,false,[1.0, 2.0,
-3.2, 2.5,
8.0, -0.5,
-2.2, 1.8]); // independent variables
w.SetIt(false,[1,2,2,1]); // weights
y.SetIt(false,[-3.0, 0.25, 8.0, 5.5]); // dependent variables
MulLinRegress(y,A,b,w,true,yhat,ATA); //do regression
// b=(19.093757944, -2.0141843616, -10.082487055)
RegressTest(y,yhat,ATA,RegStat,resid, bstd, true,w); // do basic regression stats
// RegStat = (ResidualVar:0.037230395108; R2:0.99965713428;
// AdjustedR2:0.99897140285; F:1457.7968725; SignifProb: 0.01851663347)
end;