Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# transprob

Estimate transition probabilities from credit ratings data

## Syntax

``[transMat,sampleTotals,idTotals] = transprob(data)``
``````[transMat,sampleTotals,idTotals] = transprob(___,Name, Value)``````

## Description

example

````[transMat,sampleTotals,idTotals] = transprob(data)` constructs a transition matrix from historical data of credit ratings.```

example

``````[transMat,sampleTotals,idTotals] = transprob(___,Name, Value)``` adds optional name-value pair arguments. ```

## Examples

collapse all

Using the historical credit rating table as input data from `Data_TransProb.mat` display the first ten rows and compute the transition matrix:

```load Data_TransProb data(1:10,:)```
```ans=10×3 table ID Date Rating __________ _____________ ______ '00010283' '10-Nov-1984' 'CCC' '00010283' '12-May-1986' 'B' '00010283' '29-Jun-1988' 'CCC' '00010283' '12-Dec-1991' 'D' '00013326' '09-Feb-1985' 'A' '00013326' '24-Feb-1994' 'AA' '00013326' '10-Nov-2000' 'BBB' '00014413' '23-Dec-1982' 'B' '00014413' '20-Apr-1988' 'BB' '00014413' '16-Jan-1998' 'B' ```
```% Estimate transition probabilities with default settings transMat = transprob(data)```
```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 ```

Using the historical credit rating table input data from `Data_TransProb.mat`, compute the transition matrix using the `cohort` algorithm:

```%Estimate transition probabilities with 'cohort' algorithm transMatCoh = transprob(data,'algorithm','cohort')```
```transMatCoh = 8×8 93.1345 5.9335 0.7456 0.1553 0.0311 0 0 0 1.7359 92.9198 4.5446 0.6046 0.1560 0 0 0.0390 0.1268 2.9716 91.9913 4.3124 0.4711 0.0544 0 0.0725 0.0210 0.3785 5.0683 89.7792 4.0379 0.4627 0.0421 0.2103 0.0221 0.1105 0.6851 6.2320 88.3757 3.6464 0.2873 0.6409 0 0 0.0761 0.7230 7.9909 86.1872 2.7397 2.2831 0 0 0 0.3094 1.8561 4.5630 80.8971 12.3743 0 0 0 0 0 0 0 100.0000 ```

Using the historical credit rating data with ratings investment grade (`'IG'`), speculative grade (`'SG'`), and default (`'D'`), from `Data_TransProb.mat` display the first ten rows and compute the transition matrix:

`dataIGSG(1:10,:)`
```ans=10×3 table ID Date Rating __________ _____________ ______ '00011253' '04-Apr-1983' 'IG' '00012751' '17-Feb-1985' 'SG' '00012751' '19-May-1986' 'D' '00014690' '17-Jan-1983' 'IG' '00012144' '21-Nov-1984' 'IG' '00012144' '25-Mar-1992' 'SG' '00012144' '07-May-1994' 'IG' '00012144' '23-Jan-2000' 'SG' '00012144' '20-Aug-2001' 'IG' '00012937' '07-Feb-1984' 'IG' ```
`transMatIGSG = transprob(dataIGSG,'labels',{'IG','SG','D'})`
```transMatIGSG = 3×3 98.6719 1.2020 0.1261 3.5781 93.3318 3.0901 0 0 100.0000 ```

Using the historical credit rating data with numeric ratings for investment grade (`1`), speculative grade (`2`), and default (`3`), from `Data_TransProb.mat` display the first ten rows and compute the transition matrix:

`dataIGSGnum(1:10,:)`
```ans=10×3 table ID Date Rating __________ _____________ ______ '00011253' '04-Apr-1983' 1 '00012751' '17-Feb-1985' 2 '00012751' '19-May-1986' 3 '00014690' '17-Jan-1983' 1 '00012144' '21-Nov-1984' 1 '00012144' '25-Mar-1992' 2 '00012144' '07-May-1994' 1 '00012144' '23-Jan-2000' 2 '00012144' '20-Aug-2001' 1 '00012937' '07-Feb-1984' 1 ```
`transMatIGSGnum = transprob(dataIGSGnum,'labels',{1,2,3})`
```transMatIGSGnum = 3×3 98.6719 1.2020 0.1261 3.5781 93.3318 3.0901 0 0 100.0000 ```

Using a MATLAB® table containing the historical credit rating cell array input data (`dataCellFormat`) from `Data_TransProb.mat,` estimate the transition probabilities with default settings.

```load Data_TransProb transMat = transprob(dataCellFormat)```
```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 ```

Using the historical credit rating cell array input data (`dataCellFormat`), compute the transition matrix using the `cohort` algorithm:

```%Estimate transition probabilities with 'cohort' algorithm transMatCoh = transprob(dataCellFormat,'algorithm','cohort')```
```transMatCoh = 8×8 93.1345 5.9335 0.7456 0.1553 0.0311 0 0 0 1.7359 92.9198 4.5446 0.6046 0.1560 0 0 0.0390 0.1268 2.9716 91.9913 4.3124 0.4711 0.0544 0 0.0725 0.0210 0.3785 5.0683 89.7792 4.0379 0.4627 0.0421 0.2103 0.0221 0.1105 0.6851 6.2320 88.3757 3.6464 0.2873 0.6409 0 0 0.0761 0.7230 7.9909 86.1872 2.7397 2.2831 0 0 0 0.3094 1.8561 4.5630 80.8971 12.3743 0 0 0 0 0 0 0 100.0000 ```

## Input Arguments

collapse all

Using `transprob` to estimate transition probabilities given credit ratings historical data (that is, credit migration data), the `data` input can be one of the following:

• An `nRecords`-by-`3` MATLAB® table containing the historical credit ratings data of the form:

``` ID Date Rating __________ _____________ ______ '00010283' '10-Nov-1984' 'CCC' '00010283' '12-May-1986' 'B' '00010283' '29-Jun-1988' 'CCC' '00010283' '12-Dec-1991' 'D' '00013326' '09-Feb-1985' 'A' '00013326' '24-Feb-1994' 'AA' '00013326' '10-Nov-2000' 'BBB' '00014413' '23-Dec-1982' 'B'```
where each row contains an ID (column 1), a date (column 2), and a credit rating (column 3). Column 3 is the rating assigned to the corresponding ID on the corresponding date. All information corresponding to the same ID must be stored in contiguous rows. Sorting this information by date is not required, but recommended for efficiency. When using a MATLAB table input, the names of the columns are irrelevant, but the ID, date and rating information are assumed to be in the first, second, and third columns, respectively. Also, when using a table input, the first and third columns can be categorical arrays, and the second can be a datetime array. The following summarizes the supported data types for table input:

Data Input TypeID (1st Column)Date (2nd Column)Rating (3rd Column)
Table

• Numeric array

• Cell array of character vectors

• Categorical array

• Numeric array

• Cell array of character vectors

• Datetime array

• Numeric array

• Cell array of character vectors

• Categorical array

• An `nRecords`-by-`3` cell array of character vectors containing the historical credit ratings data of the form:

```'00010283' '10-Nov-1984' 'CCC' '00010283' '12-May-1986' 'B' '00010283' '29-Jun-1988' 'CCC' '00010283' '12-Dec-1991' 'D' '00013326' '09-Feb-1985' 'A' '00013326' '24-Feb-1994' 'AA' '00013326' '10-Nov-2000' 'BBB' '00014413' '23-Dec-1982' 'B'```
where each row contains an ID (column 1), a date (column 2), and a credit rating (column 3). Column 3 is the rating assigned to the corresponding ID on the corresponding date. All information corresponding to the same ID must be stored in contiguous rows. Sorting this information by date is not required, but recommended for efficiency. IDs, dates, and ratings are stored in character vector format, but they can also be entered in numeric format. The following summarizes the supported data types for cell array input:

Data Input TypeID (1st Column)Date (2nd Column)Rating (3rd Column)
Cell

• Numeric elements

• Character vector elements

• Numeric elements

• Character vector elements

• Numeric elements

• Character vector elements

• A preprocessed data structure obtained using `transprobprep`. This data structure contains the fields`'idStart'`, `'numericDates'`, `'numericRatings'`, and `'ratingsLabels'`.

Data Types: `table` | `cell` | `struct`

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: ```transMat = transprob(data,'algorithm','cohort')```

Estimation algorithm, specified as the comma-separated pair consisting of `'algorithm'` and a character vector with a value of `'duration'` or `'cohort'`.

Data Types: `char`

End date of the estimation time window, specified as the comma-separated pair consisting of `'endDate'` and a date character vector, serial date number, or datetime object. The `endDate` cannot be a date before the `startDate`.

Data Types: `char` | `double` | `datetime`

Credit-rating scale, specified as the comma-separated pair consisting of `'labels'` and a `nRatings`-by-`1`, or `1`-by-`nRatings` cell array of character vectors.

`labels` must be consistent with the ratings labels used in the third column of `data`. Use a cell array of numbers for numeric ratings, and a cell array for character vectors for categorical ratings.

### Note

When the input argument `data` is a preprocessed data structure obtained from a previous call to `transprobprep`, this optional input for `'labels` is unused because the labels in the `'ratingsLabels'` field of `transprobprep` take priority.

Data Types: `cell`

Number of credit-rating snapshots per year to be considered for the estimation, specified as the comma-separated pair consisting of `'snapsPerYear'` and a numeric value of `1`, `2`, `3`, `4`, `6`, or `12`.

### Note

This parameter is only used with the `'cohort'` `algorithm`.

Data Types: `double`

Start date of the estimation time window, specified as the comma-separated pair consisting of `'startDate'` and a date character vector, serial date number, or datetime object.

Data Types: `char` | `double` | `datetime`

Length of the transition interval, in years, specified as the comma-separated pair consisting of `'transInterval'` and a numeric value.

Data Types: `double`

## Output Arguments

collapse all

Matrix of transition probabilities in percent, returned as a `nRatings`-by-`nRatings` transition matrix.

Structure with sample totals, returned with fields:

• `totalsVec` — A vector of size `1`-by-`nRatings`.

• `totalsMat` — A matrix of size `nRatings`-by-`nRatings`.

• `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 ratingj (all the diagonal elements are zero). The total time spent on rating i is stored in `totalsVec`(i). For example, if there are 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```
Then
```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```
Then

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

IDs totals, returned as a struct array of size `nIDs`-by-`1`, where nIDs is the number of distinct IDs in column 1 of `data` when this is a table or cell array or, equivalently, equal to the length of the `idStart` field minus 1 when `data` is a preprocessed data structure from `transprobprep`. For each ID in the sample, `idTotals` contains one structure with the following fields:

• `totalsVec` — A sparse vector of size `1`-by-`nRatings`.

• `totalsMat` — A sparse matrix of size `nRatings`-by-`nRatings`.

• `algorithm` — A character vector with values `'duration'` or `'cohort'`.

These fields contain the same information described for the output `sampleTotals`, but at an ID level. For example, for `'duration'`, `idTotals`(k).`totalsVec` contains the total time that the k-th company spent on each rating.

collapse all

### Cohort Estimation

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.

### Duration Estimation

Unlike the cohort method, 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.

## Algorithms

collapse all

### Cohort Estimation

The algorithm first determines a sequence t0,...,tK of snapshot dates. The elapsed time, in years, between two consecutive snapshot dates tk-1 and tk is equal to `1` / ns, where ns is the number of snapshots per year. These K +`1` dates determine K transition periods.

The algorithm computes ${N}_{i}^{n}$, the number of transition periods in which obligor n starts at rating i. These are added up over all obligors to get Ni, the number of obligors in the sample that start a period at rating i. The number periods in which obligor n starts at rating i and ends at rating j, or migrates from i to j, denoted by${N}_{ij}^{n}$, is also computed. These are also added up to get ${N}_{ij}^{}$, the total number of migrations from i to j in the sample.

The estimate of the transition probability from i to j in one period, denoted by${P}_{ij}^{}$, is given by:

`${P}_{ij}^{}=\frac{Nij}{Ni}$`

These probabilities are arranged in a one-period transition matrix P0, where the i,j entry in P0 is Pij.

If the number of snapshots per year ns is 4 (quarterly snapshots), the probabilities in P0 are 3-month (or 0.25-year) transition probabilities. You may, however, be interested in 1-year or 2-year transition probabilities. The latter time interval is called the transition interval, Δt, and it is used to convert P0 into the final transition matrix, P, according to the formula:

`$P={P}_{0}^{ns△t}$`

For example, if ns = `4` and Δt = `2`, P contains the 2-year transition probabilities estimated from quarterly snapshots.

### Note

For the cohort algorithm, optional output arguments `idTotals` and `sampleTotals` from `transprob` contain the following information:

• `idTotals(n).totalsVec` = $\left({N}_{i}^{n}\right)\forall i$

• `idTotals(n).totalsMat` = $\left({N}_{i,j}^{n}\right)\forall ij$

• `idTotals(n).algorithm` = `'cohort'`

• `sampleTotals.totalsVec` = $\left({N}_{i}^{}\right)\forall i$

• `sampleTotals.totalsMat` = $\left({N}_{i,j}^{}\right)\forall ij$

• `sampleTotals.algorithm` = `'cohort'`

For efficiency, the vectors and matrices in `idTotals` are stored as sparse arrays.

### Duration Estimation

The algorithm computes ${T}_{i}^{n}$, the total time that obligor n spends in rating i within the estimation time window. These quantities are added up over all obligors to get ${T}_{i}^{}$, the total time spent in rating i, collectively, by all obligors in the sample. The algorithm also computes ${T}_{ij}^{n}$, the number times that obligor n migrates from rating i to rating j, with i not equal to j, within the estimation time window. And it also adds them up to get ${T}_{ij}^{}$, the total number of migrations, by all obligors in the sample, from the rating i to j, with i not equal to j.

To estimate the transition probabilities, the duration algorithm first computes a generator matrix $\Lambda$. Each off-diagonal entry of this matrix is an estimate of the transition rate out of rating i into rating j, and is given by:

`${\lambda }_{ij}^{}=\frac{{T}_{ij}^{}}{{T}_{i}^{}},i\ne j$`

The diagonal entries are computed as:

`${\lambda }_{ii}^{}=-\sum _{j\ne i}^{}{\lambda }_{ij}^{}$`

With the generator matrix and the transition interval Δt (e.g., Δt = `2` corresponds to 2-year transition probabilities), the transition matrix is obtained as $P=\mathrm{exp}\left(\Delta t\Lambda \right)$, where exp denotes matrix exponentiation (`expm` in MATLAB).

### Note

For the duration algorithm, optional output arguments `idTotals` and `sampleTotals` from `transprob` contain the following information:

• `idTotals(n).totalsVec` = $\left({T}_{i}^{n}\right)\forall i$

• `idTotals(n).totalsMat` = $\left({T}_{i,j}^{n}\right)\forall ij$

• `idTotals(n).algorithm` = `'duration'`

• `sampleTotals.totalsVec` = $\left({T}_{i}^{}\right)\forall i$

• `sampleTotals.totalsMat` = $\left({T}_{i,j}^{}\right)\forall ij$

• `sampleTotals.algorithm` = `'duration'`

For efficiency, the vectors and matrices in `idTotals` are stored as sparse arrays.

## References

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