summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2014-08-20 16:47:44 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2014-08-20 16:47:44 -0400
commitc451841cdac4bef74ef9a011f13d8befe85e9d56 (patch)
treee6d1219eea408141acb76308e11500ed351dfdac
parent2aa4adce263003c6dfed75cc2c1ea6214b3006e4 (diff)
downloadlossdistrib-c451841cdac4bef74ef9a011f13d8befe85e9d56.tar.gz
replace tranche.pvvec with MFtranche.pv, which mimics BCtranche.pv
-rw-r--r--R/tranche_functions.R27
1 files changed, 19 insertions, 8 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index 9b971f2..6bff635 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -610,14 +610,6 @@ adjust.attachments <- function(K, losstodate, factor){
return( pmin(pmax((K-losstodate)/factor, 0),1) )
}
-tranche.pvvec <- function(K, L, R, cs){
- r <- rep(0, length(K)-1)
- for(i in 1:(length(K)-1)){
- r[i] <- 1/(K[i+1]-K[i]) * tranche.pv(L, R, cs, K[i], K[i+1])
- }
- return( r )
-}
-
BClossdist <- function(defaultprob, issuerweights, recov, rho, Z, w,
N=length(recov)+1, defaultflag=FALSE, n.int=500){
if(missing(Z)){
@@ -702,6 +694,25 @@ BCtranche.pv <- function(index, protection=FALSE, complement=FALSE){
return(list(pl=plvec, cl=clvec, bp=bp))
}
+MFtranche.pv <- function(index, dist, protection=FALSE){
+ n.tranches <- length(index$K)-1
+ pl <- rep(0, n.tranches)
+ cl <- rep(0, n.tranches)
+ for(i in seq.int(n.tranches)){
+ pl[i] <- tranche.pl(dist$L, index$cs, index$K[i], index$K[i+1])
+ cl[i] <- tranche.cl(dist$L, dist$R, index$cs, index$K[i], index$K[i+1])
+ }
+ dK <- diff(index$K)
+ plvec <- pl/dK
+ clvec <- cl/dK*index$tranche.running
+ if(protection){
+ bp <- -plvec-clvec
+ }else{
+ bp <- 1+plvec+clvec
+ }
+ return(list(pl=plvec, cl=clvec, bp=bp))
+}
+
adjust.skew <- function(index1, index2, method="ATM"){
#index1 is the index for which we already have computed the skew
#index2 is the index we're mapping to