r.squared {LGDtoolkit} | R Documentation |
Coefficient of determination
Description
r.squared
returns coefficient of determination for risk factors
supplied in data frame db
. Implemented algorithm processes numerical as well
as categorical risk factor.
Usually, this procedure is applied as starting point of bivariate analysis in LGD model development.
Usage
r.squared(db, target)
Arguments
db |
Data frame of risk factors and target variable supplied for bivariate analysis. |
target |
Name of target variable within |
Value
The command r.squared
returns the data frames with a following statistics:
name of the processed risk factor (rf
), type of processed risk factor (rf.type
),
number of missing and infinite observations (miss.inf
), percentage of missing and
infinite observations (miss.inf.pct
), coefficient of determination (r.squared
)
Examples
library(monobin)
library(LGDtoolkit)
data(lgd.ds.c)
r.squared(db = lgd.ds.c, target = "lgd")
#add categorical risk factor
lgd.ds.c$rf_03_bin <- sts.bin(x = lgd.ds.c$rf_03, y = lgd.ds.c$lgd)[[2]]
r.squared(db = lgd.ds.c, target = "lgd")
#add risk factor with all missing, only one complete case and zero variance risk factor
lgd.ds.c$rf_20 <- NA
lgd.ds.c$rf_21 <- c(1, rep(NA, nrow(lgd.ds.c) - 1))
lgd.ds.c$rf_22 <- c(c(1, 1), rep(NA, nrow(lgd.ds.c) - 2))
r.squared(db = lgd.ds.c, target = "lgd")
[Package LGDtoolkit version 0.2.0 Index]