1 Preparation

# Packages
# setup library
Packages <- c("tidyverse", "countrycode", "WDI", "plotly", "patchwork", "modelr")
lapply(Packages, library, character.only = TRUE)

# set time span
start_year <- 1970
end_year <- 2020
caption <- "Source: Arthor's creation based on the data extracted from World Bank"

# set graphic functions
errorbar <- function(data, title = "title", subtitle = "subtitle") {
  data$model <- data$model %>% set_names(c(df$country %>% unique())) 
  data$summary <- lapply(data$model, summary)
  
  # create data frame for plotting error bars
  coefficient <- c()
  p_value <- c()
  sd_error <- c()
  for (i in 1:length(data$country)) {
    coefficient[i] <- data$summary[i][[1]]$coefficients[2, 1]
    p_value[i] <- data$summary[i][[1]]$coefficients[2, 4]
    sd_error[i] <- data$summary[i][[1]]$coefficients[2, 2]
  }
  
  df_graphics <- tibble(
    country = data$country,
    coefficient = coefficient,
    p_value = p_value,
    sd_error = sd_error,
    ci_lower = coefficient - 1.96*sd_error,
    ci_upper = coefficient + 1.96*sd_error,
    p_logical = ifelse(p_value > 0.05, "p>0.05", "p<=0.05") 
  )
  
  # plot with ggplot2
  ggplot(df_graphics, 
         aes(country, 
             coefficient, 
             colour = p_logical)) +
    geom_hline(yintercept = 0, alpha = 0.25, linetype = "dashed") +
    geom_point() +
    geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper)) +
    scale_color_manual(values = c( "#33ccff", "#ff9980")) +
    labs(title = title,
         subtitle = str_wrap(subtitle, 80),
         x = "Country",
         y = "Coefficient",
         caption = caption) +
    facet_wrap(~p_logical, scales = "free_x") +
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0),
          legend.position = "none")
}

2 Introduction

Okun’s Law defines the relations of economic growth rate (%) and unemployment rate (%) as follows;

\[ GDP\,growth\,rate = \hat{\alpha} + \hat{\beta_1} \times Unemployment\,rate \]

3 Data and model Specifications

In this essay, I test the robustness of Okun’s law by using database from the World Bank among OECD countries. The reason I narrow down to OCED coutntries are 1) world-wide regression is too vague as an analysis and 2) that the economy systems are different between the developed and the developing countries. The time frame is from 1970 and 2020.

  • The Difference Model

\[ \Delta y_t = \beta_0 - \beta_1 \Delta u_t + \epsilon_t, \qquad t = 1, \, ...,\, T, \qquad (1)\\ \] \[ y: Real\,GDP\,Growth\,Rate\\ u: Unemployment\,Rate\\ \]

  • The Gap Model

\[ y_t - y_t* = -\beta(u_t - u_t*) + \epsilon_t, \qquad (2) \\ \] \[ y : Real\,GDP\,Growth\,Rate\\ y*: Natural\,GDP\,Growth\,Rate\\ u : Unemployment\,Rate\\ u*: Natural\,Uemployment\,Rate\\ \]

4 Importing Data

# Importing data
# get the OECD coutnries name
url <- "https://raw.githubusercontent.com/OxfordEconomics/CountryLists/master/countryList-OECD.csv"
oecd_country <- read_csv(url) %>% 
  rename(country = `OecdMembers2019-07-31`)

# get world countires' name for continent data
world_country <- countrycode::codelist[,c(3,6)] %>% 
  setNames(c("continent", "country"))

# create data frame with OECD countries and a continent's column
df_oecd <-
  oecd_country %>%
  add_row(country = "South Korea") %>% 
  add_row(country = "Slovakia") %>% 
  # add_row(country = "Czechoslovakia") %>% 
  left_join(world_country) %>% 
  na.omit()

# convert countries'name to iso3c data structure
iso3c_names <- countrycode::countrycode(
  sourcevar = df_oecd$country,
  origin = "country.name",
  destination = "iso3c"
) 

# unemployment, gdp data, and gdp growth rate
input <- c("SL.UEM.TOTL.ZS", "NY.GDP.MKTP.CD", "NY.GDP.MKTP.KD.ZG")

# import data from world bank database by using `WDI` package
df_worldbank <- input %>%
  purrr::map(~WDI(country = iso3c_names,
                  indicator = ., 
                  start = start_year,
                  end = end_year)) %>%
  reduce(merge) %>% 
  setNames(c("iso2c", "country", "year", "unemployment", "gdp", "gdp_growth")) %>% 
  as_tibble()
  

# tidy df_worldbank
df <- df_worldbank %>% 
  left_join(df_oecd, by = "country") %>%
  mutate(continent = ifelse(country == "Korea, Rep.", "Asia", continent)) %>% 
  mutate(continent = as.factor(continent),
         gdp_log = log(gdp)) %>% 
  select(country, year, continent, gdp, gdp_log, gdp_growth, unemployment) %>% 
  na.omit()

5 Visualization

Since I got data from the above code, now I run a linear regression model by using “unemployment” on X axis and “gdp_grow” on Y axis. Accoding to Okun, Okun’s Law discribes their negative relations, so when unemployment goes up, it states, the gdp growth rate goes down.

# visualization of Okun's law by country
ggplot(df, aes(unemployment, gdp_growth, colour = continent)) +
  geom_point(alpha = .25) +
  geom_smooth(method = "lm", size = 0.5, alpha = .25, colour = "black", se = FALSE) +
  scale_x_continuous(breaks = seq(0, 25, by = 5)) +
  gghighlight::gghighlight() +
  facet_wrap(~country, drop = TRUE) +
  labs(title = "Empirical research on Okun's Law over OECD countries",
       x = "Unemployment rate (%)",
       y = "GDP growth rate (%)",
       caption = caption) +
  scale_x_continuous(expand = c(0, 0)) +
  theme_bw()

6 Modeling

6.1 The Difference Model

  • The Difference Model

\[ \Delta y_t = \beta_0 - \beta_1 \Delta u_t + \epsilon_t, \qquad t = 1, \, ...,\, T, \qquad (1)\\ \] \[ y: Real\,GDP\,Growth\,Rate\\ u: Unemployment\,Rate\\ \]

# modeling of the difference model
df_lm <- df %>% 
  group_by(country) %>% 
  nest() %>% 
  mutate(model = map(data, ~lm(unemployment ~ gdp_growth, data = .)))

# plot error bars
errorbar(df_lm,
         title = "Beta1 Accross OECD countries with the difference model",
         subtitle = "Most of the countries do not have p value less than 0.05, meaning
         the null hypothesis can not be rejected.")

\[ log(\Delta y_t) = \beta_0 - \beta_1 \Delta u_t + \epsilon_t, \qquad t = 1, \, ...,\, T, \qquad (1)\\ \]

\[ y: Real\,GDP\,Growth\,Rate\\ u: Unemployment\,Rate\\ \]

# modeling of the difference model (log)
df_lm_log <- df %>% 
  group_by(country) %>% 
  nest() %>% 
  mutate(model = map(data, ~lm(unemployment ~ gdp_log, data = .)))

# plot error bars
errorbar(df_lm_log, 
         title = "Beta Accross OECD coutnries with the difference model (log)",
         subtitle = "Most of the countries do not have p value less than 0.05, meaning
         the null hypothesis can not be rejected.")

6.2 The Gap Model

  • The Gap Model

\[ y_t - y_t* = -\beta(u_t - u_t*) + \epsilon_t, \qquad (2) \\ \] \[ y : Real\,GDP\,Growth\,Rate\\ y*: Natural\,GDP\,Growth\,Rate\\ u : Unemployment\,Rate\\ u*: Natural\,Uemployment\,Rate\\ \]

# set the natural gdp growth rate
y_natural <- 2

# set the natural unemployment rate
u_natural <- 3

# modeling of the gap model
df_gap <- df %>%
  mutate(gdp_growth = gdp_growth - y_natural,
         unemployment = unemployment - u_natural) %>% 
  group_by(country) %>% 
  nest() %>% 
  mutate(model = map(data, ~lm(gdp_growth ~ unemployment, data = .)))

# plot error bars
errorbar(df_gap, 
         title = "Beta Accross OCED countriest the gap model",
         subtitle = "Most of the countries do not have p value less than 0.05, meaning the null hypothesis can not be rejected.")

  • Gap Model (log)

\[ log(y_t) - log(y_t*) = -\beta(u_t - u_t*) + \epsilon_t, \qquad (2) \\ \]

\[ y : Real\,GDP\,Growth\,Rate\\ y*: Natural\,GDP\,Growth\,Rate\\ u : Unemployment\,Rate\\ u*: Natural\,Uemployment\,Rate\\ \]

# modeling of the gap model (log)
df_gap_log <- df %>%
  mutate(gdp_growth = gdp_log - y_natural,
         unemployment = unemployment - u_natural) %>% 
  group_by(country) %>% 
  nest() %>% 
  mutate(model = map(data, ~lm(gdp_growth ~ unemployment, data = .)))

# plot error bars
errorbar(df_gap_log,
         title = "Beta Accross OCED countriest the gap model (log)",
         subtitle = "Most of the countries do not have p value less than 0.05, meaning the null hypothesis can not be rejected.")

7 References

  • Lee, J. I. M. 2000. “The Robustness of Okun ’ s Law : Evidence from OECD Countries.” 22(2).
  • Zanin, Luca. 2014. “On Okun’s Law in OECD Countries: An Analysis by Age Cohorts.” Economics Letters 125(2):243–48. doi: 10.1016/j.econlet.2014.08.030.