aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/tranche_functions.R11
1 files changed, 7 insertions, 4 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index ef13d4ff..58a08189 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -396,17 +396,19 @@ dist.transform <- function(dist.joint){
## from the (L, R) distribution using D = L+R
distDR <- array(0, dim=dim(dist.joint))
Ngrid <- dim(dist.joint)[2]
- u <- seq(0, 1, length=Ngrid)
- v <- seq(0, 1, length=Ngrid)
- for(t in 1:ncol(dp)){
+ for(t in 1:dim(dist.joint)[1]){
for(i in 1:Ngrid){
for(j in 1:Ngrid){
index <- i+j
if(index <= Ngrid){
distDR[t,index,j] <- distDR[t,index,j] + dist.joint[t,i,j]
+ }else{
+ distDR[t,Ngrid,j] <- distDR[t,Ngrid,j] +
+ dist.joint[t,i,j] * index * 0.005
}
}
}
+ distDR[t,,] <- distDR[t,,]/sum(distDR[t,,])
}
return( distDR )
}
@@ -783,7 +785,8 @@ MFlossrecovdist.prepay <- function(w, Z, rho, defaultprob, defaultprobmod, prepa
MFlossdist.joint <- function(cl, w, Z, rho, defaultprob, defaultprobmod, issuerweights, recov,
Ngrid=2*length(issuerweights)+1, defaultflag=FALSE){
- ## rowSums(Q) is the loss/default distribution
+ ## rowSums(Q) is the default/loss distribution depending if
+ ## defaultflag is TRUE or FALSE (default setting is FALSE)
## colSums(Q) is the recovery distribution
## so that recovery is the y axis and L/D is the x axis
## if we use the persp function, losses is the axes facing us,