Generate risk contributions for each counterparty in portfolio
returns a table of risk contributions for each counterparty in the portfolio.
Contributions = riskContribution(
Contributions table allocates the full portfolio
risk measures to each counterparty, such that the counterparty risk
contributions sum to the portfolio risks reported by
When creating a
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
Before you use the
riskContribution function, you must run
simulate function. For more
information on using a
creditMigrationCopula object, see
adds an optional name-value pair argument for
Contributions = riskContribution(
Determine the Risk Contribution for Each Counterparty for a
Load the saved portfolio data.
Scale the bond prices for portfolio positions for each bond.
migrationValues = migrationPrices .* numBonds;
creditMigrationCopula object with a four-factor model using
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 UseParallel: 0 PortfolioValues: 
VaRLevel to 99%.
cmc.VaRLevel = 0.99;
simulate function to simulate 100,000 scenarios, and then use the
riskContribution function to generate the
cmc = simulate(cmc,1e5); Contributions = riskContribution(cmc); Contributions(1:10,:)
ans=10×5 table ID EL Std VaR CVaR __ ______ ______ ______ ______ 1 15.521 41.153 238.72 279.18 2 8.49 18.838 92.074 122.19 3 6.0937 20.069 113.22 181.53 4 6.6964 55.885 272.23 313.25 5 23.583 73.905 360.32 573.39 6 10.722 114.97 445.94 728.38 7 1.8393 84.754 262.32 490.39 8 11.711 39.768 175.84 253.29 9 2.2154 4.4038 22.797 31.039 10 1.7453 2.5545 9.8801 17.603
creditMigrationCopula object obtained after running
For more information on
Specify optional pairs of arguments as
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.
VaRWindow — Size of the window used to compute VaR contributions
(default) | numeric between
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.
Contributions — Risk contributions
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
Contributions table allocates the full
portfolio risk measures to each counterparty, such that the counterparty
risk contributions sum to the portfolio risks reported by
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
ELis the expected loss for each counterparty and is the mean of the counterparty's losses across all scenarios.
Stdis the standard deviation for counterparty i:
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.
VaRcontribution 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
0.05meaning that all scenarios in which the total portfolio loss is within 5% of the portfolio VaR are included in VaR neighborhood.
CVaRis the mean of the counterparty's losses in the set of scenarios in which the total portfolio losses exceed the portfolio VaR.
 Glasserman, P. “Measuring Marginal Risk Contributions in Credit Portfolios.” Journal of Computational Finance. Vol. 9, No. 2, Winter 2005/2006.
 Gupton, G., Finger, C., and Bhatia, M. “CreditMetrics – Technical Document.” J. P. Morgan, New York, 1997.
Introduced in R2017a