homogeneity {LGDtoolkit}R Documentation

Testing homogeneity of the LGD rating model

Description

homogeneity performs homogeneity testing of LGD model based on the rating pools and selected segment. This test is usually applied on application portfolio, but it can be applied also on model development sample. Additionally, this method requires higher number of observations per segment modalities within each rating in order to produce available results. For segments with less than 30 observations, test is not performed.

Usage

homogeneity(
  app.port,
  loss,
  pools,
  segment,
  segment.num,
  method = "t.test",
  alpha = 0.05
)

Arguments

app.port

Application portfolio (data frame) which contains at lease realized loss (LGD), pools in use and variable used as a segment.

loss

Name of the column that represents realized loss (LGD).

pools

Name of the column that represents LGD pools.

segment

Name of the column that represent testing segments. If it is of numeric type, than it is first grouped into segment.num of groups otherwise is it used as supplied.

segment.num

Number of groups used for numeric variables supplied as a segment. Only applicable if segment is of numeric type.

method

Statistical test. Available options are t.test (default) and wilcox.test.

alpha

Significance level of statistical test. Default is 0.05.

Details

Testing procedure is implemented for each rating separately comparing average realized loss from one segment modality to the average realized loss from the rest of segment modalities.

Value

The command homogeneity returns a data frame with the following columns:

Examples

library(monobin)
library(LGDtoolkit)
data(lgd.ds.c)
#build dummy model
rf <- c("rf_01", "rf_02", "rf_16", "rf_03", "rf_09")
for   (i in 1:length(rf)) {
     rf_l <- rf[i]
     lgd.ds.c[, rf_l] <- sts.bin(x = lgd.ds.c[, rf_l], 
                                y = lgd.ds.c[, "lgd"])[[2]]	
     }
str(lgd.ds.c)
frm <- paste0("lgd ~ ", paste(rf, collapse = " + "))
model <- lm(formula = as.formula(frm), data = lgd.ds.c)
summary(model)$coefficients
#create lgd pools
lgd.ds.c$pred <- unname(predict(model))
lgd.ds.c$pool <- sts.bin(x = lgd.ds.c$pred, 
                        y = lgd.ds.c$lgd)[[2]]
#test homogeneity on development sample
#(the same procedure can be applied on application portfolio)
homogeneity(app.port = lgd.ds.c, 
           loss = "lgd", 
           pools = "pool", 
           segment = "rf_03", 
           segment.num = 3, 
           method = "t.test", 
           alpha = 0.05)

[Package LGDtoolkit version 0.2.0 Index]