diff options
Diffstat (limited to 'R/tranche_functions.R')
| -rw-r--r-- | R/tranche_functions.R | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R index 4650c19b..ef13d4ff 100644 --- a/R/tranche_functions.R +++ b/R/tranche_functions.R @@ -241,6 +241,16 @@ lossdistC <- function(p, w, S, N, defaultflag=FALSE){ as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), q = double(N))$q
}
+lossdistCZ <- function(p, w, S, N, defaultflag=FALSE, rho, Z, wZ){
+ if(!is.loaded("lossdistrib_Z")){
+ dyn.load(file.path(root.dir, "code", "R", paste0("lossdistrib", .Platform$dynlib.ext)))
+ }
+ .C("lossdistrib_Z", as.double(p), as.integer(length(p)),
+ as.double(w), as.double(S), as.integer(N), as.logical(defaultflag),
+ as.double(rho), as.double(Z), as.double(wZ), as.integer(length(Z)),
+ q = matrix(0, N, length(Z)))$q
+}
+
lossdistC.truncated <- function(p, w, S, N, T=N){
## C version of lossdistrib2, roughly 50 times faster
if(!is.loaded("lossdistrib_truncated")){
@@ -269,6 +279,22 @@ lossdistC.joint <- function(p, w, S, N, defaultflag=FALSE){ as.double(S), as.integer(N), as.logical(defaultflag), q = matrix(0, N, N))$q
}
+lossdistC.jointZ <- function(dp, w, S, N, defaultflag = FALSE, rho, Z, wZ){
+ ## N is the size of the grid
+ ## dp is of size n.credits
+ ## w is of size n.credits
+ ## S is of size n.credits by nZ
+ ## rho is a double
+ ## Z is a vector of length nZ
+ ## w is a vector if length wZ
+ if(!is.loaded("lossdistrib_joint_Z")){
+ dyn.load(file.path(root.dir, "code", "R", paste0("lossdistrib", .Platform$dynlib.ext)))
+ }
+ r <- .C("lossdistrib_joint_Z", as.double(dp), as.integer(length(dp)),
+ as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), as.double(rho),
+ as.double(Z), as.double(wZ), as.integer(length(Z)), q = matrix(0, N, N))$q
+}
+
lossdistC.prepay.joint <- function(dp, pp, w, S, N, defaultflag=FALSE){
## C version of lossdist.prepay.joint
if(!is.loaded("lossdistrib_prepay_joint")){
|
