www.gusucode.com > risk 案例源码程序 matlab代码 > risk/CreateacreditcopulaObjectandSimulateCreditPortfolioLosseExample.m

    %% Create a |creditCopula| Object and Simulate Credit Portfolio Losses

%% 
% Load saved portfolio data. 
load CreditPortfolioData.mat;  

%% 
% Create a |creditCopula| object with a two-factor model. 
cc = creditCopula(EAD,PD,LGD,Weights2F,'FactorCorrelation',FactorCorr2F)  

%% 
% Set the |VaRLevel| to 99%. 
cc.VaRLevel = 0.99;  

%% 
% Simulate 100,000 scenarios and view the portfolio risk measures. 
 cc = simulate(cc,1e5)
 portRisk = portfolioRisk(cc)  

%% 
% View a histogram of the portfolio losses. 
histogram(cc.PortfolioLosses);
title('Distribution of Portfolio Losses');    

%%
% For further analysis, use the |<docid:risk_ug.bvaj1_z-1 simulate>|, |<docid:risk_ug.bvaj2l_-1
% portfolioRisk>|, and |<docid:risk_ug.bvaj2yb-1 riskContribution>| functions
% with the |creditCopula| object.