# =============================================
# 1. Cargar y preparar los datos
# =============================================
# Cargar base de datos
data1 <- read.csv("bank.csv")
# Verificar estructura
str(data1)## 'data.frame': 41188 obs. of 20 variables:
## $ age : int 56 57 37 40 56 45 59 41 24 25 ...
## $ job : chr "housemaid" "services" "services" "admin." ...
## $ marital : chr "married" "married" "married" "married" ...
## $ education : chr "basic.4y" "high.school" "high.school" "basic.6y" ...
## $ default : chr "no" "unknown" "no" "no" ...
## $ housing : chr "no" "no" "yes" "no" ...
## $ loan : chr "no" "no" "no" "no" ...
## $ contact : chr "telephone" "telephone" "telephone" "telephone" ...
## $ month : chr "may" "may" "may" "may" ...
## $ day_of_week : chr "mon" "mon" "mon" "mon" ...
## $ campaign : int 1 1 1 1 1 1 1 1 1 1 ...
## $ pdays : int 999 999 999 999 999 999 999 999 999 999 ...
## $ previous : int 0 0 0 0 0 0 0 0 0 0 ...
## $ poutcome : chr "nonexistent" "nonexistent" "nonexistent" "nonexistent" ...
## $ emp.var.rate : num 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 ...
## $ cons.price.idx: num 94 94 94 94 94 ...
## $ cons.conf.idx : num -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 ...
## $ euribor3m : num 4.86 4.86 4.86 4.86 4.86 ...
## $ nr.employed : num 5191 5191 5191 5191 5191 ...
## $ y : chr "no" "no" "no" "no" ...
#=============================================================
# PREPARACIÓN DE VARIABLES
#=============================================================
# Variable respuesta:
# no = No suscribió depósito
# yes = Sí suscribió depósito
data1$y <- factor(data1$y, levels = c("no", "yes"), labels = c("No", "Sí"))
#=============================================================
# VARIABLES CATEGÓRICAS
#=============================================================
# Variables categóricas como factores
data1$job <- as.factor(data1$job)
data1$marital <- as.factor(data1$marital)
data1$education <- as.factor(data1$education)
data1$contact <- as.factor(data1$contact)
data1$poutcome <- as.factor(data1$poutcome)
#=============================================================
# VERIFICAR ESTRUCTURA
#=============================================================
str(data1)## 'data.frame': 41188 obs. of 20 variables:
## $ age : int 56 57 37 40 56 45 59 41 24 25 ...
## $ job : Factor w/ 12 levels "admin.","blue-collar",..: 4 8 8 1 8 8 1 2 10 8 ...
## $ marital : Factor w/ 4 levels "divorced","married",..: 2 2 2 2 2 2 2 2 3 3 ...
## $ education : Factor w/ 8 levels "basic.4y","basic.6y",..: 1 4 4 2 4 3 6 8 6 4 ...
## $ default : chr "no" "unknown" "no" "no" ...
## $ housing : chr "no" "no" "yes" "no" ...
## $ loan : chr "no" "no" "no" "no" ...
## $ contact : Factor w/ 2 levels "cellular","telephone": 2 2 2 2 2 2 2 2 2 2 ...
## $ month : chr "may" "may" "may" "may" ...
## $ day_of_week : chr "mon" "mon" "mon" "mon" ...
## $ campaign : int 1 1 1 1 1 1 1 1 1 1 ...
## $ pdays : int 999 999 999 999 999 999 999 999 999 999 ...
## $ previous : int 0 0 0 0 0 0 0 0 0 0 ...
## $ poutcome : Factor w/ 3 levels "failure","nonexistent",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ emp.var.rate : num 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 ...
## $ cons.price.idx: num 94 94 94 94 94 ...
## $ cons.conf.idx : num -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 -36.4 ...
## $ euribor3m : num 4.86 4.86 4.86 4.86 4.86 ...
## $ nr.employed : num 5191 5191 5191 5191 5191 ...
## $ y : Factor w/ 2 levels "No","Sí": 1 1 1 1 1 1 1 1 1 1 ...
#=============================================================
# VISUALIZACIÓN DE LOS DATOS
#=============================================================
#-------------------------------------------------------------
# Gráfico 1: Edad vs Euribor según suscripción
#-------------------------------------------------------------
ggplot(data1,
aes(x = age,
y = euribor3m,
color = y)) +
geom_point(alpha = 0.5) +
scale_color_manual(values = c("red", "darkgreen"),
labels = c("No suscribió",
"Sí suscribió"),
name = "Suscripción") +
labs(title = "Edad y tasa Euribor según suscripción",
x = "Edad",
y = "Euribor 3 meses") +
theme_minimal(base_size = 14)#-------------------------------------------------------------
# Gráfico 2: Número de contactos vs contactos previos
#-------------------------------------------------------------
ggplot(data1,
aes(x = campaign,
y = previous,
color = y)) +
geom_point(alpha = 0.5) +
scale_color_manual(values = c("red", "darkgreen"),
labels = c("No suscribió",
"Sí suscribió"),
name = "Suscripción") +
labs(title = "Campaña actual vs contactos previos",
x = "Número de contactos actuales",
y = "Contactos previos") +
theme_minimal(base_size = 14)#=============================================================
# Calcular odds de suscripción
#=============================================================
# Tabla de proporciones
prop1 <- prop.table(table(data1$y))
prop1##
## No Sí
## 0.8873458 0.1126542
## Sí
## 0.1269563
• Modelo estadístico para clasificación binaria. • Predice probabilidades de “sí” o “no”. • Alta interpretabilidad mediante Odds Ratios. • Permite identificar variables significativas.
modelo_logit <- glm(y ~ age + job + marital + education + campaign + previous + euribor3m + emp.var.rate + cons.conf.idx +
contact + poutcome, data = data1, family = binomial)##
## Call:
## glm(formula = y ~ age + job + marital + education + campaign +
## previous + euribor3m + emp.var.rate + cons.conf.idx + contact +
## poutcome, family = binomial, data = data1)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.953600 0.301615 3.162 0.00157 **
## age 0.002091 0.002067 1.011 0.31181
## jobblue-collar -0.298109 0.067228 -4.434 9.24e-06 ***
## jobentrepreneur -0.138288 0.105823 -1.307 0.19129
## jobhousemaid -0.074137 0.124635 -0.595 0.55196
## jobmanagement -0.091699 0.073249 -1.252 0.21062
## jobretired 0.360589 0.091318 3.949 7.86e-05 ***
## jobself-employed -0.071970 0.099047 -0.727 0.46746
## jobservices -0.211645 0.073499 -2.880 0.00398 **
## jobstudent 0.331437 0.097435 3.402 0.00067 ***
## jobtechnician -0.059750 0.060277 -0.991 0.32156
## jobunemployed 0.040707 0.108305 0.376 0.70702
## jobunknown -0.152713 0.204112 -0.748 0.45435
## maritalmarried 0.023783 0.058584 0.406 0.68477
## maritalsingle 0.133575 0.066441 2.010 0.04439 *
## maritalunknown 0.236734 0.356850 0.663 0.50707
## educationbasic.6y 0.050527 0.101821 0.496 0.61973
## educationbasic.9y -0.066986 0.080549 -0.832 0.40563
## educationhigh.school 0.010892 0.078026 0.140 0.88898
## educationilliterate 0.821833 0.667323 1.232 0.21812
## educationprofessional.course 0.076475 0.086009 0.889 0.37392
## educationuniversity.degree 0.143134 0.077861 1.838 0.06601 .
## educationunknown 0.183701 0.102515 1.792 0.07314 .
## campaign -0.053943 0.009444 -5.712 1.12e-08 ***
## previous 0.245251 0.052435 4.677 2.91e-06 ***
## euribor3m -0.584539 0.038520 -15.175 < 2e-16 ***
## emp.var.rate 0.161650 0.041020 3.941 8.12e-05 ***
## cons.conf.idx 0.046058 0.003571 12.897 < 2e-16 ***
## contacttelephone -0.430288 0.047101 -9.135 < 2e-16 ***
## poutcomenonexistent 0.741229 0.084133 8.810 < 2e-16 ***
## poutcomesuccess 1.909005 0.075996 25.120 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 28999 on 41187 degrees of freedom
## Residual deviance: 23672 on 41157 degrees of freedom
## AIC: 23734
##
## Number of Fisher Scoring iterations: 6
#=============================================================
# ODDS RATIOS
#=============================================================
odds_ratios <- exp(coef(modelo_logit))
odds_ratios## (Intercept) age
## 2.5950355 1.0020931
## jobblue-collar jobentrepreneur
## 0.7422207 0.8708481
## jobhousemaid jobmanagement
## 0.9285449 0.9123801
## jobretired jobself-employed
## 1.4341738 0.9305592
## jobservices jobstudent
## 0.8092517 1.3929680
## jobtechnician jobunemployed
## 0.9420000 1.0415474
## jobunknown maritalmarried
## 0.8583758 1.0240678
## maritalsingle maritalunknown
## 1.1429069 1.2671044
## educationbasic.6y educationbasic.9y
## 1.0518252 0.9352085
## educationhigh.school educationilliterate
## 1.0109514 2.2746658
## educationprofessional.course educationuniversity.degree
## 1.0794753 1.1538843
## educationunknown campaign
## 1.2016570 0.9474858
## previous euribor3m
## 1.2779420 0.5573625
## emp.var.rate cons.conf.idx
## 1.1754488 1.0471349
## contacttelephone poutcomenonexistent
## 0.6503220 2.0985125
## poutcomesuccess
## 6.7463727
#=============================================================
# INTERVALOS DE CONFIANZA
#=============================================================
exp(confint(modelo_logit))## 2.5 % 97.5 %
## (Intercept) 1.4362099 4.6851169
## age 0.9980363 1.0061574
## jobblue-collar 0.6504480 0.8465873
## jobentrepreneur 0.7048930 1.0675931
## jobhousemaid 0.7239646 1.1804165
## jobmanagement 0.7894163 1.0520499
## jobretired 1.1984085 1.7142717
## jobself-employed 0.7639275 1.1265938
## jobservices 0.6999212 0.9336978
## jobstudent 1.1495888 1.6844221
## jobtechnician 0.8367115 1.0597466
## jobunemployed 0.8396952 1.2840776
## jobunknown 0.5674800 1.2649669
## maritalmarried 0.9138111 1.1497623
## maritalsingle 1.0040309 1.3027906
## maritalunknown 0.6013633 2.4576732
## educationbasic.6y 0.8602793 1.2825060
## educationbasic.9y 0.7988776 1.0955659
## educationhigh.school 0.8680799 1.1787175
## educationilliterate 0.5317163 7.6155211
## educationprofessional.course 0.9122043 1.2780134
## educationuniversity.degree 0.9912318 1.3450605
## educationunknown 0.9819735 1.4678087
## campaign 0.9297827 0.9648405
## previous 1.1536887 1.4170674
## euribor3m 0.5168264 0.6010713
## emp.var.rate 1.0846561 1.2738836
## cons.conf.idx 1.0398305 1.0544899
## contacttelephone 0.5927530 0.7129650
## poutcomenonexistent 1.7815799 2.4777762
## poutcomesuccess 5.8160270 7.8346308
#=============================================================
# PREDICCIONES
#=============================================================
probabilidades <- predict(modelo_logit, type = "response")
head(probabilidades)## 1 2 3 4 5 6
## 0.04476810 0.03973472 0.03816944 0.04883455 0.03965501 0.03598679
#=============================================================
# CLASIFICACIÓN
#=============================================================
predicciones <- ifelse(probabilidades > 0.5, "Sí", "No")
predicciones <- factor(predicciones, levels = c("No", "Sí"))
#=============================================================
# VARIABLES SIGNIFICATIVAS
#=============================================================
summary(modelo_logit)$coefficients## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.953600183 0.301614677 3.1616505 1.568777e-03
## age 0.002090947 0.002067310 1.0114336 3.118089e-01
## jobblue-collar -0.298108662 0.067228435 -4.4342645 9.238716e-06
## jobentrepreneur -0.138287704 0.105823177 -1.3067809 1.912871e-01
## jobhousemaid -0.074136504 0.124635396 -0.5948270 5.519591e-01
## jobmanagement -0.091698638 0.073249470 -1.2518676 2.106181e-01
## jobretired 0.360588901 0.091318144 3.9487103 7.857336e-05
## jobself-employed -0.071969622 0.099046978 -0.7266211 4.674581e-01
## jobservices -0.211645344 0.073499109 -2.8795634 3.982262e-03
## jobstudent 0.331436728 0.097435035 3.4016176 6.698830e-04
## jobtechnician -0.059749968 0.060277302 -0.9912515 3.215628e-01
## jobunemployed 0.040707484 0.108304765 0.3758605 7.070206e-01
## jobunknown -0.152713254 0.204111901 -0.7481840 4.543492e-01
## maritalmarried 0.023782704 0.058584286 0.4059571 6.847742e-01
## maritalsingle 0.133574896 0.066441258 2.0104209 4.438666e-02
## maritalunknown 0.236734286 0.356850059 0.6633999 5.070745e-01
## educationbasic.6y 0.050526899 0.101821084 0.4962322 6.197306e-01
## educationbasic.9y -0.066985765 0.080548818 -0.8316170 4.056252e-01
## educationhigh.school 0.010891864 0.078025661 0.1395934 8.889813e-01
## educationilliterate 0.821833123 0.667322622 1.2315379 2.181217e-01
## educationprofessional.course 0.076475110 0.086009074 0.8891517 3.739216e-01
## educationuniversity.degree 0.143133903 0.077860672 1.8383338 6.601324e-02
## educationunknown 0.183701429 0.102515422 1.7919395 7.314267e-02
## campaign -0.053943306 0.009444151 -5.7118214 1.117734e-08
## previous 0.245250954 0.052434748 4.6772601 2.907334e-06
## euribor3m -0.584539363 0.038520029 -15.1749461 5.182029e-52
## emp.var.rate 0.161650025 0.041020134 3.9407484 8.122780e-05
## cons.conf.idx 0.046057767 0.003571149 12.8971852 4.668399e-38
## contacttelephone -0.430287694 0.047100836 -9.1354578 6.513063e-20
## poutcomenonexistent 0.741228767 0.084132707 8.8102332 1.248858e-18
## poutcomesuccess 1.909004983 0.075995667 25.1199188 3.013605e-139
#=============================================================
# IMPORTANCIA ESTADÍSTICA
#=============================================================
# Variables con p-value < 0.05
coeficientes <- summary(modelo_logit)$coefficients
variables_sig <- coeficientes[coeficientes[,4] < 0.05, ]
variables_sig## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.95360018 0.301614677 3.161650 1.568777e-03
## jobblue-collar -0.29810866 0.067228435 -4.434264 9.238716e-06
## jobretired 0.36058890 0.091318144 3.948710 7.857336e-05
## jobservices -0.21164534 0.073499109 -2.879563 3.982262e-03
## jobstudent 0.33143673 0.097435035 3.401618 6.698830e-04
## maritalsingle 0.13357490 0.066441258 2.010421 4.438666e-02
## campaign -0.05394331 0.009444151 -5.711821 1.117734e-08
## previous 0.24525095 0.052434748 4.677260 2.907334e-06
## euribor3m -0.58453936 0.038520029 -15.174946 5.182029e-52
## emp.var.rate 0.16165003 0.041020134 3.940748 8.122780e-05
## cons.conf.idx 0.04605777 0.003571149 12.897185 4.668399e-38
## contacttelephone -0.43028769 0.047100836 -9.135458 6.513063e-20
## poutcomenonexistent 0.74122877 0.084132707 8.810233 1.248858e-18
## poutcomesuccess 1.90900498 0.075995667 25.119919 3.013605e-139
• Modelo estadístico para clasificación binaria. • Predice probabilidades de “sí” o “no”. • Alta interpretabilidad mediante Odds Ratios. • Permite identificar variables significativas.
modelo_logit <- glm(y ~ age + job + marital + education + campaign + previous + euribor3m + emp.var.rate + cons.conf.idx +
contact + poutcome, data = data1, family = binomial)##
## Call:
## glm(formula = y ~ age + job + marital + education + campaign +
## previous + euribor3m + emp.var.rate + cons.conf.idx + contact +
## poutcome, family = binomial, data = data1)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.953600 0.301615 3.162 0.00157 **
## age 0.002091 0.002067 1.011 0.31181
## jobblue-collar -0.298109 0.067228 -4.434 9.24e-06 ***
## jobentrepreneur -0.138288 0.105823 -1.307 0.19129
## jobhousemaid -0.074137 0.124635 -0.595 0.55196
## jobmanagement -0.091699 0.073249 -1.252 0.21062
## jobretired 0.360589 0.091318 3.949 7.86e-05 ***
## jobself-employed -0.071970 0.099047 -0.727 0.46746
## jobservices -0.211645 0.073499 -2.880 0.00398 **
## jobstudent 0.331437 0.097435 3.402 0.00067 ***
## jobtechnician -0.059750 0.060277 -0.991 0.32156
## jobunemployed 0.040707 0.108305 0.376 0.70702
## jobunknown -0.152713 0.204112 -0.748 0.45435
## maritalmarried 0.023783 0.058584 0.406 0.68477
## maritalsingle 0.133575 0.066441 2.010 0.04439 *
## maritalunknown 0.236734 0.356850 0.663 0.50707
## educationbasic.6y 0.050527 0.101821 0.496 0.61973
## educationbasic.9y -0.066986 0.080549 -0.832 0.40563
## educationhigh.school 0.010892 0.078026 0.140 0.88898
## educationilliterate 0.821833 0.667323 1.232 0.21812
## educationprofessional.course 0.076475 0.086009 0.889 0.37392
## educationuniversity.degree 0.143134 0.077861 1.838 0.06601 .
## educationunknown 0.183701 0.102515 1.792 0.07314 .
## campaign -0.053943 0.009444 -5.712 1.12e-08 ***
## previous 0.245251 0.052435 4.677 2.91e-06 ***
## euribor3m -0.584539 0.038520 -15.175 < 2e-16 ***
## emp.var.rate 0.161650 0.041020 3.941 8.12e-05 ***
## cons.conf.idx 0.046058 0.003571 12.897 < 2e-16 ***
## contacttelephone -0.430288 0.047101 -9.135 < 2e-16 ***
## poutcomenonexistent 0.741229 0.084133 8.810 < 2e-16 ***
## poutcomesuccess 1.909005 0.075996 25.120 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 28999 on 41187 degrees of freedom
## Residual deviance: 23672 on 41157 degrees of freedom
## AIC: 23734
##
## Number of Fisher Scoring iterations: 6
#=============================================================
# ODDS RATIOS
#=============================================================
odds_ratios <- exp(coef(modelo_logit))
odds_ratios## (Intercept) age
## 2.5950355 1.0020931
## jobblue-collar jobentrepreneur
## 0.7422207 0.8708481
## jobhousemaid jobmanagement
## 0.9285449 0.9123801
## jobretired jobself-employed
## 1.4341738 0.9305592
## jobservices jobstudent
## 0.8092517 1.3929680
## jobtechnician jobunemployed
## 0.9420000 1.0415474
## jobunknown maritalmarried
## 0.8583758 1.0240678
## maritalsingle maritalunknown
## 1.1429069 1.2671044
## educationbasic.6y educationbasic.9y
## 1.0518252 0.9352085
## educationhigh.school educationilliterate
## 1.0109514 2.2746658
## educationprofessional.course educationuniversity.degree
## 1.0794753 1.1538843
## educationunknown campaign
## 1.2016570 0.9474858
## previous euribor3m
## 1.2779420 0.5573625
## emp.var.rate cons.conf.idx
## 1.1754488 1.0471349
## contacttelephone poutcomenonexistent
## 0.6503220 2.0985125
## poutcomesuccess
## 6.7463727
#=============================================================
# INTERVALOS DE CONFIANZA
#=============================================================
exp(confint(modelo_logit))## 2.5 % 97.5 %
## (Intercept) 1.4362099 4.6851169
## age 0.9980363 1.0061574
## jobblue-collar 0.6504480 0.8465873
## jobentrepreneur 0.7048930 1.0675931
## jobhousemaid 0.7239646 1.1804165
## jobmanagement 0.7894163 1.0520499
## jobretired 1.1984085 1.7142717
## jobself-employed 0.7639275 1.1265938
## jobservices 0.6999212 0.9336978
## jobstudent 1.1495888 1.6844221
## jobtechnician 0.8367115 1.0597466
## jobunemployed 0.8396952 1.2840776
## jobunknown 0.5674800 1.2649669
## maritalmarried 0.9138111 1.1497623
## maritalsingle 1.0040309 1.3027906
## maritalunknown 0.6013633 2.4576732
## educationbasic.6y 0.8602793 1.2825060
## educationbasic.9y 0.7988776 1.0955659
## educationhigh.school 0.8680799 1.1787175
## educationilliterate 0.5317163 7.6155211
## educationprofessional.course 0.9122043 1.2780134
## educationuniversity.degree 0.9912318 1.3450605
## educationunknown 0.9819735 1.4678087
## campaign 0.9297827 0.9648405
## previous 1.1536887 1.4170674
## euribor3m 0.5168264 0.6010713
## emp.var.rate 1.0846561 1.2738836
## cons.conf.idx 1.0398305 1.0544899
## contacttelephone 0.5927530 0.7129650
## poutcomenonexistent 1.7815799 2.4777762
## poutcomesuccess 5.8160270 7.8346308
#=============================================================
# PREDICCIONES
#=============================================================
probabilidades <- predict(modelo_logit, type = "response")
head(probabilidades)## 1 2 3 4 5 6
## 0.04476810 0.03973472 0.03816944 0.04883455 0.03965501 0.03598679
#=============================================================
# CLASIFICACIÓN
#=============================================================
predicciones <- ifelse(probabilidades > 0.5, "Sí", "No")
predicciones <- factor(predicciones, levels = c("No", "Sí"))
#=============================================================
# VARIABLES SIGNIFICATIVAS
#=============================================================
summary(modelo_logit)$coefficients## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.953600183 0.301614677 3.1616505 1.568777e-03
## age 0.002090947 0.002067310 1.0114336 3.118089e-01
## jobblue-collar -0.298108662 0.067228435 -4.4342645 9.238716e-06
## jobentrepreneur -0.138287704 0.105823177 -1.3067809 1.912871e-01
## jobhousemaid -0.074136504 0.124635396 -0.5948270 5.519591e-01
## jobmanagement -0.091698638 0.073249470 -1.2518676 2.106181e-01
## jobretired 0.360588901 0.091318144 3.9487103 7.857336e-05
## jobself-employed -0.071969622 0.099046978 -0.7266211 4.674581e-01
## jobservices -0.211645344 0.073499109 -2.8795634 3.982262e-03
## jobstudent 0.331436728 0.097435035 3.4016176 6.698830e-04
## jobtechnician -0.059749968 0.060277302 -0.9912515 3.215628e-01
## jobunemployed 0.040707484 0.108304765 0.3758605 7.070206e-01
## jobunknown -0.152713254 0.204111901 -0.7481840 4.543492e-01
## maritalmarried 0.023782704 0.058584286 0.4059571 6.847742e-01
## maritalsingle 0.133574896 0.066441258 2.0104209 4.438666e-02
## maritalunknown 0.236734286 0.356850059 0.6633999 5.070745e-01
## educationbasic.6y 0.050526899 0.101821084 0.4962322 6.197306e-01
## educationbasic.9y -0.066985765 0.080548818 -0.8316170 4.056252e-01
## educationhigh.school 0.010891864 0.078025661 0.1395934 8.889813e-01
## educationilliterate 0.821833123 0.667322622 1.2315379 2.181217e-01
## educationprofessional.course 0.076475110 0.086009074 0.8891517 3.739216e-01
## educationuniversity.degree 0.143133903 0.077860672 1.8383338 6.601324e-02
## educationunknown 0.183701429 0.102515422 1.7919395 7.314267e-02
## campaign -0.053943306 0.009444151 -5.7118214 1.117734e-08
## previous 0.245250954 0.052434748 4.6772601 2.907334e-06
## euribor3m -0.584539363 0.038520029 -15.1749461 5.182029e-52
## emp.var.rate 0.161650025 0.041020134 3.9407484 8.122780e-05
## cons.conf.idx 0.046057767 0.003571149 12.8971852 4.668399e-38
## contacttelephone -0.430287694 0.047100836 -9.1354578 6.513063e-20
## poutcomenonexistent 0.741228767 0.084132707 8.8102332 1.248858e-18
## poutcomesuccess 1.909004983 0.075995667 25.1199188 3.013605e-139
#=============================================================
# IMPORTANCIA ESTADÍSTICA
#=============================================================
# Variables con p-value < 0.05
coeficientes <- summary(modelo_logit)$coefficients
variables_sig <- coeficientes[coeficientes[,4] < 0.05, ]
variables_sig## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.95360018 0.301614677 3.161650 1.568777e-03
## jobblue-collar -0.29810866 0.067228435 -4.434264 9.238716e-06
## jobretired 0.36058890 0.091318144 3.948710 7.857336e-05
## jobservices -0.21164534 0.073499109 -2.879563 3.982262e-03
## jobstudent 0.33143673 0.097435035 3.401618 6.698830e-04
## maritalsingle 0.13357490 0.066441258 2.010421 4.438666e-02
## campaign -0.05394331 0.009444151 -5.711821 1.117734e-08
## previous 0.24525095 0.052434748 4.677260 2.907334e-06
## euribor3m -0.58453936 0.038520029 -15.174946 5.182029e-52
## emp.var.rate 0.16165003 0.041020134 3.940748 8.122780e-05
## cons.conf.idx 0.04605777 0.003571149 12.897185 4.668399e-38
## contacttelephone -0.43028769 0.047100836 -9.135458 6.513063e-20
## poutcomenonexistent 0.74122877 0.084132707 8.810233 1.248858e-18
## poutcomesuccess 1.90900498 0.075995667 25.119919 3.013605e-139