Documentation

# riskContribution

Generate risk contributions for each counterparty in portfolio

## Description

example

Contributions = riskContribution(cdc) 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.

### Note

When creating a creditDefaultCopula object, you can set the 'UseParallel' property if you have Parallel Computing Toolbox™. Once the 'UseParallel' property is set, parallel processing is used to compute riskContribution.

The simulate function must be run before riskContribution is used. For more information on using a creditDefaultCopula object, see creditDefaultCopula.

example

Contributions = riskContribution(cdc,Name,Value) adds an optional name-value pair argument for VaRWindow.

## Examples

collapse all

Load saved portfolio data.

Create a creditDefaultCopula object with a two-factor model.

cdc =
creditDefaultCopula with properties:

Portfolio: [100x5 table]
FactorCorrelation: [2x2 double]
VaRLevel: 0.9500
UseParallel: 0
PortfolioLosses: []

Set the VaRLevel to 99%.

cdc.VaRLevel = 0.99;

Use the simulate function before running riskContribution. Then use riskContribution with the creditDefaultCopula object to generate the risk Contributions table.

cdc = simulate(cdc,1e5);
Contributions = riskContribution(cdc);
Contributions(1:10,:)
ans=10×5 table
ID        EL           Std          VaR          CVaR
__    __________    __________    ________    __________

1      0.038604       0.02495     0.10482       0.12868
2      0.067068      0.036472     0.17378       0.24527
3        1.2527       0.62684      2.0384        2.3103
4     0.0023253    0.00073407           0     0.0026274
5       0.11766      0.042185     0.27028       0.26223
6       0.12437       0.07545     0.37669       0.47915
7       0.82913        0.3475         1.6        1.6516
8    0.00085629    4.3929e-05    0.001544    0.00089197
9       0.91406       0.87311        3.55         4.009
10       0.24352       0.36543      1.5864        2.2781

Note: Due to simulation noise or numerical error, the VaR contribution can sometimes be greater than the CVaR contribution.

## Input Arguments

collapse all

creditDefaultCopula object obtained after running the simulate function.

For more information on creditDefaultCopula objects, see creditDefaultCopula.

### 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: Contributions = riskContribution(cdc,'VaRWindow',0.3)

Size of the window used to compute VaR contributions, specified as the comma-separated pair consisting of 'VaRWindow' and a scalar numeric with a percent value. Scenarios in the VaR scenario set are used to calculate the individual counterparty VaR contributions.

The default is 0.05, meaning that all scenarios with portfolio losses within 5 percent of the VaR are included when computing counterparty VaR contributions.

Data Types: double

## 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

• Std — Standard deviation of loss for the particular counterparty over the scenarios

• VaR — Value at risk 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.

collapse all

### Risk Contributions

The riskContribution function reports the individual counterparty contributions to the total portfolio risk measures using four risk measures: expected loss (EL), standard deviation (Std), VaR, and CVaR.

• EL is the expected loss for each counterparty and is the mean of the counterparty's losses across all scenarios.

• Std is the standard deviation for counterparty i:

$StdCon{t}_{i}=St{d}_{i}\frac{{\sum }_{j}St{d}_{j}{\rho }_{ij}}{St{d}_{\rho }}$

where

Stdi is the standard deviation of losses from counterparty i.

Stdρ is the standard deviation of portfolio losses.

ρij is the correlation of the losses between counterparties i and j.

• VaR contribution is the mean of a counterparty’s losses across all scenarios in which the total portfolio loss is within some small neighborhood around the Portfolio VaR. The default of the ‘VaRWindow’ parameter is 0.05 meaning that all scenarios in which the total portfolio loss is within 5% of the portfolio VaR are included in VaR neighborhood.

• CVaR is the mean of the counterparty’s losses in the set of scenarios in which the total portfolio losses exceed the portfolio VaR.

## References

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

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