主要内容

risk.validation.slotBacktest

Slot backtest

Since R2026a

    Description

    hSlotTest = risk.validation.slotBacktest(NumDefaults,NumLoans,ObservedLGDRates,ExpectedLossRate) returns the result of a slot backtest, which is a z-test that compares the expected loss with the mean realized loss rate for a portfolio or a slot. The output is 1 if the test rejects the null hypothesis at the 95% confidence level, or 0 otherwise.

    hSlotTest = risk.validation.slotBacktest(NumDefaults,NumLoans,ObservedLGDRates,ExpectedLossRate,ConfidenceLevel=confidenceLevel) specifies the confidence level for the slot backtest.

    [hSlotTest,Output] = risk.validation.slotBacktest(___) also returns a structure Output that contains summary metrics.

    example

    Examples

    collapse all

    Perform a slot backtest to determine whether a portfolio's expected loss (EL) rate is greater than its mean realized loss rate for the year 2024. Use loss-given-default (LGD) data from the year 2024, and default data from the lookback period between years 2020 to 2024.

    Load the portfolio LGD data.

    LGDData = readtable("LGDRatingGradeData.csv");

    The LGDData table contains loss-given-default (LGD) data for the portfolio. Each row of LGDData corresponds to a defaulted loan whose recovery period closed in 2023 or 2024. The RealizedLGD and RecoveryClosedYear table variables contain the realized LGD and the year the recovery period was closed.

    Create a table that contains only the data for the year 2024.

    observationLGD = LGDData(LGDData.RecoveryClosedYear==2024,:);

    Load the portfolio default data.

    defaultData = readtable("PDRatingGradeData.csv");

    defaultData contains portfolio observations made in the lookback period between 2020 to 2024. The table variable Default indicates whether a loan defaulted in the year contained in ObservationYear. Each row of defaultData corresponds to a loan and observation year pair.

    Use the groupsummary function to calculate the number of defaults in each observation year.

    lookbackDefault = groupsummary(defaultData, "ObservationYear", "sum", "Default")
    lookbackDefault=5×3 table
        2020    100    22
        2021    100    16
        2022    100    37
        2023    100    35
        2024    100    40
    
    

    lookbackDefault contains table variables ObservationYear, GroupCount, and sum_Default. For each year in ObservationYear, GroupCount and sum_Default, respectively, contain counts for the total number of loans and the number of defaulted loans in the portfolio.

    Perform the hypothesis test using an EL rate of 0.177, the number of defaults and loans in lookbackDefault, and the realized LGDs in observationLGD. The EL rate is set by the portfolio's corresponding regulatory body.

    expectedLossRate = 0.177;
    numDefaults = lookbackDefault.sum_Default;
    numLoans = lookbackDefault.GroupCount;
    observedLGDRates = observationLGD.RealizedLGD;
    [hTest,Output] = risk.validation.slotBacktest(numDefaults,numLoans,observedLGDRates,expectedLossRate)
    hTest = logical
       1
    
    
    Output = struct with fields:
                         RejectTest: 1
                             PValue: 0.0028
                      TestStatistic: 2.7652
                      CriticalValue: 1.6449
                    MeanDefaultRate: 0.3000
            MeanDefaultRateVariance: 4.2000e-04
                MeanObservedLGDRate: 0.7638
        MeanObservedLGDRateVariance: 0.0012
                       MeanLossRate: 0.2292
               MeanLossRateVariance: 3.5570e-04
                   ExpectedLossRate: 0.1770
                    ConfidenceLevel: 0.9500
    
    

    The output shows that enough evidence exists to reject the null hypothesis that the portfolio's EL is greater than its mean loss rate.

    Input Arguments

    collapse all

    Number of defaults for each year in the lookback period, specified as a vector of nonnegative integers. NumDefaults has the same number of elements as the number of years in the lookback period, and each element corresponds to a particular year. For more information about the observation and lookback periods, see More About.

    To perform a slot backtest on the portfolio level, specify NumDefaults as the number of defaults in the portfolio. To perform a slot backtest on the slot level, specify NumDefaults as the number of defaults in the slot.

    Example: [22 16 45 30 28]

    Data Types: single | double

    Number of loans for each year in the lookback period, specified as a vector of positive integers. NumLoans has the same number of elements as the number of years in the lookback period, and each element corresponds to a particular year. For more information about the observation and lookback periods, see More About.

    To perform a slot backtest on the portfolio level, specify NumLoans as the number of loans in the portfolio. To perform a slot backtest on the slot level, specify NumLoans as the number of loans in the slot.

    Example: [98 107 115 113]

    Data Types: single | double

    Loss-given-default (LGD) rates for loans whose recovery period closed in the observation period. ObservedLGDRates has the same number of elements as the number of loans whose recovery periods were closed in the observation period, and each element corresponds to a loan. For more information about the observation year, see More About.

    To perform a slot backtest on the portfolio level, specify ObservedLGDRates as the number of loans in the portfolio whose recovery period was closed in the observation period. To perform a slot backtest on the slot level, specify NumLoans as the number of loans in the slot whose recover period was closed in the observation period.

    Example: [1.00 0.85 1.07 … 0.32 0.82 1.03]

    Data Types: single | double

    Expected loss (EL) rate, specified as a positive numeric scalar. You can use an EL rate set by the portfolio's regulatory body, or estimate it by using historical data and a formula that is relevant for your data.

    Example: 0.177

    Data Types: single | double

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

    Output Arguments

    collapse all

    Hypothesis test result, returned as a numeric scalar.

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

    Output metrics, returned as a structure the following fields:

    • RejectTest — Numeric scalar indicating whether the null hypothesis was rejected. This field represents the same value as hSlotTest.

    • PValuep-value for the hypothesis test returned as a scalar in the range [0,1]. A small value indicates that the null hypothesis might not be valid.

    • TestStatistic — Value of the test statistic for the hypothesis test, returned as a numeric scalar.

    • CriticalValue — Critical value for the hypothesis test, returned as a numeric scalar.

    • MeanDefaultRate — Mean default rate for the lookback period, returned as a numeric scalar.

    • MeanDefaultRateVariance — Estimated variance for MeanDefaultRate.

    • MeanObservedLGDRate — Mean LGD rate for the loans whose recovery period closed in the observation period, returned as a numeric scalar.

    • MeanObservedLGDRateVariance — Estimated variance for MeanObservedLGDRate, returned as a numeric scalar.

    • MeanLossRate — Mean loss rate, returned as a numeric scalar. The mean loss rate is the product of MeanDefaultRate and MeanObservedLGDRate.

    • MeanLossRateVariance — Estimated variance for the mean loss rate, returned as a numeric scalar.

    • ExpectedLossRate — Expected loss rate, returned as a numeric scalar.

    • ConfidenceLevel — Confidence level for the hypothesis test.

    For more information about the slot backtest 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