首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解data编程、辅导program程序设计、Matlab编程语言调试 解析R语言编程|讲解留学生Prolog
项目预算:
开发周期:
发布时间:
要求地区:
Computational Finance – HW 2
Complete the following problems in your home work 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;
Some helpful hints for the following questions (I’ll leave it to you to figure out where these hints apply ):
MATLAB has a function that calculates the cumulative sum of a vector. You can look it up using MATLAB’s help.
When you call the fprintf() function, if you leave the ‘\n’ off of the format string, the next time you call fprintf() will print again on the same line. This allows you to call fprintf() different ways for multiple items that you print on the same line.
1.Read the excerpt below from Options, Futures, and other Derivatives by John Hull. You will be writing a MATLAB program to simulate credit rating changes of a correlated Baa company and a Ba company following the steps outlined in the question parts below. You will use numbers to represent ratings: 0: default, 1: Aaa, 2: Aa, 3: A, etc. The one-year rating transition matrix is given in Table 22.6 on the next page.
a.[Hint for part a: you should use the RunBedford.m code from the Quiz1 Practice Problems I gave you in Week 3 as the basis for how you write the portion for the discrete inverse transform in this function]
First, write a function, called get_end_of_year_ratings (in its own function file), that generates N correlated rating transitions. Your function should produce the following two separate outputs (i.e., there should be two output variables, each of which is a vector, as specified here):
rating1: an N-element column vector of the end-of-year ratings for company 1.
rating2: an N-element column vector of the end-of-year ratings for company 2.
The function must take the following 5 arguments as inputs, in this order:
p1: a row vector of the cumulative probability boundaries for all the rating categories.
p2: a row vector of the cumulative probability boundaries for all the rating categories.
rho: a 2x2 correlation matrix with the Gaussian copula correlation coefficient between the two companies included.
categories: a row vector of the numeric values to use for each category represented by the cumulative probability vectors p1 and p2 (NOTE: you should represent the default category as a zero, and it does not need to be included in this “categories” vector or in the p1/p2 vectors; simply make it whatever is left over)
N: the number of end-of-year ratings to generate.
Paste the code from your function file here (no outputs for this one):
b.Write a script file that performs the following steps:
Generate 10 million end-of-year ratings for each of two companies, where Company 1 is a Ba-rated company at the start of the year, and Company 2 is Baa to start the year, using a correlation coefficient ρ=0.9. (Hint: start out with a much smaller number, like 100,000 simulations, so that your code runs quickly as you’re making sure it’s working, then run 10 million once you’re satisfied it works properly, as this will take quite a bit longer to run) As stated above, use numbers to represent ratings: 0: default, 1: Aaa, 2: Aa, 3: A, etc., and use the one-year rating transition matrix from Table 22.6 above.
For each company, generate a vector containing the proportion of simulated results of each rating index (the numeric values representing the ratings) 0 through 8. This should result in two nine-element vectors (one for each company), each of which contains the proportion of 0s, the proportion of 1s, proportion of 2s, etc., all the way through proportion of 8s for that company. These proportions are the simulated probabilities of each rating index occurring for each company. Note: Do this in a ‘for’ loop. If you simply copy-and-paste the same code nine times for each of these proportions, you will lose significant points.
Produce a line plot (just using the standard plot() function) of each of these vectors of proportions (times 100 to make them percentages) with the title “part (b): Rating Probabilities” as well as a legend indicating the lines as “Baa Probabilities” and “Ba Probabilities”.
c.Using the two proportion/probability vectors that you just plotted in part (b) times 100, produce a nice-looking, lined-up table that looks like the one I have pictured below using a short series of fprintf() function calls. As a helpful hint, for each column that displays a numeric value, I used a %8.2f placeholder, which turned out to be a nice width. Note: when you print out the numeric values in the table, you should do so using only one fprintf statement to print all of them for the row at once, and do it without indexing the vector (i.e., the entire vector should be the second argument in the fprintf() function call, not one element at a time as multiple arguments). Thus, you print all numeric values in the table for the Baa company at once. Then, when you’re printing the numeric values for the Ba company, you print all of those at once. This part is tricky, and you may have to do some research for how to reuse the same format for multiple values in a vector/matrix with one function call to fprintf().
Once you have produced this table, compare it to Table 22.6’s probability densities. Is it largely the same or different? And what does this tell you about how correlating random variables affects the individual variables’ univariate distributions? (NOTE: I have intentionally produced numbers very different from what you’ll get so I don’t give anything away)
d.For this part, you don’t need to write any code. I have produced a table for you using 10 million simulations like you will for part c (I will provide you the solution code to generate this table). The rightmost three columns represent the following:
Independent (%): The theoretical probability that both companies will end with the same rating specified in the leftmost column if they were independent/uncorrelated. (e.g. that both will default in the first row, that both will have a Aaa rating in the second row, etc.). I calculated this by multiplying the probability densities of each company in Table 22.6 for that end-of-year rating.
Correlated (%): The probability that both companies will end with the same rating specified in the leftmost column based on our simulation, in which the companies are correlated.
Diff (%): This is simply the Correlated (%) column minus the Independent (%) problem.
Given the values in this table, coupled with your conclusion from part (c) regarding correlation’s effects on the univariate probabilities, briefly explain what it looks like the correlation’s effect is overall.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!