Created
May 1, 2016 21:21
-
-
Save rshyam1/1c841264a26708d32ebd66b7c7df594a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Calculating monthly default rate from April 2005 to September 2005 | |
default_rate=vector(length=6) | |
names(default_rate)= c("April 2005","May 2005","June 2005","July 2005","August 2005","September 2005") | |
c("April 2005","May 2005","June 2005","July 2005","August 2005","September 2005") | |
default_rate[6]= percent(nrow(filter(credi_tbl_temp,PAY_0 > 2 ))/total_rows) | |
default_rate[5]= percent(nrow(filter(credi_tbl_temp,PAY_2 > 2 ))/total_rows) | |
default_rate[4]= percent(nrow(filter(credi_tbl_temp,PAY_3 > 2 ))/total_rows) | |
default_rate[3]= percent(nrow(filter(credi_tbl_temp,PAY_4 > 2 ))/total_rows) | |
default_rate[2]= percent(nrow(filter(credi_tbl_temp,PAY_5 > 2 ))/total_rows) | |
default_rate[1]= percent(nrow(filter(credi_tbl_temp,PAY_6 > 2 ))/total_rows) | |
#Separating months names | |
months_name=names(default_rate) | |
names(default_rate)= c("04-2005","05-2005","06-2005","07-2005","08-2005","09-2005") | |
#c("April 2005","May 2005","June 2005","July 2005","August 2005","September 2005") | |
# Plot of Default(rate)=default > 60 days vs months | |
data_rate = data.frame(months=months_name, default_rate=default_rate) | |
d=ggplot(data=data_rate,aes(x=months, y=default_rate)) | |
d1=d+geom_point()+ggtitle("Default rate(default payment > 2 months) Vs. Months")+ | |
xlab("Months")+ylab("Default Rate") | |
d1 | |
d2=d1+geom_point()+geom_line() | |
d2 | |
d3=ggplot(data=data_rate,aes(x=months, y=default_rate))+ geom_smooth(aes( se = FALSE)) | |
d3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment