init: Initialize an Object of Class 'GCPM'

Description Usage Arguments Value Author(s) References See Also Examples

Description

The function helps to create a new object of class GCPM. The arguments of the function are passed to the object after performing some plausibility checks.

Usage

1
2
3
init(model.type = "CRP", link.function = "CRP", N, seed,
loss.unit, alpha.max = 0.9999, loss.thr = Inf, sec.var,
random.numbers = matrix(), LHR, max.entries=1e3)

Arguments

model.type

Character value, specifying the model type. One can choose between “simulative” and “CRP” which corresponds to the analytical version of the CreditRisk+ model (see First Boston Financial Products, 1997)

link.function

character value, specifying the type of the link function. One can choose between “CRP”, which corresponds to \overline{PD}=PD\cdot (w^Tx) and “CM” which corresponds to \overline{PD}=Φ≤ft(\frac{Φ^{-1}PD-w^Tx}{√{1-w^TΣ w}}\right), where PD is the original PD from portfolio data, x is the vector of sector drawings, Φ is the CDF of the standard normal distribution, w is the vector of sector weights given in the portfolio data and Σ is the correlation matrix of the sector variables estimated from random.numbers. “CRP” will be used automatically if model.type == "CRP".

N

numeric value, defining the number of simulations if model.type == "simulative". If N is greater than the number of scenarios provided via random.numbers, scenarios are reused. This parameter is used only if model.type == "simulative".

seed

numeric value used to initialize the random number generator. If seed is not provided a value based on current system time will be used. This parameter is used only if model.type == "simulative".

loss.unit

numeric positive value used to discretize potential losses.

alpha.max

numeric value between 0 and 1 defining the maximum CDF-level which will be computed in case of an analytical CreditRisk+ type model.

loss.thr

numeric value specifying a lower bound for portfolio losses to be stored in order to derive risk contributions on counterparty level. Using a lower value needs a lot of memory but will be necessary in order to calculate risk contributions on lower CDF levels. This parameter is used only if model.type == "simulative".

sec.var

named numeric vector defining the sector variances in case of a CreditRisk+ type model. The names have to correspond to the sector names given in the portfolio. This parameter is used only if model.type == "CRP".

random.numbers

matrix with sector drawings. The columns represent the sectors, whereas the rows represent the scenarios (number of different simulations). The column names must correspond to the names used in the portfolio data (see analyze) and to the names of sec.var if model.type == "CRP". This parameter is used only if model.type == "simulative".

LHR

numeric vector of length equal to nrow(random.numbers) defining the likelihood ratio of each scenario. If not provided, all scenarios are assumed to be equally likely. This parameter is used only if model.type == "simulative".

max.entries

numeric value defining the maximum number of loss scenarios stored to calculate risk contributions.

Value

object of class GCPM

Author(s)

Kevin Jakob

References

Jakob, K. & Fischer, M. "GCPM: A flexible package to explore credit portfolio risk" Austrian Journal of Statistics 45.1 (2016): 25:44
Morgan, J. P. "CreditMetrics-technical document." JP Morgan, New York, 1997
First Boston Financial Products, "CreditRisk+", 1997
Gundlach & Lehrbass, "CreditRisk+ in the Banking Industry", Springer, 2003

See Also

GCPM, GCPM-class, analyze

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#create a random portfolio with NC counterparties
NC=100
#assign business lines and countries randomly
business.lines=c("A","B","C")
CP.business=business.lines[ceiling(runif(NC,0,length(business.lines)))] 
countries=c("A","B","C","D","E")
CP.country=countries[ceiling(runif(NC,0,length(countries)))]

#create matrix with sector weights (CreditRisk+ setting)
#according to business lines
NS=length(business.lines)
W=matrix(0,nrow = NC,ncol = length(business.lines),
dimnames = list(1:NC,business.lines)) 
for(i in 1:NC){W[i,CP.business[i]]=1}

#create portfolio data frame
portfolio=data.frame(Number=1:NC,Name=paste("Name ",1:NC),Business=CP.business,
                     Country=CP.country,EAD=runif(NC,1e3,1e6),LGD=runif(NC),
                     PD=runif(NC,0,0.3),Default=rep("Bernoulli",NC),W)

#draw sector variances randomly
sec.var=runif(NS,0.5,1.5)
names(sec.var)=business.lines

#draw N sector realizations (independent gamma distributed sectors)
N=5e4
random.numbers=matrix(NA,ncol=NS,nrow=N,dimnames=list(1:N,business.lines))
for(i in 1:NS){
random.numbers[,i]=rgamma(N,shape = 1/sec.var[i],scale=sec.var[i])}

#create a portfolio model and analyze the portfolio
TestModel=init(model.type = "simulative",link.function = "CRP",N = N,
loss.unit = 1e3, random.numbers = random.numbers,LHR=rep(1,N),loss.thr=5e6,
max.entries=2e4)
TestModel=analyze(TestModel,portfolio)

#plot of pdf of portfolio loss (in million) with indicators for EL, VaR and ES
alpha=c(0.995,0.999)
plot(TestModel,1e6,alpha=alpha)

#calculate portfolio VaR and ES
VaR=VaR(TestModel,alpha)
ES=ES(TestModel,alpha)

#Calculate risk contributions to VaR and ES 
risk.cont=cbind(VaR.cont(TestModel,alpha = alpha),
ES.cont(TestModel,alpha = alpha))

Example output

    Generalized Credit Portfolio Model 
    Copyright (C) 2015 Kevin Jakob & Dr. Matthias Fischer

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    version 2 as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1301, USA.

Importing portfolio data....
3 sectors ...
100 counterparties (0 removed due to EAD=0 (0), lgd=0 (0), pd<=0 (0) pd>=1 (0))

Portfolio statistics....
Loss unit: 1 K
Portfolio EAD:53.25 M
Portfolio potential loss:26.27 M
Portfolio expected loss:3.61 M(analytical)
Starting simulation (50000simulations )
0%   10   20   30   40   50   60   70   80   90   100%
|----|----|----|----|----|----|----|----|----|----|
**************************************************|
Simulation finished

Calculating loss distribution...
Calculating risk measures from loss distribution....
Expected loss from loss distribution: 3.54 M (deviation from EL calculated from portfolio data: -1.86%)
Exceedance Probability of the expected loss:0.4117
Portfolio mean expected loss exceedance: 5.96 M
Portfolio loss standard deviation:2.49 M

Deviation between VaR, EC contributions and VaR, EC caused by discontinuity of loss distribution:
Sum-check (alpha = 0.999 ) VaR-cont: -0.02% deviation

GCPM documentation built on May 1, 2019, 8:50 p.m.