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

    %% Run a Simulation Using a |creditCopula| Object

%% 
% 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;  

%% 
% Use the |simulate| function with the |creditCopula| object. After using |simulate|,
% you can then use the |<docid:risk_ug.bvaj2l_-1 portfolioRisk>|, |<docid:risk_ug.bvaj2yb-1
% riskContribution>|, and |<docid:risk_ug.bvc9zpv-1 confidenceBands>| functions
% with the updated |creditCopula| object. 
cc = simulate(cc,1e5,'Copula','t','DegreesOfFreedom',10)   
%% 
% For instance, you can use |riskContribution| with the |creditCopula| object to generate the
% |riskContributions|. 
riskContributions = riskContribution(cc);
riskContributions(1:10,:)