init: Initializing a new entity of class crp.CSFP

Description Usage Arguments Value Author(s) See Also Examples

View source: R/other_functions.r

Description

This function helps to create a new entity of a crp.CSFP object. The arguments, given to the functions become the attributes of the new model.

Usage

1
2
3
4
5
6
7
8
init(path.in = "", path.out = "", port.name = "portfolio.csv",
rating.scale.name = "rating_pd.csv", sec.var.name = "pd_sector_var.csv",
sec.var.est = 5, loss.unit = 1e+06, Niter.max = 0, alpha.max = 0.9999,
Niter.max.global = 1e+05, alpha = c(0.999), PLOT.PDF = TRUE,
export.to.file = FALSE, calc.rc = FALSE, PLOT.scale = 1e+06,
PLOT.range.x = c(0, 0), PLOT.range.y = c(0, 0), save.memory = FALSE,
file.format = "csv", portfolio = data.frame(), rating.scale = data.frame(),
sec.var = data.frame())

Arguments

portfolio

is a data frame containing the portfolio information. The structure has to be the same as described in port.name for the .csv files. If not provided, the file is read from path.in.

rating.scale

is a data frame containing the rating master scale. The structure has to be the same as described in rating.scale.name for the .csv files. If not provided, the file is read from path.in.

sec.var

is a data frame containing the sector variances. The structure has to be the same as described in sec.var.name for the .csv files. If not provided, the file is read from path.in.

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. It must end with "...\\" or ".../". In alternative the files can be passed as data frames to init, please have a look at portfolio, rating.scale or sec.var below.

file.format

is a character string defining the format of the input files. 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 ','.

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 your path.in as path.out (which is the default case), create different models from the same input data (or from different files, lying in the same directory), without worrying about the output path or overwriting other results.

port.name

is a character string with the name of the portfolio file, ending with ".csv". The file must contain the following columns: CPnumber, CPname, exposure,lgd, maturity, rating, S1, S2 ,... . Take care of the right spelling of the column titles and capitalization.

rating.scale.name

is a character string with the name of the rating file, ending with ".csv". The file must contain the following columns: RATING, PD, SD. The SD column is not necessary if sec.var.est=5. The rating classes have to be integer values. A class '0' is allowed. All counterparties in this class are removed before analyzing the portfolio. Take care of the right spelling of the column titles and capitalization.

sec.var.name

is a character string with the name of the file containing the sector variances, ending with ".csv". The file must contain the column Var. Take care of the right spelling and capitalization. The file is not used if sec.var.est != 5.

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

in alternative to Niter.max, one can also define the maximum CDF level.

Niter.max.global

is the maximum number of iterations if alpha.max is provided. 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 logical indicator for plotting the PDF or not. It will not be recognized if you start plot directly.

export.to.file

is a logical indicator defining if loss distribution, risk contributions and a summary should be exported to path.out.

calc.rc

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

PLOT.scale

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

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 defaults for PLOT.range.x /-.y (0,0) have the meaning, that R will choose axis range by itself.

PLOT.range.y

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

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.

Value

A new object of class crp.CSFP.

Author(s)

Kevin Jakob & Dr. Matthias Fischer

See Also

crp.CSFP

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

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.

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