M-Box test for equal covariances.
function MBoxTest(const X1: TMtx; const X2: TMtx; out Signif: double; out hRes: THypothesisResult; out df1: Integer; out df2: Integer; const Alpha: double = 0.05): double;
Parameters |
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. |
Signif |
(Significance level) returns the probability of observing the given result |
hRes |
Returns the result of the null hypothesis. |
df1 |
Nominator degrees of freedom. |
df2 |
Denominator degrees of freedom. |
Alpha |
Defines the desired significance level. |
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.
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: double; hres: THypothesisResult; df1, df2: integer; 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, df1, df2, 0.05); // MB : 27,16221062 // Sign : 0,01619810 // Sign < Alpha meaning hres = hrReject i.e. covariance matrices are significantly different. end;
#include "MtxExpr.hpp" #include "Statistics.hpp" void __fastcall Example() { sMatrix 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; int df1, df2; double MB = MBoxTest(X1,X2,sign,hres, df1, df2, 0.05); // MB : 27,16221062 // Sign : 0,01619810 // Sign < Alpha meaning hres = hrReject i.e. covariance matrices are significantly different. }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|