Main Content

risk.validation.migrationMatrixStabilityTest

R2026b

Migration matrix stability test

Since R2026a

    Description

    hMMSTest = risk.validation.migrationMatrixStabilityTest(CountMatrix) returns the migration matrix stability (MMS) test result or results, hMMSTest, for a count matrix, CountMatrix. The output is 1 if the test rejects the null hypothesis at the 95% confidence level, or 0 if it does not reject the null hypothesis.

    hMMSTest = risk.validation.migrationMatrixStabilityTest(CountMatrix,ConfidenceLevel=confidenceLevel) specifies the confidence level for the MMS test.

    [hMMSTest,MMSOutput] = risk.validation.migrationMatrixStabilityTest(___) also returns a structure MMSOutput that contains summary metrics. Specify MMSOutput as the second output argument with any of the input argument combinations in the previous syntaxes.

    example

    Examples

    collapse all

    Perform a migration matrix stability test on the matrix Grades, which contains counts for probability of default (PD) grade migrations. The migration matrix stability test tests the null hypothesis that migration frequencies closer to the diagonal are greater than those farther from the diagonal.

    Load the matrix.

    load Grades.mat
    Grades
    Grades = 14×15
    
               1          11          21          31          41          51          61          71          81          91         101         111         121         131         141
              89         120          81          14           0           0           0           0           0           0           0           0           0           0           0
              24          81         114          81          15           0           0           0           0           0           0           0           0           0           0
               2          19          75         132          69          21           4           1           0           0           0           0           0           0           0
               0           0          19          89         100          66          32           1           0           0           0           0           0           0           0
               0           0           1          18          83         114          74          18           4           0           0           0           0           0           0
               0           0           0           4          27          61         107          73          13           0           0           0           0           0           0
               0           0           0           0           0          15          62         105          68          16           2           0           0           0           0
               0           0           0           0           0           1          10          84         102          75          14           1           0           0           0
               0           0           0           0           0           0           4          13          57         127          68          32           1           0           0
               0           0           0           0           0           0           0           1          14          85         122          83          26           0           0
               0           0           0           0           0           0           0           0           1          16          71         103          80          16           3
               0        1500        1400        1300        1200        1100        1000         900         800         700         600         500         400         300         200
               0           0           0           0           0           0           0           0           0           0           2          14          67         114         106
    
    

    The rows of Grades correspond to grades at the beginning of the observation period and the columns correspond to grades at the end. The element at position (3,5), for example, indicates that 15 customers migrated from rating grade 3 to rating grade 5.

    Perform an MMS test using the counts in Grades.

    [hMMSTest,MMSOutput] = risk.validation.migrationMatrixStabilityTest(Grades)
    hMMSTest = 14×14
    
       NaN     1     1     0     0     0     0     0     0     0     0     0     0     0
         0   NaN     0     0     0   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN
         0     0   NaN     0     0     0   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN
         0     0     0   NaN     0     0     0     0     0   NaN   NaN   NaN   NaN   NaN
       NaN     0     0     0   NaN     0     0     0     0   NaN   NaN   NaN   NaN   NaN
       NaN     0     0     0     0   NaN     0     0     0     0   NaN   NaN   NaN   NaN
       NaN   NaN     0     0     0     0   NaN     0     0     0   NaN   NaN   NaN   NaN
       NaN   NaN   NaN   NaN     0     0     0   NaN     0     0     0     0   NaN   NaN
       NaN   NaN   NaN   NaN     0     0     0     0   NaN     0     0     0     0   NaN
       NaN   NaN   NaN   NaN   NaN     0     0     0     0   NaN     0     0     0     0
       NaN   NaN   NaN   NaN   NaN   NaN     0     0     0     0   NaN     0     0     0
       NaN   NaN   NaN   NaN   NaN   NaN   NaN     0     0     0     0   NaN     0     0
         0     1     1     1     1     1     1     1     1     1     1     1   NaN     0
       NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN     0     0     0     0   NaN
    
    
    MMSOutput = struct with fields:
                 RejectTest: [14×14 double]
               PValueMatrix: [14×14 double]
        TestStatisticMatrix: [14×14 double]
              CriticalValue: -1.6449
            MigrationMatrix: [14×15 double]
    
    

    The matrix hMMSTest contains the results of the MMS test. Above the main diagonal, a value of 1 indicates enough evidence exists to reject the null hypothesis that the corresponding probability in the migration matrix is significantly smaller than the probability in the same row of the previous column. Below the main diagonal, a value of 1 indicates enough evidence exists to reject the null hypothesis that the corresponding probability in the migration matrix is significantly smaller than the probability in the same row of the following column. NaN entries indicate that the test statistic is NaN.

    The MMSOutput structure contains values that the risk.validation.migrationMatrixTest function uses to perform the hypothesis test, including p-values, test statistics, and the migration matrix.

    Display the migration matrix.

    MMSOutput.MigrationMatrix
    ans = 14×15
    
        0.0009    0.0103    0.0197    0.0291    0.0385    0.0479    0.0573    0.0667    0.0761    0.0854    0.0948    0.1042    0.1136    0.1230    0.1324
        0.2928    0.3947    0.2664    0.0461         0         0         0         0         0         0         0         0         0         0         0
        0.0762    0.2571    0.3619    0.2571    0.0476         0         0         0         0         0         0         0         0         0         0
        0.0062    0.0588    0.2322    0.4087    0.2136    0.0650    0.0124    0.0031         0         0         0         0         0         0         0
             0         0    0.0619    0.2899    0.3257    0.2150    0.1042    0.0033         0         0         0         0         0         0         0
             0         0    0.0032    0.0577    0.2660    0.3654    0.2372    0.0577    0.0128         0         0         0         0         0         0
             0         0         0    0.0140    0.0947    0.2140    0.3754    0.2561    0.0456         0         0         0         0         0         0
             0         0         0         0         0    0.0560    0.2313    0.3918    0.2537    0.0597    0.0075         0         0         0         0
             0         0         0         0         0    0.0035    0.0348    0.2927    0.3554    0.2613    0.0488    0.0035         0         0         0
             0         0         0         0         0         0    0.0132    0.0430    0.1887    0.4205    0.2252    0.1060    0.0033         0         0
             0         0         0         0         0         0         0    0.0030    0.0423    0.2568    0.3686    0.2508    0.0785         0         0
             0         0         0         0         0         0         0         0    0.0034    0.0552    0.2448    0.3552    0.2759    0.0552    0.0103
             0    0.1261    0.1176    0.1092    0.1008    0.0924    0.0840    0.0756    0.0672    0.0588    0.0504    0.0420    0.0336    0.0252    0.0168
             0         0         0         0         0         0         0         0         0         0    0.0066    0.0462    0.2211    0.3762    0.3498
    
    

    The migration matrix contains probabilities for customer migration from one state to another. The software uses these probabilities to calculate the test statistics for the hypothesis tests. For more information about the MMS test, see More About.

    Input Arguments

    collapse all

    Count matrix, specified as a wide or square matrix of nonnegative values. The elements of the matrix are counts for rating grade migrations and status migrations. The rating grades and statuses can belong to any ordinal rating system. Examples of ordinal rating systems include credit rating grades, loss given default (LGD) rating grades, probability of default (PD) rating grades, and mortgage delinquency states.

    The rows of CountMatrix correspond to the grade at the beginning of the observation period and the columns correspond to the grade at the end. In other words, the element at position (i,j) represents the number of customers whose grade was i at the start of the observation period and j at then end of the observation period.

    Confidence level of the hypothesis test, specified as a numeric scalar in the range (0,1).

    Output Arguments

    collapse all

    Hypothesis test results, returned as a numeric matrix containing values of 1, 0, or NaN. Each element in hMMSTest corresponds to the element in CountMatrix at the same position.

    • A value of 1 rejects the null hypothesis at the specified confidence level.

    • A value of 0 fails to reject the null hypothesis at the specified confidence level.

    • A value of NaN indicates that the corresponding test statistic is NaN.

    Output metrics, returned as a structure with the following fields:

    • RejectTest — Numeric matrix indicating whether each null hypothesis was rejected. Each element in RejectTest corresponds to the element in CountMatrix at the same position. This field represents the same values as hMMSTest.

    • PValueMatrix — Numeric matrix with values in the range [0,1] representing the p-values for the hypothesis tests. Each element in pValueMatrix corresponds to the element in CountMatrix at the same position. A small value indicates that the null hypothesis might not be valid.

    • TestStatisticMatrix — Numeric matrix representing the test statistic values for the hypothesis tests. Each element in TestStatistic corresponds to the element in CountMatrix at the same position.

    • CriticalValue — Numeric scalar representing the critical value for the hypothesis tests.

    • MigrationMatrix — Numeric matrix representing the migration probabilities. The element at position (i,j) is the probability of migrating from state i to state j.

    The test statistic can be undefined for some values of i and j. In this case, the software returns 0 in the corresponding positions of hMMSTest and the RejectTest field of MMSOutput, and NaN in the corresponding positions of the PValueMatrix, TestStatisticMatrix, and CriticalValue fields of MMSOutput.

    For more information about the MMS test and its corresponding statistics, see More About.

    More About

    collapse all

    References

    [1] European Central Bank. “Instructions for reporting the validation results of internal models.” February, 2019. https://www.bankingsupervision.europa.eu/activities/internal_models/shared/pdf/instructions_validation_reporting_credit_risk.en.pdf.

    Version History

    Introduced in R2026a