RegModels::MulLinFit Function

void MulLinFit(TVec *B, TMtx *X, TVec *Y, bool Constant = false, TVec *Weights = null);

Fits multiple linear equations to data.

#NameTypeDescription
1BTVec *Returns regression coefficients for multiple linear function.
2XTMtx *Vector of independent variable.
3YTVec *Vector of dependent variable.
4Constant = falseboolIf true then intercept term b(0) will be included in calculations. If false, set intercept term b(0) to 0.0.
5Weights = nullTVec *Weights (optional). Weights are used only if they are set.
Remarks:

The routine fits equations to data by minimizing the sum of squared residuals. The observed values obey the following equation:

Y⃗=X‾⋅b⃗.\vec Y= \underline{X} \cdot \vec b \quad .

where X is matrix, Y, B are vectors.

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

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

void Example()
{
    Matrix X(0,0);
    Vector Y(0);
    Vector B(0);
    X.SetIt(3,2,false,DewArray<double>{1.0, 2.0,
        -3.2, 2.5,
        8.0, -0.5});
    Y.SetIt(false,DewArray<double>{-3.0, 0.25, 8.0});
    MulLinFit(B,X,Y,true,nullptr);
    // B = (18.646428571, -1.9464285714, -9.85 )
}
See Also: RegModels::MulLinEval
Declared in Dew::Stats::Units::RegModels · Dew.Stats/Units.RegModels.h · Cross-compiler