Macroeconomics


Section 1 - Is France gloomy? Aux larmes, citoyens!

Installing & loading packages

library(WDI) 
library(fredr) 
library(rdbnomics) 
## Visit <https://db.nomics.world>.
library(OECD) 
library(tidyverse) 
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.1     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(ggthemes)

Question 1 - replicate the Economist Graph

data4 <- rdb(ids = c("OECD/QNA/DEU.B1_GS1.CQRSA.Q",
                   "OECD/QNA/ESP.B1_GS1.CQRSA.Q",
                   "OECD/QNA/USA.B1_GS1.CARSA.Q",
                   "OECD/QNA/ITA.B1_GS1.CQRSA.Q",
                   "OECD/QNA/GBR.B1_GS1.CQRSA.Q",
                   "OECD/QNA/FRA.B1_GS1.CQRSA.Q"))%>%
  select(period,Country,value)

data4 %>%
  filter(period >= as.Date("2019-10-01") & period<= as.Date("2021-07-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2019-10-01")]) %>% 
  ggplot + geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) +
  theme_economist(
    base_size = 10,
    base_family = "sans",
    horizontal = TRUE,
    dkpanel = FALSE
  ) +
  xlab("Years") + ylab("") + 
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2019 = 100") +
  labs(caption = "Data source: OECD") + 
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))

Question 2 - replot using Real GDP (until ’21 Q3)

data5 <- rdb(ids = c("OECD/QNA/DEU.B1_GS1.LNBQRSA.Q",
                     "OECD/QNA/ESP.B1_GS1.LNBQRSA.Q",
                     "OECD/QNA/USA.B1_GS1.LNBARSA.Q",
                     "OECD/QNA/ITA.B1_GS1.LNBQRSA.Q",
                     "OECD/QNA/GBR.B1_GS1.LNBQRSA.Q",
                     "OECD/QNA/FRA.B1_GS1.LNBQRSA.Q"))%>%
  select(period,Country,value)

data5 %>%
  filter(period >= as.Date("2019-10-01") & period<= as.Date("2021-07-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2019-10-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) + 
  labs(caption = "Data Source: OECD")+
  theme_economist(
    base_size = 10,
    base_family = "sans",
    horizontal = TRUE,
    dkpanel = FALSE
  ) + xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2019 = 100)") + 
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))

Question 3 - replot using latest data

data7<-rdb(ids = c("OECD/QNA/DEU.B1_GS1.LNBQRSA.Q",
                   "OECD/QNA/ESP.B1_GS1.LNBQRSA.Q",
                   "OECD/QNA/USA.B1_GS1.LNBQRSA.Q",
                   "OECD/QNA/ITA.B1_GS1.LNBQRSA.Q",
                   "OECD/QNA/GBR.B1_GS1.LNBQRSA.Q",
                   "OECD/QNA/FRA.B1_GS1.LNBQRSA.Q"))%>%
  select(period,Country,value)

data7 %>%
  filter(period >= as.Date("2019-10-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2019-10-01")]) %>% 
  ggplot + geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) + labs(caption = "Data Source: OECD") +
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1)) + 
  xlab("Years") + ylab("") +
  theme_economist(
    base_size = 10,
    base_family = "sans",
    horizontal = TRUE,
    dkpanel = FALSE
  ) + xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2019=100)") + 
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))

Question 4 - Show France ain’t doing so well, which 5 countries? (since 2019Q4)

We compared France to Australia, Denmark, Canada, Netherlands and Ireland. We chose these because they are the greatest outliers relative to France. Ireland, Denmark and the Netherlands - European Union members - are outperforming France, and Australia and Canada also representing economies outside of Europe.

data9<-rdb(ids = c("OECD/QNA/AUS.B1_GS1.CQRSA.Q",
                   "OECD/QNA/DNK.B1_GS1.CQRSA.Q",
                   "OECD/QNA/CAN.B1_GS1.CARSA.Q",
                   "OECD/QNA/NLD.B1_GS1.CQRSA.Q",
                   "OECD/QNA/IRL.B1_GS1.CQRSA.Q",
                   "OECD/QNA/FRA.B1_GS1.CQRSA.Q"))%>%
  select(period,Country,value)

data9 %>%
  filter(period >= as.Date("2019-10-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2019-10-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) +
  labs(caption = "Data Source: OECD") +
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1)) + 
  xlab("Years") + ylab("") +
  theme_economist(
    base_size = 10,
    base_family = "sans",
    horizontal = TRUE,
    dkpanel = FALSE
  ) + xlab("Years")+ylab("") +
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2019=100)") + 
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))

Question 5 - Do the same analysis for a longer time period, do the results hold up?

Yes, the graph supports that the results hold up being largely dominated by the other economies for this new period.

data9 %>%
  filter(period >= as.Date("2000-10-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2000-10-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) +theme_minimal()+ 
  labs(caption = "Data Source: OECD") +
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1)) + 
  xlab("Years") + ylab("")+
  theme_economist(
    base_size = 10,
    base_family = "sans",
    horizontal = TRUE,
    dkpanel = FALSE
  ) +
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2000=100)")

Question 6 - Do the same analysis comparing to other important economies, what do you find ?

5 new economies - Austria, Sweden, Czech Republic, Hungary and Belgium.

data9 %>%
  filter(period >= as.Date("2000-10-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2000-10-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) + theme_minimal() + 
  labs(caption = "Data Source: OECD")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1)) + 
  xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2000 = 100)")

#Part 2:Countries used: Czech Republic, Austria, Hungry, Sweden, Belgium.

data12<-rdb(ids = c("OECD/QNA/CZE.PPPGDP.CD.Q",
                    "OECD/QNA/AUT.PPPGDP.CD.Q",
                    "OECD/QNA/HUN.PPPGDP.CD.Q",
                    "OECD/QNA/SWE.PPPGDP.CD.Q",
                    "OECD/QNA/BEL.PPPGDP.CD.Q",
                    "OECD/QNA/FRA.PPPGDP.CD.Q"))%>%
  select(period,Country,value)

data12 %>%
  filter(period >= as.Date("2000-10-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2000-10-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + geom_line(aes(x = period, y = 100)) +theme_minimal()+ labs(caption = "Data Source: OECD")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP, Q4 2000 = 100)")

Question 7 GDP PPP

data11<-rdb(ids = c("OECD/QNA/AUS.PPPGDP.CD.Q",
                    "OECD/QNA/DNK.PPPGDP.CD.Q",
                    "OECD/QNA/CAN.PPPGDP.CD.Q",
                    "OECD/QNA/NLD.PPPGDP.CD.Q",
                    "OECD/QNA/IRL.PPPGDP.CD.Q",
                    "OECD/QNA/FRA.PPPGDP.CD.Q"))%>%
  select(period,Country,value)

data11 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("1995-01-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) +theme_minimal()+ 
  labs(caption = "Data Source: OECD")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP, Q1 1995=100)")

Question 7 GDP Per Capita

data15<-rdb(ids = c("OECD/EO/AUS.GDPV_CAP.A",
                    "OECD/EO/DNK.GDPV_CAP.A",
                    "OECD/EO/CAN.GDPV_CAP.A",
                    "OECD/EO/NLD.GDPV_CAP.A",
                    "OECD/EO/IRL.GDPV_CAP.A",
                    "OECD/EO/FRA.GDPV_CAP.A"))%>%
  select(period,Country,value)

data15 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("1995-01-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + geom_line(aes(x = period, y = 100)) +theme_minimal()+ labs(caption = "Data Source: OECD")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP per capita, 1995=100)")

Question 7 GDP Consumption

Unfortunately, OECD data does not go back to 1995 and for the sake of statistical continuity we did not want to use another data set for one sole component of the question. Moreover, we weren’t able to incorporate Australia and Canada as with the other components of this question due to a dataset issue.

data13<-rdb(ids = c("OECD/QNA/DNK.K1.CQR.Q",
                    "OECD/QNA/NLD.K1.CQR.Q",
                    "OECD/QNA/IRL.K1.CQR.Q",
                    "OECD/QNA/FRA.K1.CQR.Q"))%>%
  select(period,Country,value)

data13 %>%
  filter(period >= as.Date("2000-01-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2000-01-01")]) %>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country)) + 
  geom_line(aes(x = period, y = 100)) +theme_minimal()+ 
  labs(caption = "Data Source: OECD")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Why so blue?", subtitle = "GDP (Consumption), Q1 2000=100)")


Section 2 - Is France really the “employment champion”?

Question 1 - Replicate the graph

data10<-rdb(ids = c("ECB/ENA/Q.N.DE.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                   "ECB/ENA/Q.N.ES.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                   "ECB/ENA/Q.N.FR.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                   "ECB/ENA/Q.N.I9.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                   "ECB/ENA/Q.N.IT.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N"))%>%
  select(period,REF_AREA,value)

data10 %>%
  filter(period >= as.Date("2000-01-01"))%>%
  group_by(REF_AREA) %>%
  mutate(index = 100*value/value[period == as.Date("2019-10-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = REF_AREA)) +
  geom_line(aes(x = period, y = 100)) +
  theme_minimal() + labs(caption = "Data Source: European Central Bank")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("") +
  ggtitle("Eurozone: Total Employment", 
          subtitle = "GDP, Q4 2019 = 100 (national accounts concept)")

Question 2 - Longer period and different base year

data11<-rdb(ids = c("ECB/ENA/Q.N.DE.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.ES.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.FR.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.I9.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.IT.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N"))%>%
  select(period,REF_AREA,value)

data11 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(REF_AREA) %>%
  mutate(index = 100*value/value[period == as.Date("2007-10-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = REF_AREA)) +
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: European Central Bank")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Eurozone: Total Employment", 
          subtitle = "GDP, Q4 2007 = 100 (national accounts concept)")

#different base year to show that it does not show (depends on the view)----
data11<-rdb(ids = c("ECB/ENA/Q.N.DE.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.ES.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.FR.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.I9.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N",
                    "ECB/ENA/Q.N.IT.W2.S1.S1._Z.EMP._Z._T._Z.PS._Z.N"))%>%
  select(period,REF_AREA,value)

data11 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(REF_AREA) %>%
  mutate(index = 100*value/value[period == as.Date("2000-01-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = REF_AREA)) +
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: European Central Bank")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Eurozone: Total Employment", 
          subtitle = "GDP, Q1 2000 = 100 (national accounts concept)")

Question 3 - Types of employment / by sector

#Germany
data12<-rdb(ids = c("Eurostat/ei_isind_q/Q.SCA.PCH_PRE.B.EMPL.DE",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.C.EMPL.DE",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.D.EMPL.DE",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.MIG_NRG.EMPL.DE"))%>%
  select(period,nace_r2,value)

data12 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(nace_r2) %>%
  mutate(index = 100*value/value[period == as.Date("2000-04-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = nace_r2))+
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: Eurostat")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Germany: Employment by sector", subtitle = "GDP, Q4 2019 = 100")

#Spain
data15 <-rdb(ids = c("Eurostat/ei_isind_q/Q.SCA.PCH_PRE.B.EMPL.ES",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.C.EMPL.ES",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.D.EMPL.ES",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.MIG_NRG.EMPL.ES"))%>%
  select(period,nace_r2,value)

data15 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(nace_r2) %>%
  mutate(index = 100*value/value[period == as.Date("2000-04-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = nace_r2))+
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: Eurostat")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Spain: Employment by sector", subtitle = "GDP, Q4 2019 = 100")

#France
data16 <-rdb(ids = c("Eurostat/ei_isind_q/Q.SCA.PCH_PRE.B.EMPL.FR",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.C.EMPL.FR",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.D.EMPL.FR",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.MIG_NRG.EMPL.FR"))%>%
  select(period,nace_r2,value)

data16 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(nace_r2) %>%
  mutate(index = 100*value/value[period == as.Date("2000-04-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = nace_r2))+
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: Eurostat")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("France: Employment by sector", subtitle = "GDP, Q4 2019 = 100")

#Italy
data18 <-rdb(ids = c("Eurostat/ei_isind_q/Q.SCA.PCH_PRE.B.EMPL.IT",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.C.EMPL.IT",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.D.EMPL.IT",
                    "Eurostat/ei_isind_q/Q.SCA.PCH_PRE.MIG_NRG.EMPL.IT"))%>%
  select(period,nace_r2,value)

data18 %>%
  filter(period >= as.Date("1995-01-01"))%>%
  group_by(nace_r2) %>%
  mutate(index = 100*value/value[period == as.Date("2000-04-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = nace_r2))+
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: Eurostat")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Italy: Employment by sector", subtitle = "GDP, Q4 2019 = 100")

Question 4 - Unemployment instead of employment

The disparity in these numbers might come from two obvious differences between the definitions and collection methods of both. Unemployment data is collected from surveys, whereas employment data comes from the national accounts.

Definitions

- The employed are persons engaged in production and working at least one hour per week.

- Unemployed persons are defined as those aged 15 years and over who are without work, are available to start work within two weeks and have actively sought employment during the previous four weeks.

Collection methods

- Unemployment is collected in the European Community Labour Force Survey

- Employment data comes from national accounts

data13<-rdb(ids = c("EC/NUTN/DEU.1.0.0.0.NUTN",
                    "EC/NUTN/ITA.1.0.0.0.NUTN",
                    "EC/NUTN/FRA.1.0.0.0.NUTN",
                    "EC/NUTN/EA19.1.0.0.0.NUTN",
                    "EC/NUTN/ESP.1.0.0.0.NUTN"))%>%
  select(period,Country,value)

data13 %>%
  filter(period >= as.Date("2000-01-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2019-01-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country))+
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: European Central Bank")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Eurozone: Total Employment", 
          subtitle = "GDP, Q4 2019 = 100 (national accounts concept)")

data14<-rdb(ids = c("EC/ZUTN/DEU.1.0.0.0.ZUTN",
                    "EC/ZUTN/ITA.1.0.0.0.ZUTN",
                    "EC/ZUTN/FRA.1.0.0.0.ZUTN",
                    "EC/ZUTN/EA19.1.0.0.0.ZUTN",
                    "EC/ZUTN/ESP.1.0.0.0.ZUTN"))%>%
  select(period,Country,value)

data14 %>%
  filter(period >= as.Date("2000-01-01"))%>%
  group_by(Country) %>%
  mutate(index = 100*value/value[period == as.Date("2007-01-01")])%>% 
  ggplot+ geom_line(aes(x = period, y = index, color = Country))+
  geom_line(aes(x = period, y = 100)) +
  theme_minimal()+ labs(caption = "Data Source: European Central Bank")+
  theme(legend.position = "bottom", plot.caption = element_text(hjust = 1))+ 
  xlab("Years")+ylab("")+
  ggtitle("Eurozone: Total Unemployment", 
          subtitle = "GDP, Q4 2007 = 100 (national accounts concept)")