Main Content

risk.validation.slotBacktest

R2026b

Slot backtest

Since R2026a

    Description

    hSlotTest = risk.validation.slotBacktest(NumDefaults,NumLoans,ObservedLGDRates,ExpectedLossRate) returns the result of a slot backtest, hSlotTest, 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,slotOutput] = risk.validation.slotBacktest(___) also returns a structure slotOutput that contains summary metrics. Specify slotOutput as the second output argument with any of the input argument combinations in the previous syntaxes.

    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
        ObservationYear    GroupCount    sum_Default
        _______________    __________    ___________
    
             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;
    [hSlotTest,slotOutput] = risk.validation.slotBacktest(numDefaults,numLoans,observedLGDRates,expectedLossRate)
    hSlotTest = 
    1
    
    slotOutput = 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]

    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]

    Loss-given-default (LGD) rates for loans whose recovery period closed in the observation period, specified as a vector of positive numbers. 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 observed LGD rates in the portfolio whose recovery period was closed in the observation period. To perform a slot backtest on the slot level, specify ObservedLGDRates as the observed LGD rates in the slot whose recovery period was closed in the observation period.

    Example: [1.00 0.85 1.07 0.32 0.82 1.03]

    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

    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 1 or 0.

    • 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 with the following fields:

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

    • PValue — Numeric scalar in the range [0,1] representing the p-value for the hypothesis test. A small value indicates that the null hypothesis might not be valid.

    • TestStatistic — Numeric scalar with the value of the test statistic for the hypothesis test.

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

    • MeanDefaultRate — Numeric scalar representing the mean default rate for the lookback period.

    • MeanDefaultRateVariance — Numeric scalar representing the estimated variance for MeanDefaultRate.

    • MeanObservedLGDRate — Numeric scalar representing the mean LGD rate for the loans whose recovery period closed in the observation period.

    • MeanObservedLGDRateVariance — Numeric scalar representing the estimated variance for MeanObservedLGDRate.

    • MeanLossRate — Numeric scalar representing the mean loss rate. The mean loss rate is the product of MeanDefaultRate and MeanObservedLGDRate.

    • MeanLossRateVariance — Numeric scalar representing the estimated variance for the mean loss rate.

    • ExpectedLossRate — Numeric scalar representing the expected loss rate.

    • ConfidenceLevel — Numeric scalar representing the 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