Main Content


Generate portfolio-level risk measurements



[riskMeasures,confidenceIntervals] = portfolioRisk(cmc) returns tables of risk measurements for the portfolio losses. Before you use the portfolioRisk function, run the simulate function. For more information on using a creditMigrationCopula object, see creditMigrationCopula.


[riskMeasures,confidenceIntervals] = portfolioRisk(cmc,Name,Value) adds an optional name-value pair argument for ConfidenceIntervalLevel.


collapse all

Load the saved portfolio data.

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,...
cmc = 
  creditMigrationCopula with properties:

            Portfolio: [250x5 table]
    FactorCorrelation: [4x4 double]
         RatingLabels: [8x1 string]
     TransitionMatrix: [8x8 double]
             VaRLevel: 0.9500
          UseParallel: 0
      PortfolioValues: []

Set the VaRLevel to 99%.

 cmc.VaRLevel = 0.99;

Use the simulate function to simulate 100,000 scenarios, and then use the portfolioRisk function to generate the riskMeasure and ConfidenceIntervals tables.

 cmc = simulate(cmc,1e5);
[riskMeasure,confidenceIntervals] = portfolioRisk(cmc,'ConfidenceIntervalLevel',0.9)
riskMeasure=1×4 table
      EL       Std      VaR     CVaR 
    ______    _____    _____    _____

    4515.9    12963    57176    83975

confidenceIntervals=1×4 table
           EL                Std               VaR               CVaR     
    ________________    ______________    ______________    ______________

    4448.5    4583.4    12916    13011    56012    58278    82433    85517

Input Arguments

collapse all

creditMigrationCopula object obtained after running the simulate function.

For more information on creditMigrationCopula objects, see creditMigrationCopula.

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: [riskMeasure,confidenceIntervals] = portfolioRisk(cmc,'ConfidenceIntervalLevel',0.9)

Confidence interval level, specified as the comma-separated pair consisting of 'ConfidenceIntervalLevel' and a numeric between 0 and 1. For example, if you specify 0.95, a 95% confidence interval is reported in the output table (riskMeasures).

Data Types: double

Output Arguments

collapse all

Risk measures, returned as a table containing the following columns:

  • EL — Expected loss, the mean of portfolio losses

  • Std — Standard deviation of the losses

  • VaR — Value at risk at the threshold specified by the VaRLevel property of the creditMigrationCopula object

  • CVaR — Conditional VaR at the threshold specified by the VaRLevel property of the creditMigrationCopula object

Confidence intervals, returned as a table of confidence intervals corresponding to the portfolio risk measures reported in the riskMeasures table. Confidence intervals are reported at the level specified by the ConfidenceIntervalLevel parameter.


[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] Gordy, M. “A Comparative Anatomy of Credit Risk Models.” Journal of Banking and Finance. Vol. 24, 2000, pp. 119 – 149.

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

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

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

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

Version History

Introduced in R2017a