summaryrefslogtreecommitdiffstats
path: root/R
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-03-07 15:39:42 -0500
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-03-07 15:39:42 -0500
commit8e57746d75a9e65436db6e8b589fc553c4a4989b (patch)
treebf591bfd80ddd4e4fb3099f4e97660a9e195459d /R
parent0997866e260e31244729466eae548a860f9a96ae (diff)
downloadlossdistrib-8e57746d75a9e65436db6e8b589fc553c4a4989b.tar.gz
be more defensive with the dimensions
Diffstat (limited to 'R')
-rw-r--r--R/distrib.R11
1 files changed, 8 insertions, 3 deletions
diff --git a/R/distrib.R b/R/distrib.R
index c6dc609..eeb1796 100644
--- a/R/distrib.R
+++ b/R/distrib.R
@@ -281,7 +281,11 @@ lossdistC <- function(p, w, S, N, defaultflag=FALSE){
}
lossdistCZ <- function(p, w, S, N, defaultflag=FALSE, rho, Z){
- #S is of size (length(p), length(Z))
+ ##S is of size (length(p), length(Z))
+ stopifnot(length(rho)==length(p),
+ length(rho)==length(w),
+ nrow(S)==length(p),
+ ncol(S)==length(Z))
.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.integer(length(Z)),
@@ -553,11 +557,12 @@ BClossdist <- function(defaultprob, issuerweights, recov, rho, Z, w,
BClossdistC <- function(defaultprob, issuerweights, recov, rho, Z, w,
N=length(issuerweights)+1, defaultflag=FALSE){
- stopifnot(length(Z)==length(w),
- nrow(defaultprob)==length(issuerweights))
if(is.null(dim(defaultprob))){
dim(defaultprob) <- c(length(defaultprob),1)
}
+ stopifnot(length(Z)==length(w),
+ nrow(defaultprob)==length(issuerweights),
+ nrow(defaultprob)==length(recov))
L <- matrix(0, N, ncol(defaultprob))
R <- matrix(0, N, ncol(defaultprob))
rho <- rep(rho, length(issuerweights))