Main Content

simulate

Simulate credit defaults using a creditDefaultCopula object

Description

example

cdc = simulate(cdc,NumScenarios) performs the full simulation of credit scenarios and computes defaults and losses for the portfolio defined in the creditDefaultCopula object. For more information on using a creditDefaultCopula object, see creditDefaultCopula.

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

example

cdc = simulate(___,Name,Value) adds optional name-value pair arguments for (Copula, DegreesOfFreedom, and BlockSize).

Examples

collapse all

Load saved portfolio data.

load CreditPortfolioData.mat;

Create a creditDefaultCopula object with a two-factor model.

cdc = creditDefaultCopula(EAD,PD,LGD,Weights2F,'FactorCorrelation',FactorCorr2F)
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 with the creditDefaultCopula object. After using simulate, you can then use the portfolioRisk, riskContribution, confidenceBands, and getScenarios functions with the updated creditDefaultCopula object.

cdc = simulate(cdc,1e5)
cdc = 
  creditDefaultCopula with properties:

            Portfolio: [100x5 table]
    FactorCorrelation: [2x2 double]
             VaRLevel: 0.9900
          UseParallel: 0
      PortfolioLosses: [30.1008 3.6910 3.2895 19.2151 7.5761 44.5088 19.5419 1.7909 72.1443 12.6933 36.0228 1.7909 4.8512 23.0230 54.0877 35.9298 35.3757 26.1678 36.8868 24.6242 2.9770 15.3030 0 0 10.5546 61.2268 32.5802 42.5504 ... ] (1x100000 double)

You can use riskContribution with the creditDefaultCopula object to generate the risk Contributions table.

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

     1      0.036031      0.022762     0.083828       0.13625
     2      0.068357      0.039295      0.23373       0.24984
     3        1.2228       0.60699       2.3184        2.3775
     4      0.002877    0.00079014    0.0024248     0.0013137
     5       0.12127      0.037144      0.18474       0.24622
     6       0.12638      0.078506      0.39779       0.48334
     7       0.84284        0.3541       1.6221        1.8183
     8    0.00090088    0.00011379    0.0016463    0.00089197
     9       0.93117       0.87638       3.3868        3.9936
    10       0.26054       0.37918       1.7399        2.3042

Input Arguments

collapse all

creditDefaultCopula object, obtained from creditDefaultCopula.

For more information on a creditDefaultCopula object, see creditDefaultCopula.

Number of scenarios to simulate, specified as a nonnegative integer. Scenarios are processed in blocks to conserve machine resources.

Data Types: double

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: cdc = simulate(cdc,NumScenarios,'Copula','t','DegreesOfFreedom',5)

Type of copula, specified as the comma-separated pair consisting of 'Copula' and a character vector or string. Possible values are:

  • 'Gaussian' — A Gaussian copula

  • 't' — A t copula with degrees of freedom specified using DegreesOfFreedom.

Data Types: char | string

Degrees of freedom for a t copula, specified as the comma-separated pair consisting of 'DegreesOfFreedom' and a nonnegative numeric value. If Copula is set to 'Gaussian', the DegreesOfFreedom parameter is ignored.

Data Types: double

Number of scenarios to process in each iteration, specified as the comma-separated pair consisting of 'BlockSize' and a nonnegative numeric value.

If unspecified, BlockSize defaults to a value of approximately 1,000,000 / (Number-of-counterparties). For example, if there are 100 counterparties, the default BlockSize is 10,000 scenarios.

Data Types: double

Output Arguments

collapse all

Updated creditDefaultCopula object. The object is populated with the simulated PortfolioLosses.

For more information on a creditDefaultCopula object, see creditDefaultCopula.

Note

In the simulate function, the Weights (specified when using creditDefaultCopula) are transformed to ensure that the latent variables have a mean of 0 and a variance of 1.

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