程序代写代做代考 finance Vadim Elenev Computational Finance 2020 Fall II

Vadim Elenev Computational Finance 2020 Fall II
Computational Finance – HW 2
Complete the following problems in your homework groups. All calculations must be done in MATLAB. When the question tells you to report or output an answer, your code must print it using the fprintf function. When the question tells you to plot something, you must copy and paste the plot into your Word file. When the question asks you to describe something or compare, you need to answer it in your own words. You may type your answer directly in the Word file that you will be submitting.
You may find it easiest to have a separate MATLAB script file (ending in .m) for each question. But as I said in class, copy and paste both your code and your output from all questions into one Word file. See the Sample Homework on OneDrive as a template. I recommend starting each script file with commands to close all figures, clear the workspace, and clear the command window: close all; clc; clear;
1. In this question, you will construct a Gaussian Copula to simulate payment times on two mortgages.
The first mortgage has a maturity of 30 years and a 1-year default probability of 10%. The second mortgage has a maturity of 15 years and a 1-year default probability of 16%. The correlation between them is 0.5.
Both mortgages make a payment at the end of every month until maturity or default, whichever comes first. Recall, the distribution until some event occurs is often modeled using the exponential distribution, so let’s assume that times until the last payment on the mortgage is exponentially distributed.
a. For each mortgage, determine the parameter of the exponential distribution of default times measured in months. No need to report any output.
Hint: use the exponential CDF, and the fact that the probability of not defaulting for a year is the probability of not defaulting in the first month AND not defaulting in the second month AND not defaulting in the third months and so on, until the twelfth month. The exponential distribution implies that these survival probabilities are independent. Once you found the monthly default probability, solve for the

Vadim Elenev
Computational Finance 2020 Fall II
b.
exponential distribution parameter.
Use the Gaussian Copula Method to simulate N1 samples from the joint exponential distribution of the two mortgages at a monthly frequency. We need to do this at monthly frequency because mortgage payments are monthly. Don’t forget that, if the mortgage doesn’t default, its final payment is made at maturity. In other words, you should censor your sample at maturity.
Plot the histograms of each mortgage’s final payment times in years in one figure. Set the width of the histogram bins to 1 quarter (4 quarters = 1 year).
Note: to make answering part (c) easier, you may want to adjust how your histogram is displayed. You can use the following version of MATLAB’s histogram command to (1) fix the width of a histogram bin, and (2) make the Y-axis show probabilities instead of number of samples.
histogram(X,’BinWidth’,binWidth, …
‘Normalization’,’probability’)
See the file plot_example.m for sample code for making plots that you can adapt to your needs. Remember, this is how most programmers learn!
Look at the figure from (b) to approximately answer the following questions. No need to write any code for this part. Which mortgage is more likely to survive until maturity? Which mortgage is more likely to default in any given quarter at first? Does this change at some point? Approximately when?
For each mortgage, compute the average time of the final payment in years. Report the mean and 90% confidence interval. If either of the confidence intervals is wider than 1 month, adjust your simulation in part (b) to make them tighter.
For each mortgage, estimate the conditional expectation of final payment times, conditional on whether the other mortgage defaults. You should compute and report 4 numbers:
i. Mortgage 1’s expected final payment time if mortgage 2 defaults ii. Mortgage 1’s expected final payment time if mortgage 2 survives iii. Mortgage 2’s expected final payment time if mortgage 1 defaults iv. Mortgage 2’s expected final payment time if mortgage 1 survives
Why are your answers to part (e) consistent with the correlation we assumed?
c.
d. e.
f.
1 You can choose the value of N, but make sure your estimates are precise enough.