Setup

library(dplyr)
library(tidyr)
# if not yet done install the iotr package
# library(devtools)
# install_github(repo = "okrebs/iotr")
library(iotr)

Download and Tidy Data

We begin by downloading and tidying input output tables from the World Input Output Database (see Timmer, M. P., Dietzenbacher, E., Los, B., Stehrer, R. and de Vries, G. J. (2015), "An Illustrated User Guide to the World Input–Output Database: the Case of Global Automotive Production", Review of International Economics., 23: 575–605, www.wiod.org).

wiot <- get_wiot(years = c(2000, 2014)) %>%
  wiot2long() %>%
  filter(Country != "TOT") %>%
  select(origin = Country, sector = RNr, destination, use, flow,
         year = Year)

Modify Data

We adopt the initial, raw WIOD data the following three ways:

  1. In a very limited number of cases the WIOD lists country-sectors that have a larger total intermedaite use than output value implying a negative value added. This can occur e.g. in country-sectors that receive strong subsidies and feature negative returns (value added) to the employed capital. In these cases we increase the total output value and world wide consumption of the respective country-sectors until the implied value added equal the smallest positive value added observed in any countryy-sector in the WIOD.
  2. Our static model can not properly capture inherently dynamic categories (inventory, gross fixed capital formation) that are present in the WIOD. We employ the strategy presented in Costinot and Rodríguez-Clare (2014, Trade Theory with Numbers: Quantifying the Consequences of Globalization. In Handbook of International Economics, eds. Gopinath, G., Helpman, E., and Rogoff, K., volume 4, chapter 4, pages 197–261. Elsevier) and recalculate the input output table based on a Leontieff approach as if positive changes in inventories and gfcf had been consumed and negative ones produced in the current period.
  3. Finally, in this paper we will consider some simulations that feature infinite barriers to intermediate or final goods trade. In these situations if the WIOD data implies that some use category (some sectoral intermediate or final use) sources goods from a specific sector only internationally but not domestically (implying a preexisting infinite barrier in the respective internal trade) the new infinite barrier would imply that the respective sectoral use share can no longer be satisfied. Therefore we set domestic sourcing to a small value (either $1 or the smallest observed import from any trade partner). We keep the original data for robustness checks in scenarios with finite trade barriers and find that in these cases replacing 0 has no (up to at least 6 digits after the decimal point) effect on our welfare results.
wiot <- wiot %>%
  # apply the respective function to the IO table from each year separately
  nest_by(year, .key = "iot") %>%
  mutate(iot = list(rm_negative_vad(iot, category_to_scale = 57) %>%
                      rm_dynamics(dynamic_categories = c(60, 61),
                                  category_to_scale = 57)))

# after adapting dynamic use categories combine all final use types into one
wiot <- wiot %>%
  unnest(cols = c(iot)) %>%
  mutate(use = ifelse(use > 57, 57L, as.integer(use))) %>%
  group_by(year, origin, sector, destination, use) %>%
  summarise(flow = sum(flow), .groups = "drop") %>%
  nest(iot = c(origin, sector, destination, use, flow))

wiot <- wiot %>%
  rowwise() %>%
  # wiot is in millions so 1e-6 is $1
  mutate(iot_nozero = list(gen_own_trade(iot, max_replace = 1e-6))) %>%
  pivot_longer(c(iot, iot_nozero),
               names_to = "includes_zeros",
               names_transform = list("includes_zeros" = ~.x == "iot"),
               values_to = "iot")

# we only use the WIOD from 2000 as a robustness check and so do not need the
# version that includes zeros
wiot <- wiot %>% filter(year != 2000 | includes_zeros == FALSE)

This gives us three IO tables, one for the year 2000 with problematic zero own trade flows removed and two tables for 2014, with and without these zeros. Due to its size this data set is not made available via github. Run the code wiot.R in the data-raw folder of the source package to create it.



okrebs/DeGVC documentation built on March 15, 2021, 1:17 a.m.