r.squared | R Documentation |
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.
r.squared(db, target)
db |
Data frame of risk factors and target variable supplied for bivariate analysis. |
target |
Name of target variable within |
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
)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.