Commit 777ddaa7 authored by Thomas Brand's avatar Thomas Brand

Change links to DBnomics and tibble.

parent 1ae0cc1e
......@@ -9,7 +9,7 @@ bibliography: biblio_cmr14_EA.bib
rm(list = ls())
if (!"pacman" %in% installed.packages()[,"Package"]) install.packages("pacman")
pacman::p_load(dplyr,magrittr,tidyr,ggplot2,lubridate,knitr,zoo,rjson,grid,rsdmx)
pacman::p_load(tidyverse,magrittr,lubridate,knitr,rsdmx,zoo)
opts_chunk$set(message=FALSE, warning=FALSE, cache=FALSE)
......@@ -22,7 +22,8 @@ theme <- theme_bw()+ theme(strip.background=element_blank(),
legend.key=element_rect(colour="white"),
legend.position="bottom",
legend.text=element_text(size=10),
axis.text=element_text(size=10))
axis.text=element_text(size=10),
plot.title=element_text(hjust=0.5))
blueObsMacro <- "#0D5BA4"
```
......@@ -47,19 +48,19 @@ The sources we use here are :
* Bank of International Settlements
* European Central Bank
We take data directly from the <a href="http://widukind.cepremap.org" target="_blank">Widukind economics database</a>. The Widukind API can be accessed through R thanks to the RSDMX package written by @rsd16. All the following code is written in R, thanks to the @RCT16 and the @RStu16.
We take data directly from <a href="https://db.nomics.world/" target="_blank">DBnomics</a>. The DBnomics API can be accessed through R thanks to the RSDMX package written by @rsd16. All the following code is written in R, thanks to the @RCT16 and the @RStu16.
# Loans to non-financial corporations and to households
We download loans series from the Bank of International Settlements.
```{r}
url_widukind <- "http://widukind-api.cepremap.org/api/v1/sdmx"
url_dbnomics <- "https://api.db.nomics.world/api/v1/sdmx"
# List of available countries in BIS data
EAtot_code <- c("DE", "FI", "FR", "IT", "PT", "AT",
"GR", "IE", "NL", "BE", "ES", "XM")
url_country <- paste0(EAtot_code, collapse = "+")
url <- paste0(url_widukind,"/BIS/data/CNFS/Q.",url_country,".N+H.A.M.XDC.A")
url <- paste0(url_dbnomics,"/BIS/data/CNFS/Q.",url_country,".N+H.A.M.XDC.A")
# N or H: Borrowing sector : NFC or Households
# A: Lending sector : All
......@@ -68,7 +69,7 @@ url <- paste0(url_widukind,"/BIS/data/CNFS/Q.",url_country,".N+H.A.M.XDC.A")
# A: Adjustment : Adjustment for breaks
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
loans <- df %>%
select(TIME_PERIOD, WIDUKIND_ID, OBS_VALUE, `BORROWERS-COUNTRY`, WIDUKIND_NAME) %>%
......@@ -292,10 +293,10 @@ To build long series of lending rate, we use historical data from the Internatio
# Download lending rates of the 8 countries from IFS
country_code <- c("BE","FR","DE","IT","NL","FI","IE","ES")
url_country <- paste0(country_code, collapse = "+")
url <- paste0(url_widukind,"/IMF/data/IFS/Q.",url_country,".FILR-PA")
url <- paste0(url_dbnomics,"/IMF/data/IFS/Q.",url_country,".FILR-PA")
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
lendingrate_bycountry <- df %>%
select(`REF-AREA`,TIME_PERIOD, OBS_VALUE) %>%
......@@ -309,10 +310,10 @@ lendingrate_bycountry <- df %>%
# Download PPP GDP of the 8 countries from WEO
country_iso <- c("BEL","FRA", "DEU", "ITA", "NLD", "FIN", "IRL", "ESP")
url_country_iso <- paste0(country_iso, collapse = "+")
url <- paste0(url_widukind,"/IMF/data/WEO/PPPGDP.",url_country_iso,".5")
url <- paste0(url_dbnomics,"/IMF/data/WEO/PPPGDP.",url_country_iso,".5")
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
df_country <- data.frame(country_code,
country=country_iso)
......@@ -346,10 +347,10 @@ lendingrate_old <-
# Bank interest rates - loans to corporations (new business) - euro area Euro area (changing composition), Annualised agreed rate (AAR) / Narrowly defined effective rate (NDER), Credit and other institutions (MFI except MMFs and central banks) reporting sector - Loans other than revolving loans and overdrafts, convenience and extended credit card debt [A20-A2Z], Total initial rate fixation, Total amount, New business coverage, Non-Financial corporations (S.11) sector, denominated in Euro
url_series <- "/ECB/data/MIR/M.U2.B.A2A.A.R.A.2240.EUR.N"
url <- paste0(url_widukind, url_series)
url <- paste0(url_dbnomics, url_series)
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
varname <- unique(as.character(df$WIDUKIND_NAME))
......@@ -409,10 +410,10 @@ longrate_old <-
# Long term interest rate Euro area 19 (fixed composition), Long-term interest rate for convergence purposes - Unspecified rate type, Debt security issued, 10 years maturity, New business coverage, denominated in Euro - Unspecified counterpart sector
url_series <- "/ECB/data/IRS/M.I8.L.L40.CI.0000.EUR.N.Z"
url <- paste0(url_widukind, url_series)
url <- paste0(url_dbnomics, url_series)
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
varname <- unique(as.character(df$WIDUKIND_NAME))
......@@ -456,10 +457,10 @@ The entrepreunarial networth is approximated through the Dow Jones index for the
# Dow Jones euro Euro area (changing composition) - Equity/index - Dow Jones Euro Stoxx Price Index - Historical close, average of observations through period - Euro
url_series <- "/ECB/data/FM/Q.U2.EUR.DS.EI.DJEURST.HSTA"
url <- paste0(url_widukind, url_series)
url <- paste0(url_dbnomics, url_series)
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
varname <- unique(as.character(df$WIDUKIND_NAME))
......@@ -490,10 +491,10 @@ varname
# House price Euro area 19 (fixed composition); Residential property prices, New and existing dwellings; Residential property in good and poor condition; Whole country; Neither seasonally nor working day adjusted; ECB
url_series <- "/ECB/data/RPP/Q.I8.N.TD.00.3.00"
url <- paste0(url_widukind, url_series)
url <- paste0(url_dbnomics, url_series)
data_sdmx <- readSDMX(url)
df <- as.data.frame(data_sdmx)
df <- as_tibble(data_sdmx)
varname <- unique(as.character(df$WIDUKIND_NAME))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment