analyze-methods: Analyze a Credit Portfolio

Description Usage Arguments Details Value Methods References See Also Examples

Description

The method analyzes a given portfolio with a predefined portfolio model (i.e. a GCPM object). Portfolio key numbers such as the number of portfolio positions, sum of EAD and PL or the expected loss are calculated. Afterwards the loss distribution is estimated according to model.type.

Usage

1
analyze(this,portfolio,alpha,Ncores)

Arguments

this

object of class GCPM

portfolio

data frame containing portfolio data. The following columns have to be defined (please be aware of the correct spelling of the column names):
Number: identification number for each portfolio position (numeric)
Name: counterparty name (character)
Business: business information (character/factor)
Country: country information (character/factor)
EAD: exposure at default (numeric)
LGD: loss given default (numeric in [0,1])
PD: probability of default (numeric in [0,1])
Default: default distribution either “Bernoulli” or “Poisson” (employable for pools)
sectors: starting with the 9th column, the sector weights have to be defined..

alpha

loss levels for risk measures economic capital, value at risk and expected shortfall (optional)

Ncores

number of (virtual) cores used to perfom Monte Carlo simulation (requires package parallel, default=1)

Details

In case of an analytical CreditRisk+ model, a modified version of the algorithm described in Gundlach & Lehrbass (2003) is used. For a simulative model, the loss distribution is estimated based on N simulations with sector drawings specified by random.numbers (see init). The sector names (column names) should not include any white spaces. In case of a CreditMetrics type model, the values of R (not R^2) have to be provided as sector weights. In the standard CreditMetrics or CreditRisk+ framework a counterparty can be assigned to more than one sector. Within a analytical CreditRisk+ model, the sector names have to match the names of sec.var or in a simulative model the column names of random.numbers (see init)

Value

object of class GCPM.

Methods

signature(this = "GCPM", portfolio = "data.frame", alpha = "missing")

If loss levels alpha are not provided, risk measures such as economic capital, value at risk and expected shortfall are not calculated by default. However, they can be calculated afterwards by calling the corresponding methods (see VaR, ES, EC)

signature(this = "GCPM", portfolio = "data.frame", alpha = "numeric")

If loss levels alpha are provided, risk measures such as economic capital, value at risk and expected shortfall are calculated and printed. To extract these risk measures into a separate variable you can use the corresponding methods.

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

init

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
48
49
50
#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))

#Use parallel computing for Monte Carlo simulation
TestModel=analyze(TestModel,portfolio,Ncores=2)

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