diff options
Diffstat (limited to 'R')
| -rw-r--r-- | R/lossdistrib.c | 6 | ||||
| -rw-r--r-- | R/script_calibrate_tranches.R | 6 | ||||
| -rw-r--r-- | R/tranche_functions.R | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/R/lossdistrib.c b/R/lossdistrib.c index 0a2c30ab..a2984e6b 100644 --- a/R/lossdistrib.c +++ b/R/lossdistrib.c @@ -19,7 +19,7 @@ void lossdistrib_blas(double *p, int *np, double *w, double *S, int *N, int *def double shockprob(double p, double rho, double Z, int give_log);
void lossdistrib_Z(double *p, int *np, double *w, double *S, int *N, int *defaultflag,
- double *rho, double *Z, double *wZ, int *nZ, double *q);
+ double *rho, double *Z, int *nZ, double *q);
void lossdistrib_truncated(double *p, int *np, double *w, double *S, int *N,
int *T, int *defaultflag, double *q);
@@ -66,6 +66,7 @@ void lossdistrib(double *p, int *np, double *w, double *S, int *N, int *defaultf the loss distribution.
p vector of default probabilities
np length of p
+ w issuer weights
S vector of severities (should be same length as p)
N number of ticks in the grid
defaultflat if true compute the default distribution
@@ -113,6 +114,7 @@ void lossdistrib_blas(double *p, int *np, double *w, double *S, int *N, int *def the loss distribution.
p vector of default probabilities
np length of p
+ w issuer weights
S vector of severities (should be same length as p)
N number of ticks in the grid
defaultflat if true compute the default distribution
@@ -157,7 +159,7 @@ void lossdistrib_blas(double *p, int *np, double *w, double *S, int *N, int *def }
void lossdistrib_Z(double *p, int *np, double *w, double *S, int *N, int *defaultflag,
- double *rho, double *Z, double *wZ, int *nZ, double *q){
+ double *rho, double *Z, int *nZ, double *q){
int i, j;
double* pshocked = malloc(sizeof(double) * (*np) * (*nZ));
diff --git a/R/script_calibrate_tranches.R b/R/script_calibrate_tranches.R index 8a1830ed..4789db7a 100644 --- a/R/script_calibrate_tranches.R +++ b/R/script_calibrate_tranches.R @@ -90,7 +90,7 @@ rho <- rep(0.45, n.credit) result <- matrix(0, 4, n.int)
for(l in 1:100){
- Rstoch <- array(0, dim=c(n.credit, n.int, ncol(SurvProb)))
+ Rstoch <- array(0, dim=c(n.credit, n.int, ncol(SurvProb)))
for(t in 1:ncol(SurvProb)){
for(i in 1:n.credit){
Rstoch[i,,t] <- stochasticrecovC(recov[i], 0, Z, w.mod, rho, defaultprob[i,t], p[i,t])
@@ -100,8 +100,8 @@ for(l in 1:100){ R <- array(0, dim=c(n.int, Ngrid, ncol(defaultprob)))
for(t in 1:ncol(defaultprob)){
S <- 1 - Rstoch[,,t]
- L[,,t] <- t(lossdistCZ(p[,t], issuerweights, S, Ngrid, 0, rho, Z, w))
- R[,,t] <- t(lossdistCZ(p[,t], issuerweights, 1-S, Ngrid, 0, rho, Z, w))
+ L[,,t] <- t(lossdistCZ(p[,t], issuerweights, S, Ngrid, 0, rho, Z))
+ R[,,t] <- t(lossdistCZ(p[,t], issuerweights, 1-S, Ngrid, 0, rho, Z))
}
for(i in 1:n.int){
result[,i] <- tranche.pvvec(Kmodified, L[i,,], R[i,,], cs)
diff --git a/R/tranche_functions.R b/R/tranche_functions.R index f22bdc68..1bb48487 100644 --- a/R/tranche_functions.R +++ b/R/tranche_functions.R @@ -260,7 +260,7 @@ lossdistCZ <- function(p, w, S, N, defaultflag=FALSE, rho, Z, wZ){ }
.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)),
+ as.double(rho), as.double(Z), as.integer(length(Z)),
q = matrix(0, N, length(Z)))$q
}
|
