Perform the one-way analysis of variance where Data vector (one variable) is indexed by a second grouping GroupIndex vector variable.
function ANOVA1(const Data: TVec; const GroupIndex: TVecInt; out p: double; Alpha: double = 0.05): TANOVA1Result; overload;
Parameters |
Description |
Data |
Data vector of single variable. |
GroupIndex |
Stores group indexes. |
p |
Returns the significance probability of null hypothesis that two means are equal. If p is less than desired significance alpha then the result suggests the null hypothesis (two means are equal) can be rejected. |
Alpha |
Desired significance level. |
The following example will perform ANOVA on single variable with three groups (0,1,2 - stored in GroupIndex vector).
Use MtxExpr, Math387, Regress; var GroupIndex : Vector; Data: Vector; ANOVARes : TANOVA1Result; SigProb : double; begin Data.SetIt(false,[1,2,3,4,5,6,7,8,9,10,11,12]); GroupIndex.SetIt(false,[0,0,0,0,1,1,1,1,2,2,2,2]); ANOVARes := ANOVA1(Data,GroupIndex,SigProb); // ANOVARes = (SS1:128; SS2:15; SSTotal:143; // Deg1:2; Deg2:9; DegTotal:11; MS1:64; // MS2:1.6666666667; FDist:38.4; FCrit:4.2564947291) // SigProb = 3.9210149408e-05 end;
#include "MtxExpr.hpp" #include "Regress.hpp" #include "Math387.hpp" void __fastcall Example() { sVector Data, GroupIndex; TANOVA1Result ANOVAResult; double signprob; Data.SetIt(false,OPENARRAY(double,(1,2,3,4,5,6,7,8,9,10,11,12))); GroupIndex.SetIt(false,OPENARRAY(double,(0,0,0,0,1,1,1,1,2,2,2,2))); ANOVAResult = ANOVA1(Data,GroupIndex,signprob,0.05); // ANOVARes = (SS1:128; SS2:15; SSTotal:143; // Deg1:2; Deg2:9; DegTotal:11; MS1:64; // MS2:1.6666666667; FDist:38.4; FCrit:4.2564947291) // signprob = 3.9210149408e-05 }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|