- Business & Data Research
- Posts
- Credit Risk Rating using R Program
Credit Risk Rating using R Program
Risk Rating Analysis - Financial Data
Credit Risk Rating Performance Descriptive Statistics:
Credit risk rating analysis is the process of evaluating a borrower’s ability to repay debt and assigning a risk grade or score that reflects the likelihood of default. It helps lenders, investors, and institutions make informed decisions about extending credit.
Step 1: Required Packages
library(dplyr)
library(tidyverse)
library(ggplot2)
install.packages("ggthemes")
library(ggthemes)
Step 2: Load the Dataset
loan <- read.csv('/Users/Sample Datasets Kaggle/dataset.csv', header = TRUE)
View(loan)
str(loan)

Step 3: Install additional libraries gmodels and ensure gtools is properly installed in your local environment
library(gtools)
install.packages("gmodels")
library(gmodels)
Step 4: Using CrossTable, check the loan status of the existing checking account



Step 5: Describing the loan status of the customers
hist_loan_status <- hist(loan$Duration.in.months,
main = "Histogram of Status of Existing Checking Account",
xlab = "Status of Existing Checking Account",
ylab = "Frequency",
col = "lightblue",
border = "black"
hist_loan_2 <- hist(loan$Credit.amount,
main = "Histogram of Credit Amount",
xlab = "Credit Amount",
ylab = "Frequency",
col = "lightgreen",
border = "black")


Step 6: Creation of a scatter plot based on Age vs amount credited

Step 6.1: Identify the outlier just to check how much the amount is credited based on the age
# Identify the index of rows where Age is greater than 60
index_high_age <- which(loan$Age.in.years > 60)
# Print the rows with Age greater than 60
index_high_age
newdata <- loan[-index_high_age, ]
