TMtxMulLinReg Class

Source: StatTools.cs · Assembly: Dew.Stats
ComponentTMtxComponentTMtxMulLinReg

public class TMtxMulLinReg : TMtxComponent

Performs multiple linear regression.

Use TMtxMulLinReg component to perform multiple linear regression on dataset. The TMulLinRegress component fits equations to data by minimizing the sum of squared residuals:

SS = Sum [y(k) - ycalc(k)]^2 ,

where y(k) and ycalc(k) are respectively the observed and calculated value of the dependent variable for observation k. ycalc(k) is a function of the regression parameters b(0), b(1) ... Here the observed values obey the following equation:

y(k) = b(0) + b(1) * x(1,k) + b(2) * x(2,k) + ...

i.e

y = A * b

How to use TMtxMulLinReg component?
1. Drop a TMtxMulLinReg component on the form. 2. Define Dew.Stats.TMtxMulLinReg.A, the matrix of independent variables. 3. Define Dew.Stats.TMtxMulLinReg.Y, vector of dependent variables. 4. Define Dew.Stats.TMtxMulLinReg.Weights (optional) vector. 5. If you don't want to use intercept term b(0) in our calculations, set Dew.Stats.TMtxMulLinReg.Constant property to false, 6. Call the Dew.Stats.TMtxMulLinReg.Recalc method to trigger calculation.

Results:
1. Dew.Stats.TMtxMulLinReg.RegressResult : regression coefficients (b), regression coefficients confidence intervals (BConfInt) and standard deviation (BStdDev), residuals (Residuals) and calculated dependent variables (YCalc). 2. Dew.Stats.TMtxMulLinReg.RegressStatistics : basic regression statistics (R2, Adjusted R2, residuals variance, F statistics, significance probability).

Examples

csharp
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
    private void Example(StatTools.TMtxMulLinReg mlr)
    {
        // y = A*b
        mlr.A.SetIt(3,2,false,new double[] {-5,2,
            1,4,
            8,0.5});
        mlr.Y.SetIt(false,new double[] {-2,1,11});
        mlr.Weights.SetIt(false, new double[] {2,6,1});
        mlr.UseWeights = true;
        mlr.Recalc();
        // Result ==> b = ( 4.586, 0.871, -1.114 )
    }
}

Properties

NameTypeDescription
ATMtxMatrix of independent variables.
AlphaDoubleDesired significant value for the statistical tests.
AutoUpdateBooleanIf true then changing any of the TMtxMulLinReg properties will trigger the Dew.Stats.TMtxMulLinReg.Recalc method.
BlockAssignBooleanBlock streaming of specific properties when storing only a "template".
ConstantBooleanIntercept term.
DirtyBooleanWhen any of the TMtxMulLinReg properties changes, this property is automatically set to true.
EditorActiveBooleanReturns True, if the component editor is displayed.
ReferenceTReferenceListStores a list of components that have to be notified, when this component is destroyed.
RegressResultTRegResultClassRegression results.
RegressStatisticsTRegStatsClassRegression results statistics.
SolveMethodTRegSolveMethodDefines A*x=b solving method.
UseWeightsBooleanWeighted multiple linear regression.
WeightsTVecWeights for MLR.
YTVecVector of dependent variables.

Methods

NameDescription
AllowStreamingReturns the negatated value of BlockAssign.
AssignAssign values of all published properties from Source.
AssignTemplateAssign values of "template-like" published properties from Source.
EditorClassTo be overriden in descendanr classses.
LoadFromStreamLoad the component from Src stream.
LoadTemplateFromFileLoad a template from file.
LoadTemplateFromStreamLoad a template from stream.
RecalcTriggers multiple linear regression recalculation.
ResetReset is called after loading the data from stream or file.
SaveTemplateToFileSave template to file.
SaveTemplateToStreamSave template to stream.
SaveToStreamSave the component to Dst stream.
ValidSystemChecks if system is valid.