analysis/simple_example.R

library(DeGVC)
library(dplyr)

#test <- convert_io(wiot$iot[[3]])

#epsilon = 3, R[1] = 1, R[2] = 1.5, gamma[1] = 0.5, gamma[2] = 0.5, pi^I [1, 1] = 0.6, pi^I [2, 1] = 0.4, pi^I [1, 2] = 0.2, pi^I [2, 2] = 0.8, pi^F [1, 1] = 0.5, pi^F [2, 1] = 0.5, pi^F [1, 2] = 0.4, pi^F [2, 2] = 0.6}

n_location <- 2
n_sector <- 1

simple_data <-
  list(
    location_id = seq(n_location),
    sector_id = seq(n_sector),
    R = matrix(c(1, 1.5), nrow = n_location, ncol = n_sector),
    D = rep(0, n_location), # trade deficits
    pi = as.vector(array(c(0.6, 0.4, 0.2, 0.8, 0.5, 0.5, 0.4, 0.6),
                         # origin, destination, sector, use = interm or final)
                         dim = c(n_location, n_location, n_sector, n_sector + 1))),
    # sectoral consumption/expenditure shares equal 1 with just one sector
    alpha = matrix(1, nrow = n_location, ncol = n_sector),
    # intermediate usage (with just one sector this is simply 1 - gamma)
    gamma_jrs = as.vector(array(c(0.5, 0.5),
                                # location, sector, use (interm. only)
                                dim = c(n_location, n_sector, n_sector))),
    # labor share with just one sector
    gamma_js = matrix(c(0.5, 0.5), nrow = n_location, ncol = n_sector)
  )

parameters <-
  list(
    epsilon = 3,
    varphi = 1.5, # does not matter with immobility
    mobility = "immobile"
  )

# set this shock to your values for dlog_T and dlog_tau, ignore the delta and
# varkappa
shock <-
  list(
    T_hat = matrix(1, nrow = n_location, ncol = n_sector),
    tau_hat = rep(1, n_location * n_location * n_sector * (n_sector + 1)),
    delta_hat = matrix(1, nrow = n_location, ncol = n_sector), # labor productivity changes
    varkappa_hat = rep(1, n_location) # deficit changes
)

test <- calc_cf(simple_data, shock, parameters)
okrebs/DeGVC documentation built on March 15, 2021, 1:17 a.m.