Peer-to-peer lending in areas of Yorkshire

For background and methodology please visit: smtm.labs.theodi.org.

This document was written in R Markdown. You can ignore the first lines of syntax that loads the data.

setwd("~/Desktop/p2p/"); library(data.table); load("~/Google Drive/Projects/BoE/Data/Peer-to-peer/p2p-combined.Rdata") 

# Lenders
setkey(p2p, area.len); yo.len <- p2p[c("S", "LS", "YO", "BD", "HU")]; saveRDS(yo.len, file="yo-len.RData")

# Recipients
setkey(p2p, area.bor); yo.rec <- p2p[c("S", "LS", "YO", "BD", "HU")]; saveRDS(yo.rec, file="yo-rec.RData")
library(data.table)
library(plyr)
yo.rec <- readRDS("~/Desktop/p2p/yo-rec.RData")
yo.len <- readRDS("~/Desktop/p2p/yo-len.RData")

Here is the total loan amount for lenders and recipients.

Lenders
Total sum: £13,901,531

yo.len[, paste0("£", prettyNum(sum(loan.part.value), big.mark = ",")), by = area.len]
##    area.len         V1
## 1:        S £4,532,275
## 2:       LS £3,313,757
## 3:       YO £3,461,888
## 4:       BD £1,551,314
## 5:       HU £1,042,297

Recipients
Total sum: £21,392,989

yo.rec[, paste0("£", prettyNum(sum(loan.part.value), big.mark = ",")), by = area.bor]
##    area.bor         V1
## 1:        S £7,709,486
## 2:       LS £5,301,223
## 3:       YO £3,120,698
## 4:       BD £3,048,481
## 5:       HU £2,213,101

Here is the average loan amount for lenders and recipients.

loans.len <- yo.len[, list(area.len = area.len[1], total.loans = sum(loan.part.value), 
    no.loan.parts = length(loan.part.value)), by = postcode.len]
loans.rec <- yo.rec[, list(area.bor = area.bor[1], total.loans = sum(loan.part.value), 
    no.loan.parts = length(loan.part.value)), by = loan.id]

# Lenders in £
ddply(loans.len, .(area.len), function(x) summary(x$total.loans))
##   area.len Min. 1st Qu. Median Mean 3rd Qu.   Max.
## 1       BD   10     162    900 6520    5100 151000
## 2       HU   10     250   1040 4670    4790  62400
## 3       LS   10     220   1320 5170    5000 163000
## 4        S   10     288   1260 6440    4340 360000
## 5       YO   10     398   1690 7800    5480 273000

# Recipients in £
ddply(loans.rec, .(area.bor), function(x) summary(x$total.loans))
##   area.bor Min. 1st Qu. Median Mean 3rd Qu.   Max.
## 1       BD  199    3030   4130 5940    5190  98000
## 2       HU  146    3060   4130 5220    5120  98200
## 3       LS  103    3050   4160 6460    6000 294000
## 4        S  169    3060   4130 5170    5130  99600
## 5       YO  149    3110   4130 5440    5470  97700

Let's count the number of loans.

p.len <- loans.len[, list(no.of.loans = length(total.loans)), by = area.len]
p.rec <- loans.rec[, list(no.of.loans = length(total.loans)), by = area.bor]
library(ggplot2)
p.len
##    area.len no.of.loans
## 1:        S         704
## 2:       LS         641
## 3:       YO         444
## 4:       BD         238
## 5:       HU         223
ggplot(aes(factor(area.len), no.of.loans), data = p.len) + geom_bar(stat = "identity", 
    fill = "#558800", colour = "white") + theme_minimal() + ylab("Number of loans") + 
    xlab("Area Lender") + coord_flip() + ylim(0, 1500)

plot of chunk unnamed-chunk-5

p.rec
##    area.bor no.of.loans
## 1:        S        1490
## 2:       LS         820
## 3:       YO         574
## 4:       BD         513
## 5:       HU         424
ggplot(aes(factor(area.bor), no.of.loans), data = p.rec) + geom_bar(stat = "identity", 
    fill = "#990099", colour = "white") + theme_minimal() + ylab("Number of loans") + 
    xlab("Area Recipient") + coord_flip() + ylim(0, 1500)

plot of chunk unnamed-chunk-5