How to remove credit Risk.
install.packages("CreditRisk")Installing package into ‘C:/Users/ADMIN/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/CreditRisk_0.1.3.zip'
Content type 'application/zip' length 74922 bytes (73 KB)
downloaded 73 KB
package ‘CreditRisk’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\ADMIN\AppData\Local\Temp\RtmpKIUeQv\downloaded_packages
> library(CreditRisk)
Warning message:
package ‘CreditRisk’ was built under R version 3.5.2
> library(CreditRisk)
> mod <- at1p(V0 = 1, H0 = 0.7, B = 0.4, sigma = rep(0.1, 10), r = cdsdata$ED.Zero.Curve,
+ t = cdsdata$Maturity)
> mod
Maturity Vt Ht Survival
1 0.5 0.9986010 0.6976240 0.9999995
2 1.0 0.9976029 0.6955343 0.9996255
3 2.0 0.9966058 0.6920653 0.9879108
4 3.0 0.9976029 0.6899922 0.9591025
5 4.0 1.0008003 0.6894405 0.9227796
6 5.0 1.0070246 0.6909589 0.8853100
7 7.0 1.0276761 0.6995102 0.8159656
8 10.0 1.0789626 0.7256591 0.7312982
9 20.0 1.3152148 0.8498674 0.5596304
10 30.0 1.5496049 0.9620634 0.4666967
Default.Intensity
1 9.441670e-07
2 7.482850e-04
3 1.178826e-02
4 2.959447e-02
5 3.860755e-02
6 4.145252e-02
7 4.078282e-02
8 3.651696e-02
9 2.675447e-02
10 1.815970e-02
> plot(cdsdata$Maturity, mod$Ht, type = 'b', xlab = 'Maturity', ylab = 'Safety Level H(t)',
+ main = 'Safety level for different maturities', ylim = c(min(mod$Ht), 1.5),
+ col = 'red')
> lines(cdsdata$Maturity, mod$Vt, xlab = 'Maturity', ylab = 'V(t)',
+ main = 'Value of the Firm \n at time t', type = 's')
> plot(cdsdata$Maturity, mod$Survival, type = 'b',
+ main = 'Survival Probability for different Maturity \n (AT1P model)',
+ xlab = 'Maturity', ylab = 'Survival Probability')
> matplot(cdsdata$Maturity, mod$Default.Intensity, type = 'l', xlab = 'Maturity',
+ ylab = 'Default Intensity')
> install.packages("devtools")
0 Comments