Introduction

In this analysis, we will build a predictive model to determine whether a loan will be approved or not based on various applicant attributes.

Load the Data

library(dplyr) library(ggplot2)

Load the data

application_data <- read.csv(“application_record.csv”)

Display representative portions of the data

head(application_data) summary(application_data)

Check for missing values

sum(is.na(application_data))

Remove rows with missing values

application_data <- na.omit(application_data)

Impute missing values with median

application_data\(Column_Name[is.na(application_data\)Column_Name)] <- median(application_data$Column_Name, na.rm = TRUE)

Handle outliers in Income column

boxplot(application_data\(Income) quantile_value <- quantile(application_data\)Income, 0.95) application_data\(Income <- ifelse(application_data\)Income > quantile_value, quantile_value, application_data$Income)

library(caret)

set.seed(123) # For reproducibility indexes <- createDataPartition(application_data$LoanApproved, p=0.7, list=FALSE) train_data <- application_data[indexes,] test_data <- application_data[-indexes,]

BUILD THE MODEL

model <- glm(LoanApproved ~ Income + Age + EmploymentStatus, family = binomial(link = “logit”), data = train_data) summary(model)

Predictions and Model Performance

predictions <- predict(model, test_data, type = “response”) predicted_class <- ifelse(predictions > 0.5, 1, 0) confusionMatrix(factor(predicted_class), factor(test_data$LoanApproved))

Gain and Lift Chart

library(InformationValue)

gain_lift <- gainLiftChart(predictions, test_data$LoanApproved)

library(car)

vif(model)

*Suggestions for Model Improvement -Consider feature engineering to create new predictors. -Experiment with different cutoff values for binary classification. -Try other modeling techniques like decision trees or random forests for comparison. -Use cross-validation to tune hyperparameters and validate model stability.