diff options
| -rw-r--r-- | R/calibration.R | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/R/calibration.R b/R/calibration.R index 68d10573..6f672e85 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -149,16 +149,17 @@ set.tranchedata <- function(index, tradedate){ return( index ) } -build.skew <- function(index, type="bottomup"){ +build.skew <- function(index, type = c("bottomup", "towdown")) { require(lossdistrib) aux <- function(rho, index, K, quote, spread, complement){ temp <- BCtranche.legs(index, K, rho, complement) return(abs(temp$pl+temp$cl*spread + quote)) } + type = match.arg(type) rhovec <- rep(NA, length(index$K)) dK <- diff(index$K) - if(type=="bottomup"){ - for(j in 1:(length(dK)-1)){ + if(type == "bottomup") { + for(j in 1:(length(dK)-1)) { ##use the current tranche coupon ## we compute the 0-index$K[j+1] equivalent quote using the coupon of the jth quote tranchepv <- BCtranche.legs(index, index$K[j], rhovec[j]) |
