2. OBJETIVOS

2.1 Objetivo general:

Diseñar un modelo de scoring que permita identificar a probabilidad de incumplimiento en la etapa de otorgamiento de un crédito de consumo.

2.2 Objetivos específicos:

  • Proporcionar una evaluación más precisa del riesgo crediticio asociado con cada solicitante. Este enfoque tiene la intención de reducir las pérdidas asociadas con la concesión de crédito a clientes de alto riesgo y, al mismo tiempo, facilitar el acceso al crédito para aquellos con un menor riesgo crediticio.

  • Aumentar la eficiencia operativa al automatizar la evaluación de riesgos. Al reducir la carga de trabajo manual asociada con la toma de decisiones, se espera mejorar los tiempos de respuesta y reducir los costos operativos.

  • Garantizar el cumplimiento normativo. El modelo de scoring se diseñará considerando las regulaciones aplicables, contribuyendo así a un proceso de toma de decisiones que cumple con los estándares legales y éticos.

  • Desarrollar un modelo que sea adaptable a cambios en los datos y que mantenga su rendimiento predictivo a lo largo del tiempo.

  • Realizar las pruebas correspondientes a los modelos estimados, con el fin de seleccionar el modelo que estadísticamente refleje la realidad.

3. MODELO LOGIT:

El modelo logístico arroja un resultado binario, en donde la variable dependiente toma el valor de 0 o de 1, siendo un modelo de predicción de probabilidad de ocurrencia de una variable dicotómica categórica. La regresión binaria es un tipo de análisis de regresión, donde la variable dependiente es una variable dummy, ejemplo: Buen cliente (0) o Mal cliente (1)

A continuación se describen las variables a utilizar en el modelo.

Variables cuantitativas.

Variables Descripción
Valor Factura Valor aprobado del crédito otorgado
Plazo Número de meses pactados para el pago del crédito.
Sueldo Ingresos manifestados por el cliente
Score Puntaje en centrales de riesgo
NoObligSF Número de obligaciones en el SECTOR FINANCIERO
regiblmorSF Número de obligaciones EN MORA en el SECTOR FINANCIERO
regtotsalSF Saldo total adedudado en el SECTOR FINANCIERO
regsalmorSF Saldo EN MORA adedudado en el SECTOR FINANCIERO
NoObligSR Número de obligaciones en el SECTOR REAL
regiblmorSR Número de obligaciones EN MORA en el SECTOR REAL
regtotsalSR Saldo total adedudado en el SECTOR REAL
regsalmorSR Saldo EN MORA adedudado en el SECTOR REAL
NoObligSS Número de obligaciones en el SECTOR SOLIDARIO
regiblmorSS Número de obligaciones EN MORA en el SECTOR SOLIDARIO
regtotsalSS Saldo total adedudado en el SECTOR SOLIDARIO
regsalmorSS Saldo EN MORA adedudado en el SECTOR SOLIDARIO
NoObligTC Número de TARJETAS DE CRÉDITO
regiblmorTC Número de TARJETAS DE CRÉDITO en MORA
regtotsalTC Saldo total adedudado por TARJETAS DE CRÉDITO
regsalmorTC Saldo EN MORA adedudado por TARJETAS DE CRÉDITO
NoObligGL Total numero de obligaciones
regiblmorGL Total número de obligaciones EN MORA
regtotsalGL Saldo GLOBAL total adedudado por todos los sectores
regsalmorGL Saldo GLOBAL EN MORA adedudado por todos los sectores
Cuota_global Suma del valor de cuota pagada por el cliente

Variables cualitativas (categoricas):

Variables Descripción
Región Lugar demográfico donde se tramitó el crédito
Credit Vision Perfil otorgado al cliente al momento del estudio
Linea Linea de crédito por donde se tramitó el crédito
Actividad Actividad económica del cliente.
Estrato Estrato sociodemografico (1 al 6)
Sector Zona de residencia del cliente (urbana o rural)
Tipo de vivienda Clasificación o categorización de la residencia
Antiguedad laboral Clasificación en meses del tiempo laborando
Rango de Edad Clasificación según la edad del cliente.
Genero Sexo del cliente (F=Femenino, M=Masculino)
Educacion Nivel de escolaridad de cliente
Default Variable que toma valores de 0 o 1 (0 = Al día/1 = En Mora)
Ciudad Ciudad de residencia del cliente

Transformación de variables cualitativas o categoricas a tipo factor.

#  transformamos chr -> Factor (Nomimales)
score_alm = score_alm %>% 
  mutate(REGION= as.factor(REGION),
         CIUDAD = as.factor(CIUDAD),
         LINEA = as.factor(LINEA),
         ACTIVIDAD = as.factor(ACTIVIDAD),
         ESTRATO = as.factor(ESTRATO),
         SECTOR = as.factor(SECTOR),
         `TIPO DE VIVIENDA` = as.factor(`TIPO DE VIVIENDA`),
         `ANTIGÜEDAD LABORAL` = as.factor(`ANTIGÜEDAD LABORAL`),
         `RANGO DE EDAD` = as.factor(`RANGO DE EDAD`),
         `CREDIT VISION` = as.factor(`CREDIT VISION`),
         EDUCACION = as.factor(EDUCACION),
         GENERO = as.factor(GENERO),
         ESTRATO = as.factor(ESTRATO))

4. ANALISIS EXPLORATORIO DE DATOS (EDA):

El Análisis Exploratorio de Datos (EDA por sus siglas en inglés) es una etapa crucial en el proceso de análisis de datos que tiene como objetivo comprender mejor los datos antes de aplicar cualquier modelo estadístico o técnica de aprendizaje automático. Algunos puntos clave sobre el EDA son:

Comprensión de los datos: El EDA ayuda a los investigadores a familiarizarse con los datos, explorando su estructura, distribución, tendencias y relaciones entre variables.

Detección de anomalías: Permite identificar datos atípicos o inconsistentes que podrían afectar la calidad del análisis y los resultados.

Identificación de patrones: Ayuda a descubrir patrones interesantes o tendencias ocultas en los datos que podrían no ser evidentes a simple vista.

Selección de características: Permite identificar qué variables son relevantes para el análisis y la construcción de modelos predictivos.

Validación de suposiciones: Permite verificar si las suposiciones hechas sobre los datos son válidas y si los métodos de análisis seleccionados son apropiados.

# Default
(t_Default =table(score_alm$Default))
## 
##    0    1 
## 7848 2590
round(prop.table(t_Default),3)*100 #el 24.9% son clientes en Default
## 
##    0    1 
## 75.2 24.8
(g1 = ggplot(score_alm, aes(as.factor(Default), fill = as.factor(Default)))+
    geom_bar()+
    labs(title = "Default del credito",x= "", y= "")+
    scale_fill_discrete(labels = c("puntual","moroso"))+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    theme_minimal())

# Nivel Sexo
(t_Genero = table(score_alm$GENERO))
## 
##    F    M 
## 5620 4818
round(prop.table(t_Genero),3)*100
## 
##    F    M 
## 53.8 46.2
(g2 = ggplot(score_alm, aes(GENERO, fill = GENERO))+
    geom_bar()+
    labs(title = "Participacion por género",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    theme_minimal()+
    theme(legend.position = "none"))

# REGION DONDE SE SOLICITÓ EL CRÉDITO

(t_region = table(score_alm$REGION))
## 
##           COSTA       EJE-VALLE          LLANOS MAGDALENA MEDIO    TOLIMA HUILA 
##            1386            1905            4289            1014            1844
round(prop.table(t_region),2)*100
## 
##           COSTA       EJE-VALLE          LLANOS MAGDALENA MEDIO    TOLIMA HUILA 
##              13              18              41              10              18
(g3 = ggplot(score_alm, aes(REGION, fill = REGION))+
    geom_bar()+
    labs(title = "Participación por Región",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    coord_flip()+
    theme_minimal()+
    theme(legend.position = "none"))

# ACTIVIDAD ECONOMICA DEL CLIENTE

(t_actividad = table(score_alm$ACTIVIDAD))
## 
##      Empleado Independiente    Pensionado    Prestacion 
##          4589          4825           670           354
round(prop.table(t_actividad),2)*100
## 
##      Empleado Independiente    Pensionado    Prestacion 
##            44            46             6             3
(g5 = ggplot(score_alm, aes(ACTIVIDAD, fill = ACTIVIDAD))+
    geom_bar()+
    labs(title = "Participación por Actividad Económica",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    coord_flip()+
    theme_minimal()+
    theme(legend.position = "none"))

# ESTRATO SOCIODEMOGRAFICO DEL CLIENTE

(t_estrato = table(score_alm$ESTRATO))
## 
##    1    2    3    4    5    6 
## 2565 7204  568   77   18    6
round(prop.table(t_actividad),2)*100
## 
##      Empleado Independiente    Pensionado    Prestacion 
##            44            46             6             3
(g6 = ggplot(score_alm, aes(ESTRATO, fill = ESTRATO))+
    geom_bar()+
    labs(title = "Participación por Estrato Social",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    coord_flip()+
    theme_minimal()+
    theme(legend.position = "none"))

(t_antiguedad = table(score_alm$`ANTIGÜEDAD LABORAL`))
## 
##  De 4 a 8 meses De 8 a 12 meses   Mayor a 1 año   Menor 4 meses 
##             551             485            8702             700
round(prop.table(t_antiguedad),2)*100
## 
##  De 4 a 8 meses De 8 a 12 meses   Mayor a 1 año   Menor 4 meses 
##               5               5              83               7
(g7 = ggplot(score_alm, aes(`ANTIGÜEDAD LABORAL`, fill = `ANTIGÜEDAD LABORAL`))+
    geom_bar()+
    labs(title = "Participación por Antiguedad Laboral",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    theme_minimal()+
    theme(legend.position = "none"))

(t_edad = table(score_alm$`RANGO DE EDAD`))
## 
##  18-28  29-35  36-45  46-55 56-100 
##   2069   1862   2400   2122   1985
round(prop.table(t_antiguedad),2)*100
## 
##  De 4 a 8 meses De 8 a 12 meses   Mayor a 1 año   Menor 4 meses 
##               5               5              83               7
(g8 = ggplot(score_alm, aes(`RANGO DE EDAD`, fill = `RANGO DE EDAD`))+
    geom_bar()+
    labs(title = "Participación por Rangos de Edad",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    theme_minimal()+
    theme(legend.position = "none"))

(t_educ = table(score_alm$EDUCACION))
## 
##      Educación primaria    Educación secundaria Educación universitaria 
##                    1653                    6509                     667 
##               No aplica     Posgrado - maestria   Técnica - tecnologica 
##                      64                      76                    1469
round(prop.table(t_educ),2)*100
## 
##      Educación primaria    Educación secundaria Educación universitaria 
##                      16                      62                       6 
##               No aplica     Posgrado - maestria   Técnica - tecnologica 
##                       1                       1                      14
(g9 = ggplot(score_alm, aes(EDUCACION, fill = EDUCACION))+
    geom_bar()+
    labs(title = "Participación por Educacion",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    theme_minimal()+
    theme(legend.position = "none"))

(t_vivi = table(score_alm$`TIPO DE VIVIENDA`))
## 
##             Familiar               Propia  Renta de 1 a 3 años 
##                 3262                 3643                 1282 
##  Renta de 3 a 5 años Renta mayor a 5 años Renta menor de 1 año 
##                  737                  504                 1010
round(prop.table(t_vivi),2)*100
## 
##             Familiar               Propia  Renta de 1 a 3 años 
##                   31                   35                   12 
##  Renta de 3 a 5 años Renta mayor a 5 años Renta menor de 1 año 
##                    7                    5                   10
(g10 = ggplot(score_alm, aes(`TIPO DE VIVIENDA`, fill = `TIPO DE VIVIENDA`))+
    geom_bar()+
    labs(title = "Participación por Tipo de Vivienda",x= "", y= "")+
    geom_text(stat = "count", aes(label = paste0(round((..count..)/sum(..count..)*100, 1), "%")), 
              position = position_stack(vjust = 0.5)) +
    theme_minimal()+
    theme(legend.position = "none"))

Validadas las variables categoricas se realiza igualmente un análisis sobre las variables cuantitativas con el fin de discriminar la distribución de las mismas e identificar si existe o no correlaciones entre las mismas.

estadisticas = function(x){
  n <- length(x)
  media <- round(mean(x),2)
  mediana <- round(median(x),2)
  desvest <- round(sd(x),2)
  max <- round(max(x),2)
  min<-round(min(x),2)
  P25<-round(quantile(x, probs = 0.25),1)
  P50<-round(quantile(x, probs = 0.50),1)
  P75<-round(quantile(x, probs = 0.75),1)
  P80<-round(quantile(x, probs = 0.80),1)
  
  Stat<- rbind(n,media, mediana, desvest, max, 
               min,P25, P50,P75,P80)
  
  Stat
}

TABLA DE MEDIDAS ESTADISITCAS DESCRIPTIVAS.

TABLA DEL SCORE DE CREDITO

datatable(estadisticas(score_alm$Score), options = list(pageLength = 5, lengthMenu = c(5, 10, 15, 20)))

TABLA DEL SALARIO DEL CLIENTE

datatable(estadisticas(score_alm$SUELDO), options = list(pageLength = 5, lengthMenu = c(5, 10, 15, 20)))

TABLA DEL VALOR DEL CRÉDITO SOLICITAD POR EL CLIENTE

datatable(estadisticas(score_alm$VALOR_FACTURA), options = list(pageLength = 5, lengthMenu = c(5, 10, 15, 20)))

TABLA DEL VALOR GLOBAL DE CUOTA PAGADO POR EL CLIENTE

datatable(estadisticas(score_alm$Cuota_global), options = list(pageLength = 5, lengthMenu = c(5, 10, 15, 20)))

TABLA DEL SALDO GLOBAL ADEUDADO POR EL CLIENTE

datatable(estadisticas(score_alm$regtotsalGL), options = list(pageLength = 5, lengthMenu = c(5, 10, 15, 20)))

GRAFICOS DE DISTRIBUCION CON VARIABLES CUANTITATIVAS

(g11 = ggplot(score_alm, aes(x = Score))+
    geom_histogram(color ="black", fill = "#FF4F33")+
    labs(title = "Score cliente", x ="", y = "")+
    theme_ipsum())
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

(g12 = ggplot(score_alm, aes(x = PLAZO))+
    geom_histogram(color ="black", fill = "#FF33E9")+
    labs(title = "Plazo", x ="", y = "")+
    theme_ipsum())
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

(g13 = ggplot(score_alm, aes(x = regtotsalGL))+
    geom_histogram(color ="black", fill = "#45B39D", bins = 20)+
    labs(title = "Saldo Global", x ="", y = "")+
    theme_ipsum())

(g14 = ggplot(score_alm, aes(x = NoObligGL))+
    geom_histogram(color ="black", fill = "#333FFF", bins = 20)+
    labs(title = "Numero de obligaciones", x ="", y = "")+
    theme_ipsum())

————— DIVISION DATOS TRAIN TEST —————

library(caret)
## Loading required package: lattice
## 
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
## 
##     lift
set.seed(123456)
muestra = createDataPartition(score_alm$Default, p = 0.7, list = F)

train = score_alm[muestra,]
test = score_alm[-muestra,]
dim(train)
## [1] 7307   59
dim(test)
## [1] 3131   59
library(corrplot)
## corrplot 0.92 loaded
datos_cuant <- score_alm[, c('SUELDO','PLAZO','NoObligSF','NoObligSR',                      'Score','regsalmorGL','NoObligGL','NoObligTC','regoblmorGL','regtotsalGL',
                             'regsaldiaGL')]
matriz_cor <- cor(datos_cuant, use = "complete.obs")  # use = "complete.obs" para manejar valores NA
corrplot(matriz_cor, method = "color", type = "upper", order = "hclust", addCoef.col = "black",
         tl.col = "black", tl.srt = 45, tl.cex = 0.7)

# Porcentaje de Default por Grupos
tasa_de_malos = mean(train$Default)
tasa_de_malos
## [1] 0.2531819
(g15 = train %>%
    group_by(GENERO, Default) %>% 
    summarise(total = n()) %>% 
    spread(key = Default, value = total) %>% 
    mutate(tasa_malos = `1`/(`1`+ `0`)*100) %>% 
    ggplot(aes(x= GENERO, y = tasa_malos))+
    geom_col(aes(fill = tasa_malos))+
    scale_fill_gradient2(low = "#F4A460",
                         high = "#6495ED")+
    geom_label(aes(label = round(tasa_malos,2)))+
    theme_ipsum()+
    labs(title = "Default Entidades", y = "", x= "")+
    theme(legend.position = "none"))
## `summarise()` has grouped output by 'GENERO'. You can override using the
## `.groups` argument.

(g16 = train %>%
    group_by(`RANGO DE EDAD`, Default) %>% 
    summarise(total = n()) %>% 
    spread(key = Default, value = total) %>% 
    mutate(tasa_malos = `1`/(`1`+ `0`)*100) %>% 
    ggplot(aes(x= `RANGO DE EDAD`, y = tasa_malos))+
    geom_col(aes(fill = tasa_malos))+
    scale_fill_gradient2(low = "#F4A460",
                         high = "#6495ED")+
    geom_label(aes(label = round(tasa_malos,2)))+
    theme_minimal()+
    labs(title = "Default Rango de Edad", y = "", x= "")+
    theme(legend.position = "none"))
## `summarise()` has grouped output by 'RANGO DE EDAD'. You can override using the
## `.groups` argument.

(g17 = train %>%
    group_by(`TIPO DE VIVIENDA`, Default) %>% 
    summarise(total = n()) %>% 
    pivot_wider(names_from = Default, values_from = total, values_fill = 0) %>%
    mutate(tasa_malos = `1` / (`1` + `0`) * 100) %>% 
    ggplot(aes(x = reorder(`TIPO DE VIVIENDA`, tasa_malos), y = tasa_malos)) +
    geom_col(aes(fill = tasa_malos)) +
    scale_fill_gradient2(low = "#F4A460", high = "#6495ED") +
    geom_label(aes(label = round(tasa_malos, 2))) +
    theme_minimal() +
    labs(title = "Default por tipo de Vivienda", y = "", x = "") +
    theme(legend.position = "none"))
## `summarise()` has grouped output by 'TIPO DE VIVIENDA'. You can override using
## the `.groups` argument.

(g18 = train %>%
    group_by(REGION, Default) %>% 
    summarise(total = n()) %>% 
    pivot_wider(names_from = Default, values_from = total, values_fill = 0) %>%
    mutate(tasa_malos = `1` / (`1` + `0`) * 100) %>% 
    ggplot(aes(x = reorder(REGION, tasa_malos), y = tasa_malos)) +
    geom_col(aes(fill = tasa_malos)) +
    scale_fill_gradient2(low = "#F4A460", high = "#6495ED") +
    geom_label(aes(label = round(tasa_malos, 2))) +
    theme_minimal() +
    labs(title = "Default por Region", y = "", x = "") +
    theme(legend.position = "none"))
## `summarise()` has grouped output by 'REGION'. You can override using the
## `.groups` argument.

(g19 = train %>%
    group_by(ESTRATO, Default) %>% 
    summarise(total = n()) %>% 
    pivot_wider(names_from = Default, values_from = total, values_fill = 0) %>%
    mutate(tasa_malos = `1` / (`1` + `0`) * 100) %>% 
    ggplot(aes(x = reorder(ESTRATO, tasa_malos), y = tasa_malos)) +
    geom_col(aes(fill = tasa_malos)) +
    scale_fill_gradient2(low = "#F4A460", high = "#6495ED") +
    geom_label(aes(label = round(tasa_malos, 2))) +
    theme_minimal() +
    labs(title = "Default por tipo de Vivienda", y = "", x = "") +
    theme(legend.position = "none"))
## `summarise()` has grouped output by 'ESTRATO'. You can override using the
## `.groups` argument.

(g20 = train %>%
    group_by(`CREDIT VISION`, Default) %>% 
    summarise(total = n()) %>% 
    pivot_wider(names_from = Default, values_from = total, values_fill = 0) %>%
    mutate(tasa_malos = `1` / (`1` + `0`) * 100) %>% 
    ggplot(aes(x = reorder(`CREDIT VISION`, tasa_malos), y = tasa_malos)) +
    geom_col(aes(fill = tasa_malos)) +
    scale_fill_gradient2(low = "#F4A460", high = "#6495ED") +
    geom_label(aes(label = round(tasa_malos, 2))) +
    theme_minimal() +
    labs(title = "Default por Credit Vision", y = "", x = "") +
    theme(legend.position = "none"))
## `summarise()` has grouped output by 'CREDIT VISION'. You can override using the
## `.groups` argument.

library(smbinning)
## Loading required package: sqldf
## Loading required package: gsubfn
## Loading required package: proto
## Loading required package: RSQLite
## Loading required package: partykit
## Loading required package: grid
## Loading required package: libcoin
## Loading required package: mvtnorm
## Loading required package: Formula
library(party)
## Loading required package: modeltools
## Loading required package: stats4
## Loading required package: strucchange
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## 
## Attaching package: 'strucchange'
## The following object is masked from 'package:stringr':
## 
##     boundary
## 
## Attaching package: 'party'
## The following objects are masked from 'package:partykit':
## 
##     cforest, ctree, ctree_control, edge_simple, mob, mob_control,
##     node_barplot, node_bivplot, node_boxplot, node_inner, node_surv,
##     node_terminal, varimp
## The following object is masked from 'package:dplyr':
## 
##     where
#ojo Smbinning no acepta nombre Default
#El target en Smninning es 1 = bueno
train$BUENO = ifelse(train$Default == 1,0,1)

# Var Experiencia

plot(ctree( as.factor(Default) ~ Score, train)) #pvalue = la prop de malos son iguales en las ramas sgts

plot(ctree( as.factor(Default) ~ regtotsalSR, train))

plot(ctree( as.factor(Default) ~ NoObligSR, train))

plot(ctree( as.factor(Default) ~ regoblmorSR, train))

plot(ctree( as.factor(Default) ~ regtotsalTC, train))

plot(ctree( as.factor(Default) ~ NoObligTC, train))

plot(ctree( as.factor(Default) ~ regoblmorGL, train))

plot(ctree( as.factor(Default) ~ VALOR_FACTURA, train))

plot(ctree( as.factor(Default) ~ SUELDO, train))

smb_EXP = smbinning(train,y= "BUENO",x="Score",p = 0.05)
smb_EXP$ivtable
##   Cutpoint CntRec CntGood CntBad CntCumRec CntCumGood CntCumBad PctRec GoodRate
## 1   <= 585    589     299    290       589        299       290 0.0806   0.5076
## 2   <= 641    857     533    324      1446        832       614 0.1173   0.6219
## 3   <= 712   2105    1524    581      3551       2356      1195 0.2881   0.7240
## 4   <= 778   2282    1833    449      5833       4189      1644 0.3123   0.8032
## 5    > 778   1474    1268    206      7307       5457      1850 0.2017   0.8602
## 6  Missing      0       0      0      7307       5457      1850 0.0000      NaN
## 7    Total   7307    5457   1850        NA         NA        NA 1.0000   0.7468
##   BadRate   Odds LnOdds     WoE     IV
## 1  0.4924 1.0310 0.0306 -1.0512 0.1072
## 2  0.3781 1.6451 0.4978 -0.5839 0.0452
## 3  0.2760 2.6231 0.9643 -0.1174 0.0041
## 4  0.1968 4.0824 1.4067  0.3250 0.0303
## 5  0.1398 6.1553 1.8173  0.7356 0.0890
## 6     NaN    NaN    NaN     NaN    NaN
## 7  0.2532 2.9497 1.0817  0.0000 0.2758
par(mfrow = c(2,2))
smbinning.plot(smb_EXP,option="dist",sub="Score")
smbinning.plot(smb_EXP,option="badrate",sub="Score") 
smbinning.plot(smb_EXP,option="goodrate",sub="Score")
smbinning.plot(smb_EXP,option="WoE",sub="Score")

smb_Edad = smbinning(df=train,y= "BUENO",x="PLAZO",p = 0.05)
## Warning in rbind(deparse.level, ...): number of columns of result, 14, is not a
## multiple of vector length 13 of arg 2
par(mfrow = c(2,2))
smbinning.plot(smb_Edad,option="dist",sub="PLAZO")
smbinning.plot(smb_Edad,option="badrate",sub="PLAZO") 
smbinning.plot(smb_Edad,option="goodrate",sub="PLAZO")
smbinning.plot(smb_Edad,option="WoE",sub="PLAZO")