MIE1622H - Assignment 3
MIE1622H - Assignment 3
MIE1622H - Assignment 3
Due: Friday, March 23, 2018, not later than 6:00 p.m.
Where to hand in: Online via Blackboard portal, both your code and report.
Introduction
The purpose of this assignment is to model a credit-risky portfolio of corporate bonds. Consider a
structural model for portfolio credit risk described in class. Using the data for 100 counterparties,
simulate 1-year losses for each corporate bond. You will need to generate 3 sets of scenarios:
• Monte Carlo approximation 1 : 5000 in-sample scenarios (N = 1000 · 5 = 5000 (1000 systemic
scenarios and 5 idiosyncratic scenarios for each systemic), non-Normal distribution of losses);
• Monte Carlo approximation 2 : 5000 in-sample scenarios (N = 5000 (5000 systemic scenarios
and 1 idiosyncratic scenario for each systemic), non-Normal distribution of losses);
The out-of-sample scenarios represent true distribution of portfolio losses. Two in-sample non-
Normal datasets are used for evaluating sampling error and performing portfolio optimization
(portfolio credit-risk optimization is the subject of Assignment 4).
To evaluate model error (if we wrongly assumed that counterparty losses follow Normal distri-
bution), compute mean loss and standard deviation of losses for each corporate bond from the
3 scenario sets (N =1000x5, 5000, 100000). This 3 in-sample sets are referred as in-sample Normal
model.
Evaluate VaR and CVaR at quantile levels 99% and 99.9% for the two portfolios:
To better evaluate sampling and model errors, perform the experiment 100 times in the following
way: generate in-sample datasets with N =1000x5 and 5000 (non-Normal and Normal) one hundred
times and compute VaR and CVaR. Keep the out-of-sample scenario set unchanged. Perform
analysis of the results for the 100 trials, e.g., compute averages of the results for 100 trials, analyze
standard deviation over 100 trials, etc.
Questions
There is a file credit risk simul.m on the course web-page. You are required to complete
the code in the file.
Portfolio 2:
• Plot loss distributions in MATLAB that illustrate both out-of-sample and in-sample
results. Include plots that help illustrating your analysis in the report.
• Analyze sampling error when comparing non-Normal approximations to the true (out-of-
sample) loss distribution. Analyze model error when comparing Normal approximations
to the true (out-of-sample) loss distribution.
3. (10 %) Discuss possible strategies for minimizing impacts of sampling and model
errors:
• If you report the in-sample VaR and CVaR to decision-makers in your bank, what
consequences for the bank capital requirements it may have?
• Can you suggest techniques for minimizing impacts of sampling and model errors?
2
MATLAB Script to be Completed
clear all;
clc
format long;
if(~exist(’scenarios_out.mat’,’file’))
for s = 1:Nout
% -------- Insert your code here -------- %
end
save(’scenarios_out’, ’Losses_out’)
else
load(’scenarios_out’, ’Losses_out’)
3
end
% Compute VaR and CVaR (non-Normal and Normal) for 100000 scenarios
for(portN = 1:2)
for(q=1:length(alphas))
alf = alphas(q);
% -------- Insert your code here -------- %
% VaRinN(portN,q) = ...
% VaRinN(portN,q) = ...
% CVaRout(portN,q) = ...
% CVaRinN(portN,q) = ...
% -------- Insert your code here -------- %
end
end
for(tr=1:N_trials)
4
var_MCl = cov(Losses_inMC1);
mu_MC2 = mean(Losses_inMC2)’;
var_MC2 = cov(Losses_inMC2);
% Compute portfolio mean loss mu_p_MC1 and portfolio standard deviation of losses sigma_p_MC1
% Compute portfolio mean loss mu_p_MC2 and portfolio standard deviation of losses sigma_p_MC2
% Compute VaR and CVaR for the current trial
% VaRinMC1{portN,q}(tr) = ...
% VaRinMC2{portN,q}(tr) = ...
% VaRinN1{portN,q}(tr) = ...
% VaRinN2{portN,q}(tr) = ...
% CVaRinMC1{portN,q}(tr) = ...
% CVaRinMC2{portN,q}(tr) = ...
% CVaRinN1{portN,q}(tr) = ...
% CVaRinN2{portN,q}(tr) = ...
% -------- Insert your code here -------- %
end
end
end
% Plot results
% figure(1);
% -------- Insert your code here -------- %
% figure(2);
% -------- Insert your code here -------- %