diff options
Diffstat (limited to 'cds_functions_generic.R')
| -rw-r--r-- | cds_functions_generic.R | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cds_functions_generic.R b/cds_functions_generic.R index ffa0e3c3..4f73e2d9 100644 --- a/cds_functions_generic.R +++ b/cds_functions_generic.R @@ -565,10 +565,18 @@ SP <- function(sc){ SPmatrix <- function(portfolio, index){
+ ## computes matrix of survival probability
+ ## inputs:
+ ## portfolio: portfolio of survival curves
+ ## index: index representation
+ ## ouput:
+ ## matrix of survival probabilities of dimensions dim1 x dim2
+ ## with dim1 number of issuers and dim2 number of dates in the
+ ## coupon schedule of index
cs <- couponSchedule(nextIMMDate(today()), index$maturity, "Q", "FIXED", index$coupon)
SP <- matrix(0, length(portfolio), length(cs$dates))
for(i in 1:length(portfolio)){
- SP[i,] <- PD(portfolio[[i]]@curve)[1:length(cs$dates)]
+ SP[i,] <- SP(portfolio[[i]]@curve)[1:length(cs$dates)]
}
return( SP )
}
@@ -586,7 +594,7 @@ DP2 <- function(sc){ }
SPmatrix2 <- function(portfolio, dealdata){
- ## computes the default probability and prepay matrix of a portfolio
+ ## computes the default and prepay probability matrix of a portfolio
## at the dates specified from dealdata
dates <- seq(dealdata$"Deal Next Pay Date", dealdata$maturity, by="3 months")
T <- yearFrac(today(), dates)
|
