Contenido principal

risk.validation.plotSpearmanRanks

R2026b

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

    Note

    The risk.validation.plotSpearmanRanks function ignores the ax argument when you specify the Parent name-value argument.

    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 the 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)

    Figure contains 3 axes objects. Axes object 1 with title Spearman Correlation, xlabel Distribution 1 Rank, ylabel Distribution 2 Rank contains a line object which displays its values using only markers. This object represents r = 0.99776. Axes object 2 with title Spearman Correlation, xlabel Distribution 1 Rank, ylabel Distribution 2 Rank contains a line object which displays its values using only markers. This object represents r = 0.41197. Axes object 3 with title Spearman Correlation, xlabel Distribution 1 Rank, ylabel Distribution 2 Rank contains a line object which displays its values using only markers. This object represents r = 0.41202.

    The plots show that the regression model predictions are highly correlated with the Tobit model predictions. This observation 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 by using the ax input argument or the Parent name-value argument, then the risk.validation.plotSpearmanRanks function uses the current axes (gca) or creates an Axes object if one does not exist. For more information on creating an Axes object, see axes and Axes Properties.

    Note

    The risk.validation.plotSpearmanRanks function ignores the ax argument when you specify the Parent name-value argument.

    Output Arguments

    collapse all

    Handle to plotted graphics object, returned as a Line object. For more information, see Line Properties.

    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