Regress::RegressTest Function

Overload List

#SignatureDescription
1void RegressTest(TVec *Y, TVec *YCalc, int NumPars, TRegStats &RegStat, bool Constant = true, TVec *Weights = null);Regression tests.
2void RegressTest(TVec *Y, TVec *YCalc, TMtx *ATA, TRegStats &RegStat, TVec *Residuals, TVec *BStdDev, bool Constant = true, TVec *Weights = null);Regression tests.

Overload 1: void RegressTest(TVec *Y, TVec *YCalc, int NumPars, TRegStats &RegStat, bool Constant = true, TVec *Weights = null);

Regression tests.

#NameTypeDescription
1YTVec *Dependant variables.
2YCalcTVec *Estimated (calculated) dependant variables.
3NumParsintNumber of variables (parameters) in ML model A*b=y (number of columns in A matrix or number of rows in b).
4RegStatTRegStats &Returns regression statistics parameters.
5Constant = trueboolIf true then include intercept term b(0) in calculations. If false, set intercept term b(0) to 0.0.
6Weights = nullTVec *Model weights (optional).
Remarks:

Use regression results to calculate basic regression statistics for model:

A*b=Y

Examples
#include "MtxExpr.h"
#include "Units.MtxExpr.h"
#include "Regress.h"
#include "Units.Regress.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Stats;
using namespace Dew::Math::Units::MtxExpr;
using namespace Dew::Stats::Units::Regress;

void Example()
{
    Vector y, b, w, yhat, resid, bstd;
    Matrix A, ATA;
    TRegStats RegStat;

    A.SetIt(4, 2, false, DewArray<double>{1.0, 2.0, -3.2, 2.5, 8.0, -0.5, -2.2, 1.8}); // independent variables
    w.SetIt(false, DewArray<double>{1, 2, 2, 1}); // weights
    y.SetIt(false, DewArray<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, 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)
}
See Also: Regress::R2, Regress::PRESS
Declared in Dew::Stats::Units::Regress · Dew.Stats/Units.Regress.h · Cross-compiler

Overload 2: void RegressTest(TVec *Y, TVec *YCalc, TMtx *ATA, TRegStats &RegStat, TVec *Residuals, TVec *BStdDev, bool Constant = true, TVec *Weights = null);

Regression tests.

#NameTypeDescription
1YTVec *Dependant variables.
2YCalcTVec *Estimated (calculated) dependant variables.
3ATATMtx *Inverse matrix of normal equations i.e [A(T)*A]^-1.
4RegStatTRegStats &Returns regression statistics parameters.
5ResidualsTVec *Returns residual errors.
6BStdDevTVec *Returns standard deviation.
7Constant = trueboolIf true then include intercept term b(0) in calculations. If false, set intercept term b(0) to 0.0.
8Weights = nullTVec *Model weights (optional).
Remarks:

Using regression results the routine calculates additional regression statistical parameters, together with model coefficients standard errors and model errors.

Examples
#include "MtxExpr.h"
#include "Regress.h"
#include "Units.Regress.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Stats;
using namespace Dew::Stats::Units::Regress;

void Example()
{
    Matrix A(0, 0);
    Matrix ATA(0, 0);
    Vector y(0);
    Vector b(0);
    Vector w(0);
    Vector yhat(0);
    Vector res(0);
    Vector bse(0);
    TRegStats rs;

    // independent variables
    A.SetIt(4, 2, false, DewArray<double>{1.0, 2.0,
        -3.2, 2.5,
            8.0, -0.5,
            -2.2, 1.8});

    w.SetIt(false, DewArray<double>{ 1, 2, 2, 1 }); // weights
    y.SetIt(false, DewArray<double>{ -3.0, 0.25, 8.0, 5.5 }); // dependent variables
    MulLinRegress(y, A, b, w, true, yhat, ATA, TRegSolveMethod::regSolveLQR); //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)
}
See Also: Regress::R2, Regress::PRESS
Declared in Dew::Stats::Units::Regress · Dew.Stats/Units.Regress.h · Cross-compiler