主要内容

risk.validation.plotSpearmanRanks

Plot Spearman rank correlation

Since R2026a

    Description

    risk.validation.plotSpearmanRanks(Sample1,Sample2) plots the ranks of the observations in Sample1 against the ranks of the observations in Sample2. The plot also displays the Spearman rank correlation coefficient in the lower right corner.

    example

    risk.validation.plotSpearmanRanks(ax,Sample1,Sample2) plots into the axes specified by ax instead of into the current axes (gca).

    risk.validation.plotSpearmanRanks(Sample1,Sample2,Parent=ax) plots into the axes specified by ax instead of into the current axes (gca).

    h = risk.validation.plotSpearmanRanks(___) returns handles to the plotted graphics objects.

    Examples

    collapse all

    Load the CreditValidationData data.

    load CreditValidationData.mat

    The table LGDModelsValidationData contains variables RegressionLGD, TobitLGD, and ObservedLGD. RegressionLGD and TobitLGD contain data for predicted loss given default (LGD), and ObservedLGD contains data for observed LGD.

    Plot the ranks of the regression model's LGD predictions against the Tobit model's predictions. Then plot the ranks of the observed LGDs against each model's predictions.

    Regression = LGDModelsValidationData.RegressionLGD;
    Tobit = LGDModelsValidationData.TobitLGD;
    Observed = LGDModelsValidationData.ObservedLGD;
    tiledlayout("vertical")
    nexttile
    risk.validation.plotSpearmanRanks(Regression,Tobit)
    nexttile
    risk.validation.plotSpearmanRanks(Regression,Observed)
    nexttile
    risk.validation.plotSpearmanRanks(Tobit,Observed)

    The plots show that the regression model predictions are highly correlated with the Tobit model predictions. This is consistent with their Spearman correlation of 0.998. However, each model's predictions are only moderately correlated with the observed predictions.

    Input Arguments

    collapse all

    Sample data, specified as two numeric vectors. Sample1 and Sample2 must be of the same length.

    Example: normrnd(0,1,1,100),normrnd(5,2,1,100)

    Data Types: single | double

    Target axes, specified as an Axes object. If you do not specify the axes, then risk.validation.plotSpearmanRanks uses the current axes (gca).

    Output Arguments

    collapse all

    Handles to plotted graphics object, returned as a Line object.

    References

    [1] Basel Committee on Banking Supervision, "Calculation of RWA for market risk." January, 2022. https://www.bis.org/basel_framework/chapter/MAR/32.htm?inforce=20220101&published=20191215.

    Version History

    Introduced in R2026a