Performs balanced two-way analysis of variance (ANOVA).
Performs balanced two-way analysis of variance on ranks of data contained in Data matrix. The two-way analysis of variance compares the means of two or more rows and two or more columns. The data in different columns can be interpreted as change of one factor and data in different rows can be interpreted as changes in other factor. If there is more than one observation per row/column then you can set the number of row/column replications by changing Replications value to appropriate factor. An exception will be raised if (Data.Rows mod Replications) is not zero.
Example 1
This example shows the ANOVA on data with Replications set to 1 meaning there is no interaction. Uses MtxExpr, Regress, Math387;
procedure Example;
var Data: Matrix;
ANOVARes : TANOVA2Result;
pRows, pCols, pInteract : TSample;
begin
Data.SetIt(4,4,false,
[2.5, 3.2, 4.2, 3.9,
1.9, 3.5, 3.6, 3.7,
3.4, 3.5, 3.3, 3.4,
4.2, 5.0, 3.1, 2.4]);
ANOVARes := ANOVA2(Data,pRows,pCols,pInteract,1); // no interaction !!
// ANOVARes =(SS1:0.505; SS2:1.37; SS3:NAN; SS4:6.555; SSTotal:8.43 ;
// Deg1: 3; Deg2:3 ; Deg3:+NAN; Deg4:9 ; DegTotal:15 ;
// MS1:0.16833333333 ; MS2:0.45666666667 ; MS3:+NAN ; MS4:0.72833333333 ;
//FDist1:0.12260277778 ; FDist2:0.33260555556 ; FDist3:+NAN ;
// FCrit1:3.8625483576 ; FCrit2:3.8625483576 ; FCrit3:+NAN ;
// pRows: 0.94442876898
// pCols: 0.80219818603
// pInteract: 2.0820886898e-307
end;
#include "MtxVecCpp.h"
#include "Regress.hpp"
#include "Math.hpp"
void __fastcall Example()
{
Matrix Data;
Data->SetIt(4,4,false,OPENARRAY(TSample,(2.5, 3.2, 4.2, 3.9,
1.9, 3.5, 3.6, 3.7,
3.4, 3.5, 3.3, 3.4,
4.2, 5.0, 3.1, 2.4)));
double prows,pcols,pinteract;
TANOVA2Result ar = ANOVA2(Data,prows,pcols,pinteract,1,0.05);
// ar =(SS1:0.505; SS2:1.37; SS3:NAN; SS4:6.555; SSTotal:8.43 ;
// Deg1: 3; Deg2:3 ; Deg3:+NAN; Deg4:9 ; DegTotal:15 ;
// MS1:0.16833333333 ; MS2:0.45666666667 ; MS3:+NAN ; MS4:0.72833333333 ;
//FDist1:0.12260277778 ; FDist2:0.33260555556 ; FDist3:+NAN ;
// FCrit1:3.8625483576 ; FCrit2:3.8625483576 ; FCrit3:+NAN ;
// pRows: 0.94442876898
// pCols: 0.80219818603
// pInteract: 2.0820886898e-307
}
using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
private void Example()
{
Matrix Data = new Matrix(0,0);
Data.SetIt(4,4,false, new double[] {2.5, 3.2, 4.2, 3.9,
1.9, 3.5, 3.6, 3.7,
3.4, 3.5, 3.3, 3.4,
4.2, 5.0, 3.1, 2.4});
TANOVA2Result ar = Regress.ANOVA2(Data,out prows, out pcols, ount pinteract, 1, 0.05);
// ar =(SS1:0.505; SS2:1.37; SS3:NAN; SS4:6.555; SSTotal:8.43 ;
// Deg1: 3; Deg2:3 ; Deg3:+NAN; Deg4:9 ; DegTotal:15 ;
// MS1:0.16833333333 ; MS2:0.45666666667 ; MS3:+NAN ; MS4:0.72833333333 ;
//FDist1:0.12260277778 ; FDist2:0.33260555556 ; FDist3:+NAN ;
// FCrit1:3.8625483576 ; FCrit2:3.8625483576 ; FCrit3:+NAN ;
// pRows: 0.94442876898
// pCols: 0.80219818603
// pInteract: 2.0820886898e-307
}
}
Example 2
This example shows the ANOVA on data with Replications set to 2 meaning there are two rows/cols per "cell". Uses MtxExpr, Regress, Math387;
procedure Example;
var Data: Matrix;
ANOVARes : TANOVA2Result;
pRows, pCols, pInteract : TSample;
begin
Data.SetIt(4,4,false,
[2.5, 3.2, 4.2, 3.9,
1.9, 3.5, 3.6, 3.7,
3.4, 3.5, 3.3, 3.4,
4.2, 5.0, 3.1, 2.4]);
ANOVARes := ANOVA2(Data,pRows,pCols,pInteract,2); // replications! two rows/cols per "cell"
// ANOVARes =(SS1:0.2025; SS2:1.37; SS3:4.4675; SS4:2.39; SSTotal:8.43 ;
// Deg1: 1; Deg2:3 ; Deg3:3; Deg4:8 ; DegTotal:15 ;
// MS1:0.2025 ; MS2:0.45666666667 ; MS3:1.4891666667 ; MS4:0.29875 ;
// FDist1:0.060496875 ; FDist2:0.13642916667 ; FDist3:0.44488854167 ;
// FCrit1:5.3176550716 ; FCrit2:4.0661805514 ; FCrit3:4.0661805514 ;
// pRows: 0.81190529881
// pCols: 0.93549639694
// pInteract: 0.72753486979
end;
#include "MtxVecCpp.h"
#include "Regress.hpp"
#include "Math.hpp"
void __fastcall Example()
{
Matrix Data;
Data->SetIt(4,4,false,OPENARRAY(TSample,(2.5, 3.2, 4.2, 3.9,
1.9, 3.5, 3.6, 3.7,
3.4, 3.5, 3.3, 3.4,
4.2, 5.0, 3.1, 2.4)));
double prows,pcols,pinteract;
TANOVA2Result ar = ANOVA2(Data,prows,pcols,pinteract,2,0.05);
// ar =(SS1:0.2025; SS2:1.37; SS3:4.4675; SS4:2.39; SSTotal:8.43 ;
// Deg1: 1; Deg2:3 ; Deg3:3; Deg4:8 ; DegTotal:15 ;
// MS1:0.2025 ; MS2:0.45666666667 ; MS3:1.4891666667 ; MS4:0.29875 ;
// FDist1:0.060496875 ; FDist2:0.13642916667 ; FDist3:0.44488854167 ;
// FCrit1:5.3176550716 ; FCrit2:4.0661805514 ; FCrit3:4.0661805514 ;
// pRows: 0.81190529881
// pCols: 0.93549639694
// pInteract: 0.72753486979
}
using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
private void Example()
{
Matrix Data = new Matrix(0,0);
Data.SetIt(4,4,false, new double[] {2.5, 3.2, 4.2, 3.9,
1.9, 3.5, 3.6, 3.7,
3.4, 3.5, 3.3, 3.4,
4.2, 5.0, 3.1, 2.4});
TANOVA2Result ar = Regress.ANOVA2(Data,out prows, out pcols, ount pinteract, 2, 0.05);
// ar =(SS1:0.2025; SS2:1.37; SS3:4.4675; SS4:2.39; SSTotal:8.43 ;
// Deg1: 1; Deg2:3 ; Deg3:3; Deg4:8 ; DegTotal:15 ;
// MS1:0.2025 ; MS2:0.45666666667 ; MS3:1.4891666667 ; MS4:0.29875 ;
// FDist1:0.060496875 ; FDist2:0.13642916667 ; FDist3:0.44488854167 ;
// FCrit1:5.3176550716 ; FCrit2:4.0661805514 ; FCrit3:4.0661805514 ;
// pRows: 0.81190529881
// pCols: 0.93549639694
// pInteract: 0.72753486979
}
}