# Documentation

### This is machine translation

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

# riskContribution

Generate risk contributions for each counterparty in portfolio

## Syntax

``Contributions = riskContribution(cmc)``

## Description

example

````Contributions = riskContribution(cmc)` returns a table of risk contributions for each counterparty in the portfolio. The risk `Contributions` table allocates the full portfolio risk measures to each counterparty, such that the counterparty risk contributions sum to the portfolio risks reported by `portfolioRisk`. Before you use the `riskContribution` function, you must run the `simulate` function. For more information on using a `creditMigrationCopula` object, see `creditMigrationCopula`.```

## Examples

collapse all

```load CreditMigrationData.mat; ```

Scale the bond prices for portfolio positions for each bond.

```migrationValues = migrationPrices .* numBonds; ```

Create a `creditMigrationCopula` object with a four-factor model using `creditMigrationCopula`.

```cmc = creditMigrationCopula(migrationValues,ratings,transMat,... lgd,weights,'FactorCorrelation',factorCorr) ```
```cmc = creditMigrationCopula with properties: Portfolio: [250x5 table] FactorCorrelation: [4x4 double] RatingLabels: [8x1 string] TransitionMatrix: [8x8 double] VaRLevel: 0.9500 PortfolioValues: [] ```

Set the `VaRLevel` to 99%.

```cmc.VaRLevel = 0.99; ```

Use the `simulate` function to simulate 100,000 scenarios, and then use the `riskContribution` function to generate the `Contributions` table.

```cmc = simulate(cmc,1e5); Contributions = riskContribution(cmc); Contributions(1:10,:) ```
```ans = 10x3 table ID EL CVaR __ ______ ______ 1 16.397 254.12 2 9.1179 134.31 3 5.7873 236.84 4 6.4235 338.23 5 22.739 544.69 6 10.776 704.29 7 2.9046 551.4 8 12.152 265.97 9 2.1567 26.112 10 1.7495 15.933 ```

## Input Arguments

collapse all

`creditMigrationCopula` object obtained after running the `simulate` function.

For more information on `creditMigrationCopula` objects, see `creditMigrationCopula`.

## Output Arguments

collapse all

Risk contributions, returned as a table containing the following risk contributions for each counterparty:

• `EL` — Expected loss for the particular counterparty over the scenarios

• `CVaR` — Conditional value at risk for the particular counterparty over the scenarios

The risk `Contributions` table allocates the full portfolio risk measures to each counterparty, such that the counterparty risk contributions sum to the portfolio risks reported by `portfolioRisk`.

## References

[1] Crouhy, M., Galai, D., and Mark, R. “A Comparative Analysis of Current Credit Risk Models.” Journal of Banking and Finance. Vol. 24, 2000, pp. 59–117.

[2] Glasserman, P. “Measuring Marginal Risk Contributions in Credit Portfolios.” Journal of Computational Finance. Vol. 9, No. 2, Winter 2005/2006.

[3] Gordy, M. “A Comparative Anatomy of Credit Risk Models.” Journal of Banking and Finance. Vol. 24, 2000, pp. 119–149.

[4] Gupton, G., Finger, C., and Bhatia, M. “CreditMetrics – Technical Document.” J. P. Morgan, New York, 1997.

[5] Jorion, P. Financial Risk Manager Handbook. 6th Edition. Wiley Finance, 2011.

[6] Kalkbrener, M., Lotter, H., and Overbeck, L. “Sensible and Efficient Capital Allocation for Credit Portfolios.” Risk. 17, 2004, pp. S19–S24.

[7] Löffler, G., and Posch, P. Credit Risk Modeling Using Excel and VBA. Wiley Finance, 2007.

[8] McNeil, A., Frey, R., and Embrechts, P. Quantitative Risk Management: Concepts, Techniques, and Tools. Princeton University Press, 2005.