# transprobbytotals

Estimate transition probabilities using `totals` structure input

## Syntax

``[transMat,sampleTotals] = transprobbytotals(totals)``
``[transMat,sampleTotals] = transprobbytotals(___,Name,Value)``

## Description

example

````[transMat,sampleTotals] = transprobbytotals(totals)` estimates transition probabilities using a `totals` structure input. `transprobbytotals` is useful for removing outlier information, obtaining bootstrapped confidence intervals, or computing transition probability estimates for different periodicity parameters (1-year transitions, 2-year transitions, and so on) efficiently.```

example

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

## Examples

collapse all

Use historical credit rating input data from `Data_TransProb.mat` and `transprob` to generate input for `transprobbytotals`:

```load Data_TransProb % Call TRANSPROB with three output arguments [transMat, sampleTotals, idTotals] = 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 ```

Suppose companies 4 and 27 are outliers and you want to remove them from the pre-processed `idTotals` struct array and estimate the new transition probabilities.

```idTotals([4 27]) = []; [transMat1, sampleTotals1] = transprobbytotals(idTotals); transMat1```
```transMat1 = 8×8 93.1172 5.8427 0.8231 0.1763 0.0377 0.0012 0.0001 0.0017 1.6213 93.1501 4.3584 0.6614 0.1631 0.0055 0.0004 0.0397 0.1239 2.9027 92.2297 4.0628 0.5367 0.0661 0.0028 0.0753 0.0236 0.2313 5.0070 90.1825 3.7986 0.4734 0.0642 0.2193 0.0216 0.1134 0.6357 5.7959 88.9866 3.4497 0.2920 0.7050 0.0010 0.0062 0.1081 0.8697 7.3367 86.7217 2.5171 2.4395 0.0002 0.0011 0.0120 0.2591 1.4340 4.3034 81.3027 12.6875 0 0 0 0 0 0 0 100.0000 ```

Obtain the 1-year, 2-year, 3-year, 4-year, and 5-year default probabilities, without the outlier information (i.e., using `sampleTotals1`).

```DefProb = zeros(7,5); for t = 1:5 transMatTemp = transprobbytotals(sampleTotals1,'transInterval',t); DefProb(:,t) = transMatTemp(1:7,8); end DefProb```
```DefProb = 7×5 0.0017 0.0070 0.0159 0.0285 0.0450 0.0397 0.0828 0.1299 0.1813 0.2377 0.0753 0.1606 0.2567 0.3640 0.4831 0.2193 0.4675 0.7430 1.0445 1.3700 0.7050 1.4668 2.2759 3.1232 4.0000 2.4395 4.9282 7.4071 9.8351 12.1847 12.6875 23.1184 31.7177 38.8282 44.7266 ```

## Input Arguments

collapse all

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```
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'```

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`

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose `Name` in quotes.

Example: ```transMat = transprobbytotals(Totals1,'transInterval',5)```

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`

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 `nRatings1`-by-`nRatings2` transition matrix.

Structure with sample totals, returned with fields:

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

• `totalsMat` — A matrix of size `nRatings1`-by-`nRatings2` with `nRatings1``nRatings2`.

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

If `totals` is a struct array, `sampleTotals` contains the aggregated information. That is, `sampleTotals.totalsVec` is the sum of `totals`(k).`totalsVec` over all k, and similarly for `totalsMat`. When `totals` is itself a single structure, `sampleTotals` and `totals` are the same.

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.

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

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

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