Dew Stats Master .NET
MulLinFit Routine
Summary
Fits multiple linear equations to data.

Unit
RegModels

Declaration
Procedure MulLinFit(B: TVec; X: TMtx; Y: TVec; Constant: boolean = false; Weights: TVec = nil);
 Parameter  Description 
Vector of independent variable. 
Vector of dependent variable. 
Weights Weights (optional). Weights are used only if they are set. 
Returns regression coefficients for multiple linear function. 

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

where X is matrix, Y, B are vectors.
Categories
Linearizable regression models
 See Also 
MulLinEval 

Example 1

In the following example we generate some data. Then we fit multiple linear function to this data and retreive it's regression coefficients.

Uses MathExpr, RegModels; procedure Example); var Y,B: Vector; X: Matrix; begin X.SetIt(3,2,false,[1.0, 2.0, -3.2, 2.5, 8.0, -0.5]); Y.SetIt(false, [-3.0, 0.25, 8.0]); MulLinFit(B,X,Y,true); // B = (18.646428571, -1.9464285714, -9.85 ) end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "RegModels.hpp" #include "MtxVecTee.hpp" void __fastcall Example(); { Matrix X; Vector Y,B; X->SetIt(3,2,false,OPENARRAY(TSample,(1.0, 2.0, -3.2, 2.5, 8.0, -0.5))); Y->SetIt(3,false, OPENARRAY(TSample,(-3.0, 0.25, 9.0))); MulLineFit(B,X,Y,true,NULL); // B = (18.646428571, -1.9464285714, -9.85 ) }
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,false,new double[] {-3.0, 0.25, 9.0}); RegModels.MulLineFit(B,X,Y,true,null); // B = (18.646428571, -1.9464285714, -9.85 ) } }


Copyright 2008 Dew Research
http://www.dewresearch.com