On 8 November 2016, the Government of India announced the demonetisation of all Rs500 and Rs1000 bank notes.The aim of this project was to irradicate the illicit counterfeit cash which was being used to fund terrorism and crack down on the shadow black economy.
This sudden announcement created a lot of mayhem .The government put a limit on the amount of money that could be deposited and withdrawn from banks all this resulted in long queues in banks and ATMS.Since cash was restricted people started using debit cards/credit cards more .In this analysis I want to analyse the trends on the search key words demonetisation,ATM,debit card,convert black money,bitcoin.
Lets load all libraries required
library(gtrendsR)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(reshape2)
library(ggplot2)
library(sp)
library(RColorBrewer)
Lets now query google trends API with our search key words
interest_by_time=google.trends$interest_over_time
interest_by_time %>% glimpse()
## Observations: 880
## Variables: 6
## $ date <date> 2004-01-01, 2004-02-01, 2004-03-01, 2004-04-01, 2004...
## $ hits <chr> "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"...
## $ keyword <chr> "demonetisation", "demonetisation", "demonetisation",...
## $ geo <chr> "IN", "IN", "IN", "IN", "IN", "IN", "IN", "IN", "IN",...
## $ gprop <chr> "web", "web", "web", "web", "web", "web", "web", "web...
## $ category <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
interest_by_time$hits<-as.numeric(interest_by_time$hits)
## Warning: NAs introduced by coercion
ggplot(aes(x = date, y = hits,color=keyword), data = interest_by_time) +
geom_line(size = 0.5)
## Warning: Removed 21 rows containing missing values (geom_path).
There seems to be a peak in these search terms somewhere near 2016.
Let us narrow it down further to the time about the demonetisation Nov 2016 . Let us examine the data more
#Lets narrow this to demon so say 2015 to 2017
narrower_gt=interest_by_time[which(interest_by_time$date>'2016-08-01' & interest_by_time$date<='2017-06-01'),]
ggplot(aes(x = date, y = hits,color=keyword), data = narrower_gt) +
geom_line(size = 0.5)
## Warning: Removed 11 rows containing missing values (geom_path).
interest_by_city=google.trends$interest_by_region
sub_region=google.trends$interest_by_region
This is pretty interesting the trends show that there is a massive increase in the ATM key word more likely because people wanted to know which ATMs had shorter queues and were still dispensing cash. People were interested in key word “demonetistation” . Also there is a sharp increase in searches for debit card this could be attributed to the need for digital payment methods rather than cash. Most interestingly the number of searches for bitcoin trended upwards after demonetisation.
It would be great if we could visually see this data on a map.For this let us first download the level1 maps for India from http://gadm.org/country
# load level 1 india data downloaded from http://gadm.org/country
ind1=readRDS("C:\\Users\\Subu\\Downloads\\gadm36_IND_1_sp.rds")
#plot(ind1, col = 'lightgrey', border = 'darkgrey')
Since I want to merge the spatial data with the google trends data on location I will need them to be exactly same.On further inspection I find some data isnt the same so I will need to clean them up.
sub_region[which(sub_region$location=='Andaman and Nicobar Islands'),]$location=c('Andaman and Nicobar')
sub_region[which(sub_region$location=='Delhi'),]$location=c('NCT of Delhi')
I merge the spatial data with the google trends on ‘NAME_1’ and ‘location’.To give my maps more color I have used the colorRampPalette from RColorBrewer library.
my.palette <- colorRampPalette(brewer.pal(8, "Blues"))(71)
sp.label <- function(x, label) {list("sp.text", coordinates(x), label,cex=0.5)}
df=merge(ind1,sub_region,by.x='NAME_1',by.y='location',duplicateGeoms=TRUE)
The below function plots the chorolopeth for each keyword.
Let us first see which parts of India were most interested in demonetisation.It seems Arunachal Pradesh in the North East of India was the most interested in knowing about demonetisation.
pl<-function(val){
s1=df[which(df$keyword==val,),]
spplot(s1, "hits", col.regions = my.palette,
cuts = length(my.palette)-1,
main=paste("Choropleth map of ",val),
sp.layout=sp.label(s1, s1$NAME_1))
}
pl('demonetisation')
Here again the north east belt seems to be more interested in finding ATMs .
my.palette <- colorRampPalette(brewer.pal(11, "Purples"))(71)
## Warning in brewer.pal(11, "Purples"): n too large, allowed maximum for palette Purples is 9
## Returning the palette you asked for with that many colors
pl('ATM')
All the south states seem very interested in debit cards and surprisingly Haryana up north
my.palette <- colorRampPalette(brewer.pal(8, "Reds"))(71)
pl('debit card')
This is really surprising the states of Punjab,Haryana ,Gujrat were most interested in bitcoins.Bitcoin adoption trend seems to be on its way up
my.palette <- colorRampPalette(brewer.pal(11, "Greens"))(71)
## Warning in brewer.pal(11, "Greens"): n too large, allowed maximum for palette Greens is 9
## Returning the palette you asked for with that many colors
pl('bitcoin')
##Interest in how to convert black money ## Gujrat-a state well known for its entrepreneurial spirit, small scale industry and jewellers.,Haryana a state which is top news-maker for its controversial real estate deals topped the google trends chart for finding ways to convert black money.I am not surprised
my.palette <- colorRampPalette(brewer.pal(8, "Oranges"))(71)
pl('convert black money')