BIS

The BIS package package provides an R interface to data hosted by the Bank for International Settlements, specifically the single-file data sets available on the BIS homepage.

Install package

The package can be installed from GitHub.

library(devtools)
install_github("stefanangrick/BIS")  # GitHub

Example usage

To import data, first load the package:

library("BIS")

Next, run the get_datasets() function to obtain a list of available data sets:

ds <- get_datasets()
head(ds, 20)

The get_datasets() function returns a tibble data frame listing the available data sets. The column url can be used as input for the get_bis() function which downloads, parses and imports the corresponding data set.

To import monthly-frequency data on central banks' policy rates, run:

rates <- get_bis(ds$url[ds$id == "full_cbpol_m_csv"])
head(rates)

To plot the data using ggplot2, run the following:

library("dplyr")
library("ggplot2")
library("zoo")

rates_plot <- subset(rates, ref_area %in% c("US", "XM", "JP", "GB", "CH", "CA"))
rates_plot <- mutate(rates_plot, date = as.Date(as.yearmon(date, format = "%Y-%m")))

ggplot(rates_plot, aes(date, obs_value, color = reference_area)) +
  geom_line(show.legend = FALSE) +
  facet_wrap(~reference_area) +
  labs(title = "Central bank policy rates",
       subtitle = "% per annum", x = NULL, y = NULL)

Note that BIS data sets come with a number of different time formats. The zoo package (e.g. as.yearmon()) should be able to parse most formats.

Large data sets

Large data sets (e.g. the Locational banking statistics and Debt securities statistics) may cause get_bis() to fail if the amount of available memory is insufficient for executing a required pivot operation. As a workaround, users may wish to set auto_pivot = FALSE when calling get_bis(), then subset the data and run pivot_longer_bis() manually.

options(timeout = 600)
lbs <- get_bis(ds$url[(ds$id == "full_lbs_d_pub_csv")], auto_pivot = FALSE)
lbs <- subset(lbs, l_parent_cty %in% c("US", "DE", "JP"))
lbs <- pivot_longer_bis(lbs)

Retrieve individual data series

To retrieve individual data series instead of full data sets, consider using the BIS SDMX RESTful API. The rsdmx R package is able to process SDMX data within R. The latest rsdmx development version contains a BIS connector that streamlines the process.

Note

This package is in no way officially related to or endorsed by the Bank for International Settlements. It's based on a fork of CC0-licensed code by expersso. Please don't abuse the BIS's servers with unnecessary calls.



Try the BIS package in your browser

Any scripts or data that you put into this service are public.

BIS documentation built on Nov. 21, 2022, 5:06 p.m.