diff options
Diffstat (limited to 'R')
| -rw-r--r-- | R/build_scenarios.R | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/R/build_scenarios.R b/R/build_scenarios.R index f5255836..a0187762 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -16,11 +16,11 @@ if(.Platform$OS.type == "unix"){ root.dir <- "//WDSENTINEL/share/CorpCDOs" } -code.dir <- if(Sys.getenv("CODE_DIR")=="") root.dir else Sys.getenv("CODE_DIR") -source(file.path(code.dir, "code", "R", "intex_deal_functions.R"), chdir=TRUE) -source(file.path(code.dir, "code", "R", "yieldcurve.R")) -source(file.path(code.dir, "code", "R", "serenitasdb.R"), chdir=TRUE) -source(file.path(code.dir, "code", "R", "tranche_functions.R")) +code.dir <- if(Sys.getenv("CODE_DIR")=="") file.path(root.dir, "code") else Sys.getenv("CODE_DIR") +source(file.path(code.dir, "R", "intex_deal_functions.R"), chdir=TRUE) +source(file.path(code.dir, "R", "yieldcurve.R")) +source(file.path(code.dir, "R", "serenitasdb.R"), chdir=TRUE) +source(file.path(code.dir, "R", "tranche_functions.R")) if(interactive()) { tradedate <- as.Date("2016-02-25") @@ -82,12 +82,12 @@ for(j in seq_along(dealnames)){ Dfun <- splinefun(c(0, cumsum(D)), c(0, support), "hyman") Rfun <- approxfun(support, R[,t], rule=2) for(i in 1:n.scenarios){ - ## this is roughtly E(D|D is in ith percentile) - ## using trapezoidal approximation + ## this is roughly E(D|D is in ith percentile) + ## using trapezoidal approximation if(i==1){ - scenariosd[i,t] <- 0.5* Dfun(0.01) + scenariosd[i,t] <- 0.5* Dfun(0.01) }else{ - scenariosd[i,t] <- 0.5 * (Dfun((i-1)*0.01)+Dfun(i*0.01)) + scenariosd[i,t] <- 0.5 * (Dfun((i-1)*0.01)+Dfun(i*0.01)) } if(t>=2 && scenariosd[i,t] < scenariosd[i,t-1]){ scenariosd[i,t] <- scenariosd[i,t-1] |
