Load Data

filepath <- file.choose()
Financial_Development_Database_2022 <- read_excel(filepath, sheet = "Data - August 2022")

Financial_Development_Database_2022_00_14 <- subset(Financial_Development_Database_2022, 
                                                    year >= 2000 & year <= 2014)

Question 3

Part i

Depth Indicator - DI01 - Private credit by deposit money banks to GDP (%):

Grouping by Region:

Financial_Development_Database_2022_00_14 %>% 
  group_by(region, year) %>% 
  summarize(Avg_Indicator = mean(di01, na.rm = TRUE), Observations = n()) %>%
  pivot_wider(names_from = region, values_from = c(Avg_Indicator, Observations)) -> region_table_di01
## `summarise()` has grouped output by 'region'. You can override using the
## `.groups` argument.
datatable(region_table_di01,options = list(scrollX = TRUE), caption = "Region Table for DI01")

Grouping by Income:

Financial_Development_Database_2022_00_14 %>% 
  group_by(income, year) %>% 
  summarize(Avg_Indicator = mean(di01, na.rm = TRUE), Observations = n()) %>%
  pivot_wider(names_from = income, values_from = c(Avg_Indicator, Observations)) -> income_table_di01
## `summarise()` has grouped output by 'income'. You can override using the
## `.groups` argument.
datatable(income_table_di01, options = list(scrollX = TRUE), caption = "Income Table for DI01")

Access Indicator - AI02 - Bank branches per 100,000 adults:

Grouping by Region:

Financial_Development_Database_2022_00_14 %>% 
  group_by(region, year) %>% 
  summarize(Avg_Indicator = mean(ai02, na.rm = TRUE), Observations = n()) %>%
  pivot_wider(names_from = region, values_from = c(Avg_Indicator, Observations)) -> region_table_ai02
## `summarise()` has grouped output by 'region'. You can override using the
## `.groups` argument.
datatable(region_table_ai02, options = list(scrollX = TRUE), caption = "Region Table for AI02 ")

Grouping by Income:

Financial_Development_Database_2022_00_14 %>% 
  group_by(income, year) %>% 
  summarize(Avg_Indicator = mean(ai02, na.rm = TRUE), Observations = n()) %>%
  pivot_wider(names_from = income, values_from = c(Avg_Indicator, Observations)) -> income_table_ai02
## `summarise()` has grouped output by 'income'. You can override using the
## `.groups` argument.
datatable(income_table_ai02, options = list(scrollX = TRUE), caption = "Income Table for AI02")

Part ii

DI01 - Region Line Chart:

region_table_di01 %>% 
  select(starts_with("Avg_Indicator"), year) %>% 
  pivot_longer(
    cols = starts_with("Avg_Indicator"), 
    names_to = "Region", 
    values_to = "Avg_Indicator"
  ) -> region_table_di01_long

linechart_di01_region <- ggplot(region_table_di01_long, aes(year, Avg_Indicator, colour = Region)) + 
  geom_line() + 
  geom_point() + 
  labs(
    title = "Average Indicator Value Across\n Regions Over Time", 
    x = "Year", 
    y = "Average Indicator Value"
  ) + 
  scale_x_continuous(breaks = seq(min(region_table_di01_long$year), max(region_table_di01_long$year), by = 1)) + 
   theme(
    legend.key.size = unit(0.5, "cm"),    
    legend.text = element_text(size = 8), 
    legend.title = element_text(size = 10),
    plot.title = element_text(hjust = 0.5),
    axis.title = element_text(size=10),
    axis.text = element_text(angle=45,size=8)
  )
ggplotly(linechart_di01_region)

AI02- Income Line Chart:

income_table_ai02 %>% 
  select(starts_with("Avg_Indicator"), year) %>% 
  pivot_longer(
    cols = starts_with("Avg_Indicator"), 
    names_to = "income", 
    values_to = "Avg_Indicator"
  ) -> income_table_ai02_long

linechart_ai02_income <- ggplot(income_table_ai02_long, aes(year, Avg_Indicator, colour = income)) + 
  geom_line() + 
  geom_point() + 
  labs(
    title = "Average Indicator Value Across\n Income Groups Over Time", 
    x = "Year", 
    y = "Average Indicator Value"
  ) + 
  scale_x_continuous(breaks = seq(min(income_table_ai02_long$year), max(income_table_ai02_long$year), by = 1)) + 
  theme(
    legend.key.size = unit(0.5, "cm"),    
    legend.text = element_text(size = 8), 
    legend.title = element_text(size = 10),
    plot.title = element_text(hjust = 0.5),
    axis.title = element_text(size=10),
    axis.text = element_text(angle=45,size=8)
  )
ggplotly(linechart_ai02_income)

Comments on Patterns Across Regions/Income Groups:

DI01 - Private credit by deposit money banks to GDP (%):

Region-Wise Trends: The percentage of private credit by deposit money banks to GDP (DI01) rose across regions from 2000 to 2008. The nature of which varied across regions. North America and Europe & Central Asia saw dramatic rates of increase, with rare hiccups or deacceleration, marking enormous growth in their financial sectors.

Other regions saw an overall increase but with a more steady rate of change. Also, there were downturns at specific periods that could be attributed to region-specific events. For example, in East Asia & Pacific, the effects of the Asian Financial Crisis lingered on in the early 2000s.

A significant inflexion point was in 2008, the year of the “Global” Financial Crisis. However, the impact was not uniform. North America saw a catastrophic decline in DI01, conveying that the crisis originated there. Since banks were only capable of lending at a lesser level, relative to the GDP, to the private sector. DI01 steadied near 2010 but did not recover to pre-crisis levels.

Europe & Central Asia witnessed a decline a year later, with a lesser but yet significant magnitude. The Eurozone Debt Crisis had begun, with the Global Financial Crisis partly being a reason. Since bank bail-outs led to high levels of sovereign debt. DI01 did not steady in Europe, and the decline continued post 2014.

A pertinent insight reveals how the financial interconnectedness of regions with North America influences the change in DI01. Other regions were, perhaps, not impacted as severely since their financial systems were relatively less integrated with North America. For example, South Asia saw an increase in private credit by deposit banks with respect to GDP. This led to the post-crisis years being different across regions.

AI02 - Bank branches per 100,000 adults:

Income-Wise Trends: Low and middle-income economies face an overall increase in the availability of per capita bank branches (AI02). AI02 grows at a slight rate for the low-income group, with per capita availability being starkly lower. This suggests that low-income economies could not bolster financial inclusivity through bank access. Also, continuing growth amid the Global Financial Crisis conveys resilience in their financial sectors. This could have stemmed from a lack of financial integration.

The same outlook is reflected in lower-middle-income economies. However, the bank branches per capita are greater, and the rate of growth in AI02 is stronger. This could suggest an association between per capita branches and income.

In the case of upper-middle-income economies, the rate of growth, as well as the per capita availability, was more substantial than the other two groups. Reinforcing the hypothesis of association between AI02 and income. However, there is a key difference: resilience to the Global Financial Crisis. Growth in per capita branches stalled, and a slight decrease was observed post-crisis. This suggests that upper-middle-income economies are better integrated into the global financial system, which is why they felt the crisis’ effect.

High-income economies had an extremely high per capita availability of banks compared to all groups. However, there was an overall decrease in AI02. The hypothesis, once again, seems relevant. The commonality with upper-middle-income economies is the crisis. However, the impact of the crisis was more adverse. Following a stagnation in the rate of change between 2006-2010, 2011 saw a noticeable decrease in the bank branches per capita. This suggests that high-income economies are the most integrated in the global financial system.

Note of Caution:

The insights derived from patterns of both indicators are not exhaustive. They stand solely as hypotheses and require deeper investigation.

Question 4

Load Data

filepath <- file.choose()
with_pop <- read_excel(filepath)

Part i

with_pop %>% filter(year>=2004 & year <=2014 & !is.na(ai01)) %>%
  mutate(weights=population/regionpop) -> with_pop
datatable(with_pop,options = list(scrollX = TRUE), caption = "Population Weights, for Non-Missing AI01 Values")

Part ii

with_pop %>% mutate(weighted_avg=weights*ai01) %>%
  group_by(region,year) %>% summarise(weighted_avg_ry=sum(weighted_avg)) %>% 
  pivot_wider(names_from = year, values_from = weighted_avg_ry, names_glue = 
                "{year}_{.value}") -> weighted_avg_data
## `summarise()` has grouped output by 'region'. You can override using the
## `.groups` argument.
datatable(weighted_avg_data,options = list(scrollX = TRUE), caption = "Weighted Averages by Region & Year for AI01")

Part iii

Simple Average Technique for AI01 as Used in 3 (i)

Financial_Development_Database_2022_00_14 %>% filter(year>2003 & !is.na(ai01)) %>% group_by(year,region) %>% 
  summarize(Avg_Indicator = mean(ai01, na.rm = TRUE)) %>%
  pivot_wider(names_from = year, values_from = Avg_Indicator, names_glue = "{year}_{.value}") -> simple_avg_data
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.
datatable(simple_avg_data,options = list(scrollX = TRUE), caption = "Simple Average for AI01")
merged_avg_df <- merge(weighted_avg_data,simple_avg_data)
diff_avg_df <- merged_avg_df %>% mutate(
    diff_2004 = `2004_Avg_Indicator` - `2004_weighted_avg_ry`,
    diff_2005 = `2005_Avg_Indicator` - `2005_weighted_avg_ry`,
    diff_2006 = `2006_Avg_Indicator` - `2006_weighted_avg_ry`,
    diff_2007 = `2007_Avg_Indicator` - `2007_weighted_avg_ry`,
    diff_2008 = `2008_Avg_Indicator` - `2008_weighted_avg_ry`,
    diff_2009 = `2009_Avg_Indicator` - `2009_weighted_avg_ry`,
    diff_2010 = `2010_Avg_Indicator` - `2010_weighted_avg_ry`,
    diff_2011 = `2011_Avg_Indicator` - `2011_weighted_avg_ry`,
    diff_2012 = `2012_Avg_Indicator` - `2012_weighted_avg_ry`,
    diff_2013 = `2013_Avg_Indicator` - `2013_weighted_avg_ry`,
    diff_2014 = `2014_Avg_Indicator` - `2014_weighted_avg_ry`
  ) -> diff_avg_df

diff_avg_df %>% pivot_longer(cols = starts_with("diff_"), names_to = "Year",  
                             values_to = "Difference") %>% select (starts_with("diff"),
                                                                   "region")-> diff_avg_ungroup_df

median_value <- median(diff_avg_ungroup_df$Difference)
mean_value <- mean(diff_avg_ungroup_df$Difference)

ggplot(diff_avg_ungroup_df, aes(Difference, region, fill = region)) +
  ggtitle("Distribution of Differences between 3(i) & 4(ii)") + 
  geom_boxplot(fill = "skyblue", color = "darkblue") +
  theme_minimal() +
  coord_flip() + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  annotate("text", y = 2.5, x = 3000,  
           label = paste("Median:", round(median_value, 2), "Mean:", round(mean_value, 2)), 
           color = "green", size = 4)

diff_avg_ungroup_df %>% group_by(region) %>%
  summarise(mean_difference = mean(Difference))
## # A tibble: 6 × 2
##   region                     mean_difference
##   <chr>                                <dbl>
## 1 East Asia & Pacific                   656.
## 2 Europe & Central Asia                 670.
## 3 Latin America & Caribbean             254.
## 4 Middle East & North Africa           6783.
## 5 South Asia                            377.
## 6 Sub-Saharan Africa                    125.

Comment on any similarities or differences between what you got in 4 (ii) and 3 (i):

Both 3i and 4ii seek to understand AI01, i.e the Bank Branches Available per 1000 people in a country, and is organised by region and year. Understanding is sought through a summary of the data, in the form of an average. It reflects the central tendency of AI01.

The difference between methods is whether population is accounted for. 4 (ii) accounts for population, as the method required the computation of weights. This allows for population to influence the contribution toward the average. 3 (i) does not account for population. Each country contributes equally to the average, independent of population.

4 (ii) provides a more representative measure of bank branch availability per 1000 individuals (AI01) in a region per year. Since population is crucial in determining the effect of a country on region-wide AI01. The average of 3 (i) is more sensitive to outliers of smaller countries. Unlike 4 (ii) which dilutes the impact of outliers.

Empirically, this difference is seen in the box plot. The simple average technique over predicts AI01, due to the effect of smaller countries. This is reflected by the central tendency of the difference between 3 (i) & 4 (ii) being positive, in terms of both mean & median. With the same pattern being reflected for every regions, as seen in the table above consisting of mean differences by region.