In R language, the members at Revolution R provide foreach and doSNOW packages for parallel computation. these packages allow us to compute things in parallel. So, we start to install these packages.
In foreach package, you can write the codes which are run not only in parallel but also in sequence. And, these are as following.
Next, we make clusters by doSNOW package for the purpose of parallel computation.
Because I have dual core machine, I specify two as the number of clusters.
Now, We are ready to compute things in parallel. It is easy for us to do that by foreach package. You only have to change "%do%" into "%dopar%". I compared the performance of parallel comutation to single computation as following.
(I'm sorry that some terms are written in Japanese!)
You can understand the result of parallel computation is about twice as fast as single computation do !!!
They introduced copula for pricing of CDO,and discussed how different CDO spreads were with using different copula for pricing.
I would like to reproduce their result (especially,P23-Table7)
The condition of calculation is following that
number of debt(NUM.REFDEBT):=100
maturity(MATURITY):=5 year
recovery rate(RECOVERY.RATE):=40%(constant value)
probability of default (DEFAULT.PROBABILITY):=5%(in 5 years)
parameter of nomal copula ρ:=0.15
parameter of clayton copula α:=0.21
They apporoximated their valuation formula for easy calculation(equation (27))
(They assumed that CDO spread were paid as discounted bond at the begging.)
I simulated valuation of CDO with their method.
The result is following that
copula/tranche
Equity
mezzanine
senior
super senior
normal
1,145.42
62.49
0.52
0.000
t(20)
1,055.28
86.07
2.18
0.004
t(6)
896.74
126.44
8.56
0.044
t(3)
733.31
165.90
23.56
0.191
clayton
857.64
135.73
12.83
0.084
This table reproduce their result(P23-Table7).
And, In senior or super senior,you can understand that the CDO spread which is evaluated by normal copula is lower than the others. It means that normal copula is inadequate in financial crisis.
I show you my programming code(by R language).
If you copy and run my source code, you can duplicate my result easily. Before you run, please install "copula"package.
In quantitive finance,it is often said that yield curve change is explained by three factor, "parallel shift", "twist" and "butterfly". Because I found that we can get historical yield curve data from FRB's web site, I check whether these proverbial facts are correct or not.Yield curve data can be downloaded to click "Go to download" and "Download File" button. Default data format is csv. If you would like to get data another format, you should click "Build package" button to change format.
I assume that downloaded data is located at "C:\tmp"
Now,I have gotten yield curve change data.
Result image is shown like below
These result imply that Each three principal component correspond to "parallel shift", "twist" and "butterfly".
Cumulative Proportion are shown by "summary" function.
As a result, yield cuve change can be explained by three principal component.