You are here: Symbol Reference > Regress Namespace > Functions > Regress.RidgeRegress Function
Stats Master VCL
ContentsIndex
PreviousUpNext
Regress.RidgeRegress Function

Regression by using "ridge" regression method.

Pascal
procedure RidgeRegress(const Y: TVec; const A: TMtx; k: double; const b: TVec; Normalize: Boolean = true);

Calculates regression coefficients b by using "ridge regression" method. When data suffers from multicollinearity one of the available methods which can still be used is ridge regression. In this case least squares estimates are unbiased, but their variances are large so they may be far from the true value. By adding a degree of bias to the regression estimates, ridge regression reduces the standard errors. It is hoped that the total effect will be to give more reliable estimates. Ridge regression uses following model: 

y = A*b , 

where y is vector of observations, A matrix of independent variables and b are regression coefficients. Additional k parameter is the so called "ridge parameter". Regression coefficients are then calculated from the following formula: 

b = inv(AT*A + k*I) * (AT*y), 

where I is the identity matrix, A matrix of independent variables and AT=Transp(A).

The routine does NOT calculate optimal k value for ridge regression.

An example of ridge regression method.

Uses MtxExp, Regress;
procedure Example;
var y,b: Vector;
  A : Matrix;
begin
  y.SetIt(false,[-2.5, 0.1, 6.1]);
  A.SetIt(3,2,false,[1.0, 2.5,
                   3.2, -1.5,
                   0.4, 0.7]);
  RidgeRegress(y, A, 0.0, b);
  // b = (-6.8889789853, -6.450976395)
end;
#include "MtxExpr.hpp"
#include "Regress.hpp"
#include "Math387.hpp"
void __fastcall Example()
{
  sVector y,b;
  sMatrix A;
  y.SetIt(false,OPENARRAY(double,(-2.5, 0.1, 6.1)));
  A.SetIt(3,2,false,OPENARRAY(double,(1.0, 2.5,
                                       3.2, -1.5,
                                       0.4, 0.7)));
  RidgeRegress(y,A,0.0,b);
  // b = (-6.8889789853, -6.450976395)
}
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!