diff options
Diffstat (limited to 'tranche_functions.R')
| -rw-r--r-- | tranche_functions.R | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tranche_functions.R b/tranche_functions.R index 42597c68..159158fb 100644 --- a/tranche_functions.R +++ b/tranche_functions.R @@ -193,13 +193,13 @@ lossrecovdist <- function(defaultprob, prepayprob, w, S, lu, useC=TRUE){ return(list(L=L, R=R))
}
-lossrecovdist.term <- function(defaultprob, prepayprob, S, lu, useC=TRUE){
+lossrecovdist.term <- function(defaultprob, prepayprob, w, S, lu, useC=TRUE){
## computes the loss and recovery distribution over time
L <- array(0, dim=c(1/lu+1, ncol(defaultprob)))
R <- array(0, dim=c(1/lu+1, ncol(defaultprob)))
if(prepayprob==0){
for(t in 1:ncol(defaultprob)){
- temp <- lossrecovdist(defaultprob[,t], 0, S[,t], lu, useC)
+ temp <- lossrecovdist(defaultprob[,t], 0, w, S[,t], lu, useC)
L[,t] <- temp$L
R[,t] <- temp$R
}
@@ -307,7 +307,7 @@ tranche.bpvec <- function(K, L, R, cs){ return( r )
}
-BClossdist <- function(SurvProb, recov, rho, lu, n.int=100){
+BClossdist <- function(SurvProb, issuerweights, recov, rho, lu, n.int=100){
quadrature <- gauss.quad.prob(n.int, "normal")
Z <- quadrature$nodes
w <- quadrature$weights
@@ -321,7 +321,7 @@ BClossdist <- function(SurvProb, recov, rho, lu, n.int=100){ for(i in 1:length(Z)){
g.shocked <- shockprob(g, rho, Z[i])
S.shocked <- shockseverity(1-recov, 1, Z[i], rho, g)
- temp <- lossrecovdist(g.shocked, 0, S.shocked, lu)
+ temp <- lossrecovdist(g.shocked, 0, issuerweights, S.shocked, lu)
LZ[,i] <- temp$L
RZ[,i] <- temp$R
}
@@ -331,7 +331,7 @@ BClossdist <- function(SurvProb, recov, rho, lu, n.int=100){ list(L=L, R=R)
}
-BClossdistC <- function(SurvProb, recov, rho, lu, n.int=100){
+BClossdistC <- function(SurvProb, issuerweights, recov, rho, lu, n.int=100){
dyn.load("lossdistrib.dll")
quadrature <- gauss.quad.prob(n.int, "normal")
Z <- quadrature$nodes
@@ -339,6 +339,6 @@ BClossdistC <- function(SurvProb, recov, rho, lu, n.int=100){ N <- as.integer(1/lu+1)
L <- matrix(0, N, dim(SurvProb)[2])
R <- matrix(0, N, dim(SurvProb)[2])
- r <- .C("BClossdist", SurvProb, as.integer(dim(SurvProb)[1]), as.integer(dim(SurvProb)[2]), as.double(recov), as.double(Z), as.double(w), as.integer(n.int), as.double(rho), as.double(lu), L=L, R=R)
+ r <- .C("BClossdist", SurvProb, as.integer(dim(SurvProb)[1]), as.integer(dim(SurvProb)[2]), as.double(issuerweights), as.double(recov), as.double(Z), as.double(w), as.integer(n.int), as.double(rho), as.double(lu), L=L, R=R)
return(list(L=r$L,R=r$R))
}
|
