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

Perform MLR and use results to calculate additional statistical parameters.

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;
#include "MtxExpr.hpp"
#include "Regress.hpp"
void _fastcall Example()
{
    sMatrix A,ATA;
    sVector y,b,w,yhat,res,bse;
    TRegStats rs;

    // independent variables
    A.SetIt(4,2,false,OPENARRAY(double,(1.0, 2.0,
                      -3.2, 2.5,
                       8.0,   -0.5,
                       -2.2, 1.8)));
    w.SetIt(false,OPENARRAY(double,(1,2,2,1))); // weights
    y.SetIt(false,OPENARRAY(double,(-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, rs,res,bse,true,w); // do basic regression stats

    // RegStat = (ResidualVar:0.037230395108; R2:0.99965713428;
    // AdjustedR2:0.99897140285; F:1457.7968725; SignifProb: 0.01851663347)
}
Copyright (c) 1999-2025 by Dew Research. All rights reserved.