M-Box test for equal covariances.
Performs M-Box test for equal covariances. In this case the null hypothesis is that X1 and X2 covariances are equal and the alternative hypothesis is that X1 and X2 covariances are not equal.
Example 1
Suppose we have two matrices, representing two tests with 5 samples x 3 variables. We want to test if two test matrices have the same covariances. Performing M-Box test with default significance level 5% will give us an answer. Uses MtxExpr, Statistics, Math387;
procedure Example;
var X1,X2: Matrix;
MB,sign: TSample;
hres: THypothesisResult;
begin
X1.SetIt(5,3,false,[23,45,15, 40,85,18, 215,307,60, 110,110,50, 65,105,24]);
X2.SetIt(5,3,false,[277,230,63, 153,80,29, 306,440,105, 252,350,175, 143,205,42]);
MB := MBoxTest(X1,X2,sign,hres);
// MB : 27,16221062
// Sign : 0,01619810
// Sign < Alpha meaning hres = hrReject i.e. covariance matrices are significantly different.
end;
#include "MtxVecCpp.h"
#include "Statistics.hpp"
void __fastcall Example()
{
Matrix X1,X2;
X1->SetIt(5,3,false, OPENARRAY(double, (23,45,15, 40,85,18, 215,307,60, 110,110,50, 65,105,24)));
X2->SetIt(5,3,false, OPENARRAY(double, (277,230,63, 153,80,29, 306,440,105, 252,350,175, 143,205,42)));
THypothesisResult hres;
double sign;
double MB = MBoxTest(X1,X2,sign,hres);
// MB : 27,16221062
// Sign : 0,01619810
// Sign < Alpha meaning hres = hrReject i.e. covariance matrices are significantly different.
}
using Dew.Math;
using Dew.Stats.Units;
using Dew.Stats;
namespace Dew.Examples
{
private void Example()
{
Matrix X1 = new Matrix(0,0);
Matrix X2 = new Matrix(0,0);
X1.SetIt(5,3,false, new double[] {23,45,15, 40,85,18, 215,307,60, 110,110,50, 65,105,24});
X2.SetIt(5,3,false, new double[] {277,230,63, 153,80,29, 306,440,105, 252,350,175, 143,205,42});
THypothesisResult hres;
double sign;
double MB = MBoxTest(X1,X2,sign,hres);
// MB : 27,16221062
// Sign : 0,01619810
// Sign < Alpha meaning hres = hrReject i.e. covariance matrices are significantly different.
}
}