Aggregate credit ratings information into fewer rating categories

aggregates the credit ratings information stored in the
`totalsGrouped`

= transprobgrouptotals(`totals`

,`groupingEdges`

)`totals`

input into fewer ratings categories, which are
defined by the `groupingEdges`

argument.

Use historical credit rating input data from `Data_TransProb.mat`

. Load input data from file `Data_TransProb.mat`

.

load Data_TransProb % Call TRANSPROB with two output arguments [transMat, sampleTotals] = transprob(data); transMat

`transMat = `*8×8*
93.1170 5.8428 0.8232 0.1763 0.0376 0.0012 0.0001 0.0017
1.6166 93.1518 4.3632 0.6602 0.1626 0.0055 0.0004 0.0396
0.1237 2.9003 92.2197 4.0756 0.5365 0.0661 0.0028 0.0753
0.0236 0.2312 5.0059 90.1846 3.7979 0.4733 0.0642 0.2193
0.0216 0.1134 0.6357 5.7960 88.9866 3.4497 0.2919 0.7050
0.0010 0.0062 0.1081 0.8697 7.3366 86.7215 2.5169 2.4399
0.0002 0.0011 0.0120 0.2582 1.4294 4.2898 81.2927 12.7167
0 0 0 0 0 0 0 100.0000

Group into investment grade (ratings 1-4) and speculative grade (ratings 5-7); note, the default is the last rating (number 8).

```
edges = [4 7 8];
sampleTotalsGrp = transprobgrouptotals(sampleTotals,edges);
% Transition matrix at investment grade / speculative grade level
transMatIGSG = transprobbytotals(sampleTotalsGrp)
```

`transMatIGSG = `*3×3*
98.5336 1.3608 0.1056
3.9155 92.9692 3.1153
0 0 100.0000

Obtain the 1-year, 2-year, 3-year, 4-year, and 5-year default probabilities at investment grade and speculative grade level.

DefProb = zeros(2,5); for t = 1:5 transMatTemp = transprobbytotals(sampleTotalsGrp,'transInterval',t); DefProb(:,t) = transMatTemp(1:2,3); end DefProb

`DefProb = `*2×5*
0.1056 0.2521 0.4359 0.6537 0.9027
3.1153 6.0157 8.7179 11.2373 13.5881

`totals`

— Total transitions observedstructure | struct array

Total transitions observed, specified as a structure, or a struct array of length nTotals, with fields:

`totalsVec`

— A sparse vector of size`1`

-by-`nRatings1`

.`totalsMat`

— A sparse matrix of size`nRatings1`

-by-`nRatings2`

with`nRatings1`

≤`nRatings2`

.`algorithm`

— A character vector with values`'duration'`

or`'cohort'`

.

For the `'duration'`

algorithm,
`totalsMat`

(*i*,*j*)
contains the total transitions observed out of rating
*i* into rating *j* (all the
diagonal elements are 0). The total time spent on rating
*i* is stored in
`totalsVec`

(*i*). For example, you
have three rating categories, Investment Grade (`IG`

),
Speculative Grade (`SG`

), and Default
(`D`

), and the following
information:

Total time spent IG SG D in rating: 4859.09 1503.36 1162.05 Transitions IG SG D out of (row) IG 0 89 7 into (column): SG 202 0 32 D 0 0 0

totals.totalsVec = [4859.09 1503.36 1162.05] totals.totalsMat = [ 0 89 7 202 0 32 0 0 0] totals.algorithm = 'duration'

For the `'cohort'`

algorithm,
`totalsMat`

(*i*,*j*)
contains the total transitions observed from rating *i*
to rating *j*, and
`totalsVec`

(*i*) is the initial
count in rating *i*. For example, given the following
information:

Initial count IG SG D in rating: 4808 1572 1145 Transitions IG SG D from (row) IG 4721 80 7 to (column): SG 193 1347 32 D 0 0 1145

totals.totalsVec = [4808 1572 1145] totals.totalsMat = [4721 80 7 193 1347 32 0 0 1145 totals.algorithm = 'cohort'

Common totals structures are the optional output arguments from
`transprob`

:

`sampleTotals`

— A single structure summarizing the totals information for the whole dataset.`idTotals`

— A struct array with the totals information at the ID level.

**Data Types: **`struct`

| `structure`

`groupingEdges`

— Indicator for grouping credit ratings into categoriesnumeric array

Indicator for grouping credit ratings into categories, specified as a numeric array.

This table illustrates how to group a list of whole ratings into
investment grade (`IG`

) and speculative grade
(`SG`

) categories. Eight ratings are in the
original list. Ratings `1`

to `4`

are
`IG`

, ratings `5`

to
`7`

are `SG`

, and rating
`8`

is a category of its own. In this example, the
array of grouping edges is ` [4 7 8]`

.

Original ratings: 'AAA' 'AA' 'A' 'BBB' | 'BB' 'B' 'CCC' | 'D' | | Relative ordering: (1) (2) (3) (4) | (5) (6) (7) | (8) | | Grouped ratings: 'IG' | 'SG' | 'D' | | Grouping edges: (4) | (7) | (8)

In general, if `groupingEdges`

has
*K* elements `edge1`

<
`edge2`

< `...`

<`edge`

*K*, ratings
`1`

to `edge1`

(inclusive) are
grouped in the first category, ratings
`edge1`

+`1`

to
`edge2`

in the second category, and so
forth.

Regarding the last element,
`edge`

*K*:

If

*n*`Ratings1`

equals*n*`Ratings2`

, then`edge`

*K*must equal*n*`Ratings1`

. This leads to*K*groups, and*n*`RatingsGrouped1`

=*n*`RatingsGrouped2`

=*K*.If

*n*`Ratings1`

<*n*`Ratings2`

, then either:`edge`

*K*equals*n*`Ratings1`

, in which case ratings`edge`

*K*+`1`

,...,`nRatings2`

are treated as categories of their own. This results in*K*+(`nRatings2`

-edge*K*) groups, with`nRatingsGrouped1`

=*K*and`nRatingsGrouped2`

=*K*+ (`nRatings2`

–`edge`

*K*); or`edge`

*K*equals`nRatings2`

, in which case there must be a*j*th edge element,`edge`

*j*, such that`edge`

*j*equals`nRatings1`

. This leads to*K*groups, and`nRatingsGrouped1`

=*j*and`nRatingsGrouped2`

=*K*.

**Data Types: **`double`

`totalsGrouped`

— Aggregated information by categoriesstructure | struct array

Aggregated information by categories, returned as a structure, or a
struct array of length `nTotals`

, with fields:

`totalsVec`

— A vector of size`1`

-by-`nRatingsGrouped1`

.`totalsMat`

— A matrix of size`nRatingsGrouped1`

-by-`nRatingsGrouped2`

.`algorithm`

— A character vector,`'duration'`

or`'cohort'`

.

`nRatingsGrouped1`

and
`nRatingsGrouped2`

are defined in the description
of `groupingEdges`

. Each structure contains
aggregated information by categories, based on the information provided
in the corresponding structure in `totals`

, according
to the grouping of ratings defined by `groupingEdges`

and consistent with the `algorithm`

choice.

Following the examples in the description of the
`totals`

input, suppose `IG`

and
`SG`

are grouped into a single
`ND`

(Not-Defaulted) category, using the
edges`[2 3]`

. For the `'cohort'`

algorithm, the output
is:

totalsGrouped.totalsVec = [6380 1145] totalsGrouped.totalsMat = [6341 39 0 1145] totalsGrouped.algorithm = 'cohort'

`'duration'`

algorithm:totalsGrouped.totalsVec = [6362.45 1162.05] totalsGrouped.totalsMat = [0 39 0 0] totalsGrouped.algorithm = 'duration'

The `cohort`

algorithm estimates the
transition probabilities based on a sequence of snapshots of credit ratings at
regularly spaced points in time.

If the credit rating of a company changes twice between two snapshot dates,
the intermediate rating is overlooked and only the initial and final ratings
influence the estimates. For more information, see the Algorithms section of
`transprob`

.

Unlike the `cohort`

algorithm, the
`duration`

algorithm estimates the transition probabilities
based on the full credit ratings history, looking at the exact dates on which
the credit rating migrations occur.

There is no concept of snapshots in this method, and all credit rating
migrations influence the estimates, even when a company's rating changes twice
within a short time. For more information, see the Algorithms section of
`transprob`

.

[1] Hanson, S., T. Schuermann. "Confidence Intervals for Probabilities of
Default." *Journal of Banking & Finance.* Vol. 30(8),
Elsevier, August 2006, pp. 2281–2301.

[2] Löffler, G., P. N. Posch. *Credit Risk Modeling Using Excel
and VBA.* West Sussex, England: Wiley Finance, 2007.

[3] Schuermann, T. "Credit Migration Matrices." in E. Melnick, B. Everitt
(eds.), *Encyclopedia of Quantitative Risk Analysis and
Assessment.* Wiley, 2008.

A modified version of this example exists on your system. Do you want to open this version instead?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)