This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Counterparty scenarios


scenarios = getScenarios(cmc,scenarioIndices)



scenarios = getScenarios(cmc,scenarioIndices) returns counterparty scenario details as a matrix of individual values for each counterparty for the scenarios requested in scenarioIndices.

Before you use the getScenarios function, you must run the simulate function. For more information on using a creditMigrationCopula object, see creditMigrationCopula.


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
      PortfolioValues: []

Set the VaRLevel to 99%.

 cmc.VaRLevel = 0.99;

Use the simulate function to simulate 100,000 scenarios, and then use the getScenarios function to generate the scenarios matrix.

cmc = simulate(cmc,1e5);
scenarios = getScenarios(cmc,[2,3]);
ans =

   1.0e+04 *

    1.3216    1.3216
    0.2924    0.2737
    0.9788    0.9681
    0.4697    0.1536
    1.0376    1.0376
    0.5795    0.5795
    0.5641    0.5138
    0.5039    0.4956
    0.3537    0.3537
    2.3492    2.3477

Input Arguments

collapse all

creditMigrationCopula object obtained after running the simulate function.

For more information on creditMigrationCopula objects, see creditMigrationCopula.

Specifies which scenarios are returned, entered as a vector.

Output Arguments

collapse all

Counterparty values, returned as NumCounterparties-by-N matrix, where N is the number of elements in scenarioIndices.


If the number of scenarios requested is very large, then the output matrix, scenarios, could be very large, and potentially limited by the available machine memory.


[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.

Introduced in R2017a

Was this topic helpful?