aboutsummaryrefslogtreecommitdiffstats
path: root/R/tranche_functions.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/tranche_functions.R')
-rw-r--r--R/tranche_functions.R25
1 files changed, 10 insertions, 15 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index 125b5a40..3a7a643c 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -236,23 +236,18 @@ adjust.skew <- function(index1, index2, method="ATM"){
return(c(NA, cap(skew(K1eq)), NA))
}
-theta.adjust.skew <- function(index, shortened=4, method="ATM"){
- #ajust the correlation skew by doing ATM mapping on the expected loss
+BCtranche.theta <- function(index, shortened=4, complement=FALSE, method="ATM") {
+ N <- nrow(index$cs) - shortened
+ if(N < 0) {
+ stop("Maturity too short for computing tranche thetas")
+ }
indexshort <- index
- N <- nrow(index$cs)-shortened
- indexshort$defaultprob <- indexshort$defaultprob[,1:N]
- indexshort$cs <- indexshort$cs[1:N,]
- return(adjust.skew(index, indexshort, method))
-}
-
-BCtranche.theta <- function(index, shortened=4, complement=FALSE, method="ATM"){
+ indexshort$defaultprob <- index$defaultprob[,1:N]
+ indexshort$cs <- index$cs[1:N,]
+ indexshort$rho <- adjust.skew(index, indexshort, method)
temp <- BCtranche.pv(index, complement=complement)
- index$rho <- theta.adjust.skew(index, shortened, method)
- N <- nrow(index$cs) - shortened
- index$cs <- index$cs[1:N,]
- index$defaultprob <- index$defaultprob[,1:N]
- temp2 <- BCtranche.pv(index, complement=complement)
- temp3 <- BCtranche.delta(index, complement=complement)
+ temp2 <- BCtranche.pv(indexshort, complement=complement)
+ temp3 <- BCtranche.delta(indexshort, complement=complement)
return(data.frame(theta=temp2$bp-temp$bp+index$tranches$running,
fw.delta=temp3$delta))
}