You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.MBoxTest Function
Stats Master VCL
ContentsIndex
Example

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.