crp.CSFP-class: Class '"crp.CSFP"'

Description Objects from the Class Slots Methods Author(s) References See Also Examples

Description

Modelling credit risks based on the concept of "Credit Risk+".

Objects from the Class

Objects can be created by calls of the form MyModel=init(...).

Slots

portfolio data:

CP.NR:

is a numeric vector with the counterparty ID-numbers.

CP.rating:

is a numeric vector with the counterparty ratings.

NEX:

is a numeric vector with the exposure of each counterparty.

LGD:

is a numeric vector with the counterparty specific LGDs

PL:

is a numeric vector with the potential loss for each counterparty before discretization.

PD:

is a numeric vector with the probability of default according to CP.rating for each counterparty before discretization.

W:

is a matrix with the sector weights for each counterparty.

nu:

is a numeric vector with the discrete losses on counterparty level as multiples of loss.unit.

PL.crp:

is a numeric vector with the potential loss for each counterparty adjusted to the discretization.

PD.crp:

is a numeric vector with the probability of default according to CP.rating for each counterparty adjusted to the discretization.

rating information:

rating:

is a numeric vector with the different rating classes.

rating.PD:

is a numeric vector with the probabilities of default corresponding to the rating classes.

rating.SD:

is a numeric vector with the standard deviations of the probabilities of default corresponding to the rating classes. If you use sec.var.est=5 this slot is unused.

sector information:

mu.k:

is a numeric vector with the average number of defaults per sector mu.k=sum(W[,k+1]*PD.crp)

loss.k:

is a numeric vector with the average loss per sector. It is defined by
loss.K[k]=sum(W[,1+k]*PD*PL).

sigma_k:

is a numeric vector with the sector standard deviation, calculated from rating.SD or sec.var according to sec.var.est.

control parameters:

sec.var.est:

is an indicator for the mode, the sector standard deviations should be calculated.
1: Sum of (weights * SD)
2: [Sum of (weights * SD)] / MU(k)
3: Sum of (sqrt(weights) * SD)
4: [Sum of ((sqrt(weights) * SD)] / MU(k)
5: Read variances from external file
with: MU.(k)=sum(W[,k+1]*PD)

loss.unit:

is the discretization parameter for net exposures.

Niter.max:

is the maximum number of exposure bands/probabilities being calculated.

alpha.max:

If a number smaller one is insert, the calculation stops at this level of the CDF. For this mode, an upper bound of Niter.max.global is implemented to stop if this number of iterations is reached. If the desired confidence level is not reached till this threshold, a warning comes up. If you set Niter.max > Niter.max.global manually, the threshold will be ignored.

Niter.max.global:

is the maximum number of iterations if alpha.max is specified. Be aware, that a high value can have high memory costs during the algorithm, even if the calculation of the CDF stops very much earlier.

alpha:

is the vector of confidence levels (between 0 and 1), the Value at risk and expected shortfall should be calculated. It should be no problem if the entries are not in an ascending order. For the risk contributions only the last entry will be considered.

PLOT.PDF:

is a flag for plotting the PDF during crp.CSFP main routine or not. It will not be recognized if you start plot directly.

PLOT.scale:

is a numeric value defining the scale for the horizontal axis (the losses) of the PDF plot.

PLOT.range.x:

is a numeric vector with two entries representing the range on the x-axis (the losses) for the plot of the loss distribution. If you insert values smaller one, this will be interpreted as levels of the CDF. The default for PLOT.range.x /-.y (0,0) means, that R will choose axis range by itself.

PLOT.range.y:

is the same as PLOT.range.x above for vertical axis.

calc.rc:

is a flag for calculating the risk contributions or not during crp.CSFP main routine. It will not be recognized if you start rc.vares or rc.sd directly.

save.memory:

is a switch for the save memory mode. If save.memory=TRUE, loss and CDF will not be stored permanently. If needed, the CDF is recalculated from the PDF. The same happens to a and B at the end of loss.dist if calc.rc=FALSE.

model information and risk measures:

NS:

is a numeric value with the number of sectors.

NC:

is a numeric value with the number of counterparties.

sec.var:

is a numeric vector with the sector variances from sec.var.name.

EL:

is a numeric value with the expected loss before discretization.

EL.crp:

is a numeric value with the expected loss after discretization, calculated from the PDF. Differences to EL are caused by alpha.max or Niter.max being to small.

sigma_sqr_div:

is a numeric value with the diversifiable part of SD.crp. The value is already squared.

sigma_sqr_syst:

is a numeric value with the systemic part of SD. The value is already squared.

SD:

is a numeric value with the portfolio standard deviation.

SD.crp:

is a numeric value with the portfolio standard deviation after discretization, calculated from the PDF. Differences to SD are caused by loss.unit being to large or alpha.max being to small.

VaR:

is a numeric vector containing the calculated value at risk for the given levels in alpha.

EC:

is a numeric vector containing the economic capital for the given levels in alpha. In the CR+ framework this is defined as EC=VaR-EL.crp.

ES:

is a numeric vector containing the expected shortfall for the given levels in alpha.

risk contributions:

VaR.cont:

is a numeric vector with the risk contributions to the last entry in VaR for each counterparty.

ES.cont:

is a numeric vector with the risk contributions to the last entry in ES for each counterparty.

ES.tau.cont:

is a numeric vector with the risk contributions to TAU, corresponding to the the last entry in ES for each counterparty.

SD.cont:

is a numeric vector with the risk contributions to the portfolio standard deviation.

loss distribution:

loss:

is a numeric vector with the different losses / exposure bands, the PDF is calculated for.

PDF:

is a numeric vector with the probability density function.

CDF:

is a numeric vector with the cumulative distribution function.

providing model input:

input:

is a temporary list, used if input data (portfolio, rating.scale, sec.var) are passed directly to init.

path.in:

is a character string with the path to the directory, where are the input files. All input files have to be in this directory. The path should end with "...\\" or ".../".

port.name:

is a character string with the name of the portfolio file, ending with ".csv".

rating.scale.name:

is a character string with the name of the rating file, ending with ".csv".

sec.var.name:

is a character string with the name of the file containing the sector variances, ending with ".csv".

file.format:

is a character string defining the format of the input files if no data frames are provided. You can choose between 'csv', which means that the separation character is ',' and the decimal character is '.' and 'csv2', which means that the separation character is ';' and the decimal character is ','.

model output:

export.to.file:

logical, defining if results should be exported to path.out

path.out:

is a character string with the path to the directory, where the output should be written to if export.to.file = TRUE, ending with "...\\" or ".../". Be aware, that actually, by writing any output, the model will create a subdirectory in path.out with its name. So you can use path.in also as path.out (which is the default case), create different models from the same input data (or different files, lying in the same directory), without worrying about the output path or overwriting other results.

internal model parameters:

a:

is a numeric value calculated during loss.dist, necessary for the PDF and needed in rc.vares.

B:

is a matrix calculated during loss.dist, necessary for the PDF and needed in rc.vares

M:

is a numeric value giving the maximal exposure band, which is calculated during loss.dist().

read.OK:

is a flag indicating if reading input files / data frames was successful.

plausi.OK:

is a flag indicating if the plausibility check was successful.

rc.OK:

is a flag indicating if the calculation of risk contributions to VaR and ES was successful.

VaR.pos:

is a numeric vector with the positions of VaR in CDF.

alpha.crp:

is a numeric vector containing the CDF-levels of VaR. Because they are from the calculated CDF alpha.crp will always be a little bit greater as alpha. With the help of alpha.crp it is not necessary to store the CDF for calculating risk contributions to VaR and ES (save.memory = TRUE can be used.

name:

is a character string with the name of the model. This slot is set at the time you run the first method on your model, not by creation via init. If you change the model name (the name of the R object) name is updated automatically by the first method running on it.

changes.read:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting read().

changes.plausi:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting plausi().

changes.calc.portfolio.statistics:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting calc.portfolio.statistics.

changes.loss:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting loss.dist.

changes.measure:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting measure.

changes.plot:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting plot.

changes.rc.vares:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting rc.sd.

changes.rc.sd:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting rc.vares.

changes.export:

is an internal flag indicating changes on input parameters (by call to <slot>) affecting export.

Methods

calc.portfolio.statistics

Calculating portfolio statistics

loss.dist

Calculating the loss distribution

rc.sd

Calculating risk contributions to standard deviation

rc.vares

Calculating risk contributions to VaR and ES

crp.CSFP

Main routine for CSFP-model

export

Export risk contributions

measure

Calculating portfolio measures

plausi

Checking input data for plausibility

plot

Plotting the PDF

read

Reading the input files

summary

Summarize portfolio key numbers

write.summary

Writing summary to file

<slot>

You can enter every slot via <slot> e.g. VaR(MyModel) gives the calculated value at risk.

<slot> <-

You can change the value of a slot if this is an input parameter via <slot> <- e.g. alpha(MyModel)<-c(0.999,0.9995). You can do so with all slots that are available in init and the slots containing portfolio information (CP.NR, NEX, CP.rating, LGD, W), rating information (rating, rating.PD, rating.PD) and the sector variances sec.var

Author(s)

Kevin Jakob & Dr. Matthias Fischer

References

First Boston Financial Products, "CreditRisk+", 1997
Gundlach & Lehrbass, "CreditRisk+ in the Banking Industry", Springer, 2003

See Also

init crp.CSFP

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
MyModel=init(path.in=system.file("data",package="crp.CSFP"),loss.unit=1e6,
calc.rc=TRUE)

# or pass portfolio directly and use random sector variances
Path=system.file("data",package="crp.CSFP")
portfolio=read.csv(paste(Path,"/portfolio.csv",sep=""))
rating.scale=read.csv(paste(Path,"/rating_pd.csv",sep=""))
sec.var=data.frame(Var=runif(3,0,2))

MyModel=init(portfolio=portfolio,rating.scale=rating.scale,sec.var=sec.var,
loss.unit=1e6,calc.rc=TRUE)

# execute portfolio calculation
MyModel=crp.CSFP(MyModel)

Example output

    CreditRisk+ portfolio model 
    Copyright (C) 2011  Dr. Matthias Fischer, Kevin Jakob & Stefan Kolb

    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.
                        
    Please note that this package will not be updated anymore.
    Instead we recommend to use the GCPM package which includes
    the functionality of this package as well as more flexible
    and more powerfull extensions.

    CreditRisk+ portfolio model 
    Copyright (C) 2011  Dr. Matthias Fischer, Kevin Jakob & Stefan Kolb

    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.
                        
    Please note that this package will not be updated anymore.
    Instead we recommend to use the GCPM package which includes
    the functionality of this package as well as more flexible
    and more powerfull extensions.

Importing risk information (Rating, PD, SD)....
Importing portfolio data....
Importing PD sector variances....
3 sectors ...25 counterparties (0 removed) ... OK
Calculating sector information...
Sector information completed...
Diversifible risk:  8.28 Tril.   Systematic risk:  7.21 Tril. 
Calculating portfolio statistics....
Portfolio net exposure: 130.51 Mio. 
Portfolio potential loss: 41.03 Mio. 
Portfolio expected loss: 3.8 Mio. 
Portfolio standad deviation: 3.94 Mio. 
Max. exposure band per CP: 7
Discretization completed...
Calculate the loss distribution till 0.9999-confidence level is reached.
Loss unit: 1 Mio.

Reached level of confidence: 0.999904 ( iterations actually done: 33 )
Calculation completed...
Calculating portfolio statistics....
CR+ portfolio expected loss: 3.8 Mio. 
Expected loss difference: -3.55 Thd. 
CR+ Exceedance Probability of the expected loss: 0.5280406 
CR+ portfolio standard deviation: 3.92 Mio. 
CR+ portfolio Value-at-risk(0.999): 25 Mio.
CR+ portfolio economic capital(0.999): 21.2 Mio.
CR+ portfolio Expected Shortfall(0.999): 28 Mio.
CR+ portfolio mean expected loss exceedance: 6.45 Mio.
Calculating VaR and ES contributions....
CR+ Expected Shortfall TAU( 0.9969835 ): 24.02 Mio. 
Scale Factor for TAU 1.040977 
Sum Check VaR: OK
Sum Check ES: OK
Done....
Calculating SD contributions....
Sum Check SD: OK
Done....

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