Overview

In this presentation we will be looking at some loan data found on: kaggle.com We will be looking at answering a few questions like:

  • What is a summary of the loans dataset?
  • Code for graphs
  • How many loans were paid off based on the different types of terms?
  • How does education level affect the likelihood of a loan being paid off?
  • How gender affects loans being paid off
  • How gender affects loans not being paid off
  • Example of how to calculate monthly payment of a loan
  • How much will you pay over the lifetime of the loan?

What is a summary of the loans dataset?

Here is a summary of my Loans dataset:

##    Loan_ID          loan_status          Principal          terms      
##  Length:500         Length:500         Min.   : 300.0   Min.   : 7.00  
##  Class :character   Class :character   1st Qu.:1000.0   1st Qu.:15.00  
##  Mode  :character   Mode  :character   Median :1000.0   Median :30.00  
##                                        Mean   : 943.2   Mean   :22.82  
##                                        3rd Qu.:1000.0   3rd Qu.:30.00  
##                                        Max.   :1000.0   Max.   :30.00  
##                                                                        
##  effective_date       due_date         paid_off_time      past_due_days  
##  Length:500         Length:500         Length:500         Min.   : 1.00  
##  Class :character   Class :character   Class :character   1st Qu.: 3.00  
##  Mode  :character   Mode  :character   Mode  :character   Median :37.00  
##                                                           Mean   :36.01  
##                                                           3rd Qu.:60.00  
##                                                           Max.   :76.00  
##                                                           NA's   :300    
##       age         education            Gender         
##  Min.   :18.00   Length:500         Length:500        
##  1st Qu.:27.00   Class :character   Class :character  
##  Median :30.00   Mode  :character   Mode  :character  
##  Mean   :31.12                                        
##  3rd Qu.:35.00                                        
##  Max.   :51.00                                        
## 

Code

# Filter the data to only include loans paid off
was_paid <- subset(loan_data, loan_status == "PAIDOFF" | loan_status == "COLLECTION_PAIDOFF")

# Filter the data to only include loans not paid off
was_not_paid <- subset(loan_data, loan_status == "COLLECTION")

# Summarize data by terms and count the number of paid off loans
paid_off_count <- was_paid %>%
  group_by(terms) %>%
  summarise(paid_off = n())

# Summarize data by terms and count the number of not paid off loans
not_paid_off_count <- was_not_paid %>%
  group_by(terms) %>%
  summarise(not_paid_off = n())

# Create plot for paid off loans
p1 <- ggplot(paid_off_count, aes(x = as.factor(terms), y = paid_off)) +
  geom_col(fill = "blue") +
  labs(title = "Paid Off Loans", x = "Terms", y = "Count") +
  scale_x_discrete(labels = c("7", "15", "30"))

# Create plot for non paid off loans
p2 <- ggplot(not_paid_off_count, aes(x = as.factor(terms), y = not_paid_off)) +
  geom_col(fill = "red") +
  labs(title = "Not Paid Off Loans", x = "Terms", y = "Count") +
  scale_x_discrete(labels = c("7", "15", "30"))

How many loans were paid off based on the different types of terms?

How does education level affect the likelihood of a loan being paid off?

How gender affects loans being paid off

How gender affects loans not being paid off

Example of how to calculate monthly payment of a loan

\(\frac{{\text{Principle}(InterestRate/12)}}{{1-(1+(InterestRate/12)^{-12*Term}})}\)

Lets calculate one:

Principle = $600,000

Interest Rate = 6%

Loan term = 30 years

\(\frac{600000 \left(\frac{0.06}{12}\right)}{1 - \left(1 + \left(\frac{0.06}{12}\right)^{-12 \times 30}\right)} = \$3,597.30\)

How much will you pay over the lifetime of the loan?

\(MonthlyPayment \times 12 \times Term\)

Montly Payment = $3,597.30

Term = 30 years

\(3597.30 \times 12 \times 30 = \$1,295,028\)