diff options
Diffstat (limited to 'tranche_functions.R')
| -rw-r--r-- | tranche_functions.R | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tranche_functions.R b/tranche_functions.R index 63f5d20b..51a0cd87 100644 --- a/tranche_functions.R +++ b/tranche_functions.R @@ -339,6 +339,27 @@ lossrecovdist.joint.term <- function(defaultprob, prepayprob, w, S, N, defaultfl return(Q)
}
+
+dist.transform <- function(dist.joint){
+ ## compute the joint (D, R) distribution
+ ## 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(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]
+ }
+ }
+ }
+ }
+ return( distDR )
+}
+
shockprob <- function(p, rho, Z, log.p=F){
## computes the shocked default probability as a function of the copula factor
pnorm((qnorm(p)-sqrt(rho)*Z)/sqrt(1-rho), log.p=log.p)
|
