Dew Stats Master .NET
MBoxTest Routine
Summary
M-Box test for equal covariances.

Unit
Statistics

Declaration
Function MBoxTest(X1, X2: TMtx; out Signif: TSample; out hRes: THypothesisResult; out df1, df2: Integer; Alpha: TSample = 0.05): TSample;
 Parameter  Description 
X1 First matrix. The number of columns for X1 and X2 must be equal, otherwise an exception is raised. 
X2 Second matrix. The number of columns for X1 and X2 must be equal, otherwise an exception is raised. 
df1 Nominator degrees of freedom. 
df2 Denominator degrees of freedom. 

Description
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.
Categories
Hypothesis testing
Multivariate analysis routines
 See Also 
HotellingT2 

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. } }

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