library(readr)
data <- read_csv("Downloads/Loan_Approval_Dataset.csv")
## Rows: 4269 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Loan_Status, Education, Self_Employed
## dbl (3): Income, Loan_Amount, Cibil_Score
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(data)
data$Loan_Status_Bin <- ifelse(data$Loan_Status == "Approved", 1, 0)
data$Education <- as.factor(data$Education)
data$Self_Employed <- as.factor(data$Self_Employed)
modelo <- glm(Loan_Status_Bin ~ Income + Loan_Amount + Cibil_Score + Education + Self_Employed,
data = data,
family = binomial(link = "logit"))
summary(modelo)
##
## Call:
## glm(formula = Loan_Status_Bin ~ Income + Loan_Amount + Cibil_Score +
## Education + Self_Employed, family = binomial(link = "logit"),
## data = data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.163e+01 4.019e-01 -28.939 < 2e-16 ***
## Income -4.036e-07 5.502e-08 -7.337 2.18e-13 ***
## Loan_Amount 1.320e-07 1.706e-08 7.734 1.04e-14 ***
## Cibil_Score 2.214e-02 7.137e-04 31.019 < 2e-16 ***
## EducationNot Graduate -7.118e-02 1.118e-01 -0.637 0.524
## Self_EmployedYes 5.635e-02 1.118e-01 0.504 0.614
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 5660.7 on 4268 degrees of freedom
## Residual deviance: 2088.2 on 4263 degrees of freedom
## AIC: 2100.2
##
## Number of Fisher Scoring iterations: 7
coefs <- summary(modelo)$coefficients
# Tabla
tabla_mod <- data.frame(
Termino = rownames(coefs),
Logit = round(coefs[, "Estimate"], 3),
Odds_Ratio = round(exp(coefs[, "Estimate"]), 3),
row.names = NULL,
check.names = FALSE
)
tabla_mod
## Termino Logit Odds_Ratio
## 1 (Intercept) -11.631 0.000
## 2 Income 0.000 1.000
## 3 Loan_Amount 0.000 1.000
## 4 Cibil_Score 0.022 1.022
## 5 EducationNot Graduate -0.071 0.931
## 6 Self_EmployedYes 0.056 1.058
-Intercepto: situación base cuando todas las variables son constantes, cuando su ingreso, puntuación de crédito son 0. -Income y Loan_Amount: el odds ratio de estas dos variables son 1, indicando que el factor de estudio es neutral. -Cibil_Score: cada punto adicional que aumenta el puntaje crediticio, aumenta un 2.2% de probabilidad de un préstamo ser aprobado. -Self_EmployedYes: al trabajar por propia cuenta, aumenta en %5.8 la probabilidad de la aprobación del préstamo respecto a no trabajar por cuenta propia, manteniendo las demás variables constantes. -Education Not Graduate: al no ser graduado disminuye %6.9 la probabilidad de la aprobación del préstamo respecto a ser graduado, manteniendo las demás variables constantes. -A pesar de los resultados, las variables Education Not Graduate y Self_EmployedYes mostraron ser no significativas en el modelo ya que no hay suficiente evidencia estadística para comprobar su influencia a la aprobación del préstamo.