RegModels.MulLinFit Method

void MulLinFit(TVec B, TMtx X, TVec Y, Boolean Constant, TVec Weights)

Fits multiple linear equations to data.

#NameDescription
1XVector of independent variable.
2YVector of dependent variable.
3ConstantIf true then intercept term b(0) will be included in calculations. If false, set intercept term b(0) to 0.0.
4WeightsWeights (optional). Weights are used only if they are set.
5BReturns regression coefficients for multiple linear function.

Result: stored in self (calling object)

Remarks:

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

Y=Xb.\vec Y= \underline{X} \cdot \vec b \quad .

where X is matrix, Y, B are vectors.

Examples
using Dew.Math;
using Dew.Stats.Units;
namespace Dew.Examples
{
    private void Example()
    {
        Matrix X = new Matrix(0,0);
        Vector Y = new Vector(0);
        Vector B = new Vector(0);
        X.SetIt(3,2,false,new double[]{1.0, 2.0,
            -3.2, 2.5,
            8.0, -0.5});
        Y.SetIt(3,new double[] {-3.0, 0.25, 9.0});
        RegModels.MulLinFit(B,X,Y,true,null);
        // B = (18.646428571, -1.9464285714, -9.85 )
    }
}
See Also: RegModels.MulLinEval