Introduction to exvatools

Enrique Feás

University of Alcalá and Elcano Royal Institute

January, 2024

Half of today’s international trade is composed of intermediate goods, so statistics of gross exports do not reflect the complexity of globalization. Trade flows should be expressed in terms of value added, taking advantage of modern international input-output tables, which show how different sectors in different countries interact with each other. The problem is that handling big input-output tables is complicated and many indicators are not available. This is where exvatools proves useful. Its purpose is double:

International input-output analysis tools

Installing exvatools

Installing exvatools from the CRAN repository follows the usual procedure:

install.packages("exvatools")

To make exvatools available:

library(exvatools)

Using data

exvatools produces basic input-output tables from three types of data:

  1. Raw data of standard international input-output databases

Raw data can be directly downloaded from the web pages of their respective institutions. Three sources are currently supported:

  • OECD Inter-Country Input-Output (ICIO) tables, on which the OECD’s Trade in Value Added database (TiVA) is based.
  • World Input Output Database (WIOD) tables.
  • FIGARO EU Input-Output Tables (EU IC-SUIOTs).

The advantage of these databases is threefold: they are widely used in the economic literature, they are quite rich in terms of countries and sectors, and they are directly downloadable from the web page of their supporting institutions, normally as zipped files containing comma-delimited files (.csv), Excel files (.xlsx) or R data files (.rData).

For instance, if we want to use exvatools with the latest edition of the OECD ICIO tables (2023, with data up to 2020), we must first download to our computer the source file “ICIO-2016-2020-extended.zip” (142 MB) from the ICIO web page. Then we will use the command make_wio(), specifying the edition, the year and the folder where the source zip file is saved (just the directory). For instance, if we had downloaded it in C:\Users\Username\Documents\R and we wanted the year 2020, we would just need to type:

wio <- make_wio("icio2023", year = 2020, 
                src_dir = "C:/Users/Username/Documents/R")

and exvatools will take care of the rest: it will extract the .csv files from the zip file and produce the basic input-output matrices.

  1. Test datasets included in the package

If we just want to check the features of exvatools, there is no need to download any data. The package includes two sets of fictitious data, one replicating an ICIO-type database (wiotype = "iciotest", with Mexico and China disaggregated) and another one replicating a WIOD-type database (wiotype = "wiodtest").

wio <- make_wio("iciotest")
  1. Custom data

Alternatively, exvatools can use custom data to create basic input-output matrices. In this case, we just need as input a numeric matrix (or data frame) with the intermediate inputs Z and the final demand Yfd, and a vector with the names of the countries (names of sectors and final demand components are optional). The command make_custom_wio() will be used in this case.

wio <- make_custom_wio(df, g_names = c("C01", "C02", "C03"))

For didactic purposes, we will use here ICIO-type fictitious data made with make_wio("iciotest").

The contents of the created wio object can be checked with summary():

summary(wio)
#> 
#> ====================================================================== 
#>            TEST INPUT OUTPUT TABLE, ICIO-TYPE, 2022 EDITION 
#>                           Data for year: 2022 
#> ====================================================================== 
#> 
#>  Element Description                                       Dimensions
#>  Z       Intermediate inputs                               30 x 30   
#>  Zd      Domestic intermediate inputs                      30 x 30   
#>  Zm      Foreign intermediate inputs                       30 x 30   
#>  A       Coefficient matrix                                30 x 30   
#>  Ad      Domestic coefficient matrix                       30 x 30   
#>  Am      Foreign coefficient matrix                        30 x 30   
#>  B       Global Leontief inverse                           30 x 30   
#>  Bd      Domestic global Leontief inverse                  30 x 30   
#>  Bm      Foreign global Leontief inverse                   30 x 30   
#>  Ld      Local Leontief inverse matrices                   30 x 30   
#>  Yfd     Final demand, with components                     30 x 12   
#>  Y       Final demand                                      30 x 6    
#>  Yd      Domestic final demand                             30 x 6    
#>  Ym      Foreign final demand                              30 x 6    
#>  VA      Value added                                       30 x 1    
#>  V       Value added coefficients                          30 x 1    
#>  W       Diagonalized VA coefficients (V-hat)              30 x 30   
#>  X       Production                                        30 x 1    
#>  EXGR    Gross bilateral exports                           30 x 6    
#>  E       Diagonalized total gross exports (E-hat)          30 x 30   
#>  dims    Dimensions                                                  
#>  names   Names of countries, sectors and demand components           
#>  type    Type of input-output table                                  
#>  year    Year                                                        
#> 
#> Available countries, including rest of the world (G): 6 
#> ESP, FRA, MEX, USA, CHN, ROW 
#>  
#> Extra disaggregated countries: 4 
#> MEX : MX1 MX2 
#> CHN : CN1 CN2 
#> 
#> Total countries, including disaggregations (GX): 10 
#> 
#> Available sectors (N): 3 
#> D01T09, D10T39, D41T98 
#>  
#> Demand components (FD): 2 
#> CONS INVST
#> 

Operating with input-output matrices

exvatools provides multiple commands that make operating with international input-output tables extremely easy: thus, we can multiply a diagonal matrix by an ordinary one with dmult(), an ordinary by a diagonal with multd(), or make a block-by-block Hadamard product of matrices with hmult().

We can also easily obtain a block diagonal matrix with bkd(), a block off-diagonal matrix with bkoffd(), or a diagonal matrix with the sums of all columns with diagcs(),

Additionally, as we are always operating with named rows and columns with names of countries and sectors, we have improved commands to consolidate matrices and provide names, like rsums() to sum rows, csums() to sum columns, sumnrow() to sum every nth row of a matrix, sumncol() to sum every nth column, sumgrows() to sum groups of rows of a particular size, sumgcols() to do the same with columns, etc.

For instance, let us check that the production X is equivalent to the product of the global Leontief inverse matrix B and the final demand Y:

BY <- wio$B %*% wio$Y

We can sum the rows and check that it coincides with the production vector:

BY <- rsums(BY, "BY")
print(cbind(head(BY, 10), head(wio$X, 10)))
#>                 BY        X
#> ESP_01T09 1378.568 1378.568
#> ESP_10T39 1914.607 1914.607
#> ESP_41T98 2113.699 2113.699
#> FRA_01T09 1848.173 1848.173
#> FRA_10T39 1799.486 1799.486
#> FRA_41T98 1608.004 1608.004
#> MEX_01T09    0.000    0.000
#> MEX_10T39    0.000    0.000
#> MEX_41T98    0.000    0.000
#> USA_01T09 1895.742 1895.742

In OECD ICIO tables two big industrial countries, China and Mexico, are disaggregated into two. Calculations must be done with disaggregated data, but countries must be later consolidated (e.g., CN1 and CN2 must be converted into CHN). This can be done with the command meld().

For instance, to calculate the value added absorbed abroad (VAX) we need to multiply the value added coefficients matrix V-hat (represented here with W) by the global inverse matrix B by the final demand matrix Y, and then exclude the value added absorbed domestically. This can be easily done with a few commands.

# To calculate all value added induced by demand:
VBY <- dmult(wio$W, wio$B) %*% wio$Y
VBY
#>                 ESP       FRA       MEX       USA       CHN       ROW
#> ESP_01T09  33.25239  33.04328  29.13415  39.26315  44.36171  40.26254
#> ESP_10T39 105.86567  99.40932 118.73322 139.90848 115.91495 126.97831
#> ESP_41T98 221.93642 191.16663 158.37563 173.76610 145.22181 168.64254
#> FRA_01T09  48.48628  66.62310  51.62458  49.45643  47.66424  70.97642
#> FRA_10T39 120.80031 104.64030 128.78920 102.79096  97.91708  99.78527
#> FRA_41T98 134.74749 129.14500  99.99938  88.70168  86.75694 101.79354
#> MEX_01T09   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
#> MEX_10T39   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
#> MEX_41T98   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
#> USA_01T09 175.01545 130.46673 128.74728 107.71747 102.20179 117.94400
#> USA_10T39 102.29790  84.03672  79.60012 121.89497  66.60450 100.75615
#> USA_41T98 115.50508 118.18725 129.51719 122.16680  95.86500 111.98916
#> CHN_01T09   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
#> CHN_10T39   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
#> CHN_41T98   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
#> ROW_01T09  82.22487  42.82585  45.01008  60.06683  46.78138  51.62906
#> ROW_10T39  90.44372  97.64510  80.63597  95.00232  91.33130  91.05473
#> ROW_41T98  62.56171  51.01318  42.64560  58.70599  41.40437  50.09897
#> MX1_01T09 173.85507 180.14952 154.43342 149.69601 164.13090 149.43125
#> MX1_10T39 119.84480  74.11099 117.78742  97.93871 142.64384 121.97803
#> MX1_41T98  49.45281  29.23090  35.52473  39.69653  36.67997  31.42076
#> MX2_01T09  96.85254  83.89485  70.55941  97.36493  80.35587  66.40230
#> MX2_10T39 138.50490  86.35272  92.84516 108.88726  99.24637 102.95958
#> MX2_41T98  82.91973  67.68778  62.14849  77.03372  65.06803  75.12146
#> CN1_01T09 109.94070 114.47837  91.18810 152.37369 127.84703 118.37641
#> CN1_10T39 119.64017 127.22095 126.45021 165.70116 164.43470 128.00251
#> CN1_41T98 109.34845  93.91197 106.67385 115.50129 111.77386 119.86482
#> CN2_01T09  84.74417  83.13258  69.33664  86.84078  80.88526  72.00972
#> CN2_10T39  73.17244  54.76049  43.08188  56.11525  70.19744  78.67920
#> CN2_41T98 158.98841 103.45062 108.60598 136.04997 128.63627 109.93866

We can see that rows for Mexico and China are disaggregated. We can meld them with meld():

VBY <- meld(VBY)
VBY
#>                 ESP       FRA       MEX       USA       CHN       ROW
#> ESP_01T09  33.25239  33.04328  29.13415  39.26315  44.36171  40.26254
#> ESP_10T39 105.86567  99.40932 118.73322 139.90848 115.91495 126.97831
#> ESP_41T98 221.93642 191.16663 158.37563 173.76610 145.22181 168.64254
#> FRA_01T09  48.48628  66.62310  51.62458  49.45643  47.66424  70.97642
#> FRA_10T39 120.80031 104.64030 128.78920 102.79096  97.91708  99.78527
#> FRA_41T98 134.74749 129.14500  99.99938  88.70168  86.75694 101.79354
#> MEX_01T09 270.70761 264.04436 224.99283 247.06094 244.48677 215.83355
#> MEX_10T39 258.34970 160.46370 210.63258 206.82598 241.89021 224.93762
#> MEX_41T98 132.37254  96.91869  97.67322 116.73025 101.74800 106.54222
#> USA_01T09 175.01545 130.46673 128.74728 107.71747 102.20179 117.94400
#> USA_10T39 102.29790  84.03672  79.60012 121.89497  66.60450 100.75615
#> USA_41T98 115.50508 118.18725 129.51719 122.16680  95.86500 111.98916
#> CHN_01T09 194.68487 197.61095 160.52474 239.21447 208.73229 190.38614
#> CHN_10T39 192.81261 181.98144 169.53209 221.81640 234.63214 206.68171
#> CHN_41T98 268.33686 197.36260 215.27984 251.55127 240.41013 229.80349
#> ROW_01T09  82.22487  42.82585  45.01008  60.06683  46.78138  51.62906
#> ROW_10T39  90.44372  97.64510  80.63597  95.00232  91.33130  91.05473
#> ROW_41T98  62.56171  51.01318  42.64560  58.70599  41.40437  50.09897

We just want the value added absorbed abroad (sometimes referred to as value added exported). For that we need the block off-diagonal matrix of VBY, that we can produce with bkoffd():

bkoffd(VBY)
#>                 ESP       FRA       MEX       USA       CHN       ROW
#> ESP_01T09   0.00000  33.04328  29.13415  39.26315  44.36171  40.26254
#> ESP_10T39   0.00000  99.40932 118.73322 139.90848 115.91495 126.97831
#> ESP_41T98   0.00000 191.16663 158.37563 173.76610 145.22181 168.64254
#> FRA_01T09  48.48628   0.00000  51.62458  49.45643  47.66424  70.97642
#> FRA_10T39 120.80031   0.00000 128.78920 102.79096  97.91708  99.78527
#> FRA_41T98 134.74749   0.00000  99.99938  88.70168  86.75694 101.79354
#> MEX_01T09 270.70761 264.04436   0.00000 247.06094 244.48677 215.83355
#> MEX_10T39 258.34970 160.46370   0.00000 206.82598 241.89021 224.93762
#> MEX_41T98 132.37254  96.91869   0.00000 116.73025 101.74800 106.54222
#> USA_01T09 175.01545 130.46673 128.74728   0.00000 102.20179 117.94400
#> USA_10T39 102.29790  84.03672  79.60012   0.00000  66.60450 100.75615
#> USA_41T98 115.50508 118.18725 129.51719   0.00000  95.86500 111.98916
#> CHN_01T09 194.68487 197.61095 160.52474 239.21447   0.00000 190.38614
#> CHN_10T39 192.81261 181.98144 169.53209 221.81640   0.00000 206.68171
#> CHN_41T98 268.33686 197.36260 215.27984 251.55127   0.00000 229.80349
#> ROW_01T09  82.22487  42.82585  45.01008  60.06683  46.78138   0.00000
#> ROW_10T39  90.44372  97.64510  80.63597  95.00232  91.33130   0.00000
#> ROW_41T98  62.56171  51.01318  42.64560  58.70599  41.40437   0.00000

Value added in exports

The model we have used allows us to express value added induced by final demand, but we can also study how gross exports induce value added, not only from final exports but also from exports of intermediates. In this case, we need to consider the effect of the multiple times that intermediate products cross international borders, to avoid double counting.

This is why several methods have appeared to calculate full decomposition of value added in exports, distinguishing what part of value added is pure value added and which one is double counting, and also, within the pure double counting, what part is really exported and what part eventually returns back to the exporting country (‘false’ exports).

exvatools can then produce key value added indicators (like bilateral value added exports or VAX) that are not currently available in public databases.

Alternative decompositions of value added in exports

There are several methodologies in the economic literature, and exvatools includes the most complete ones: Koopman et al. (2014), Wang et al. (2013), Borin and Mancini (2023) and Miroudot and Ye (2021).

For instance, to create create a full decomposition of value added in exports of Spain using the method of Borin and Mancini (2023), using a source-based approach, we would type::

exvabm <- make_exvadec(wio, exporter = "ESP", method = "bm_src")
#> ℹ Preparing DVA auxiliary matrices...
#> ℹ Calculating DVA terms...
#> ℹ Calculating FVA terms...
#> ℹ Preparing output ...
#> ✔ Done!
#> ======================================================================
#>        DECOMPOSITION OF VALUE ADDED IN EXPORTS OF SPAIN IN 2022
#>                Sector: All sectors
#>                Destination: All countries
#> ======================================================================
#>  VA_components                              USD_MM  Percent
#>  Gross exports of goods and services (EXGR) 4666.96 100.00 
#>    Domestic Content in VA (DC)              2165.17  46.39 
#>      Domestic Value Added (DVA)             1880.60  40.30 
#>        Value Added Exported (VAX)           1624.18  34.80 
#>        Reflection (REF)                      256.41   5.49 
#>      Domestic Double Counting (DDC)          284.58   6.10 
#>    Foreign Content in VA (FC)               2501.78  53.61 
#>      Foreign Value Added (FVA)              2176.21  46.63 
#>      Foreign Double Counting (FDC)           325.58   6.98 
#>  Global Value Chain-related trade (GVC)     4034.25  86.44 
#>  GVC-related trade, backward (GVCB)         2786.36  59.70 
#>  GVC-related trade, forward (GVCF)          1247.89  26.74 
#> ======================================================================
#> Method: Borin and Mancini (2023), source-based, standard output
#> Country perspective, source approach

The advantage is that, once we have obtained a decomposition, we can play with the results in terms of sectors and countries of destination just using the command get_exvadec_bkdown(). For instance, to select the value added in Spanish exports of services (including construction) to the United States, we just have to type:

get_exvadec_bkdown(exvabm, exporter = "ESP", 
                   sector = "SRVWC", importer = "USA")
#> ======================================================================
#>        DECOMPOSITION OF VALUE ADDED IN EXPORTS OF SPAIN IN 2022
#>                Sector: Services, including construction (SRVWC)
#>                Destination: United States (USA)
#> ======================================================================
#>  VA_components                              USD_MM Percent
#>  Gross exports of goods and services (EXGR) 276.71 100.00 
#>    Domestic Content in VA (DC)              159.63  57.69 
#>      Domestic Value Added (DVA)             145.95  52.74 
#>        Value Added Exported (VAX)           127.28  46.00 
#>        Reflection (REF)                      18.67   6.75 
#>      Domestic Double Counting (DDC)          13.68   4.94 
#>    Foreign Content in VA (FC)               117.08  42.31 
#>      Foreign Value Added (FVA)              101.53  36.69 
#>      Foreign Double Counting (FDC)           15.55   5.62 
#>  Global Value Chain-related trade (GVC)     221.62  80.09 
#>  GVC-related trade, backward (GVCB)         130.76  47.26 
#>  GVC-related trade, forward (GVCF)           90.86  32.84 
#> ======================================================================
#> Method: Borin and Mancini (2023), source-based, standard output
#> Country perspective, source approach

An alternative (although with some methodologically limitations) decomposition would be that of Wang et al. (2013). In this case, instead of the normal decomposition, we will use the "terms" output. (that shows the 16 terms that compose the value added in exports):

exvawwz <- make_exvadec(wio, exporter = "all", method = "wwz",
                        output = "terms", quiet = TRUE)

Note that here we have selected export = all, that produces decompositions for all countries (not only a specific one), and we have also used the option quiet = TRUE, that produces a silent output.

We can check any exporting country, any sector, and any destination country. For instance, we can produce the decomposition of the value added in US exports to China for the manufacturing sector:

get_exvadec_bkdown(exvawwz, exporter = "USA", 
                sector = "MANUF", importer = "CHN")
#> ======================================================================
#>    DECOMPOSITION OF VALUE ADDED IN EXPORTS OF UNITED STATES IN 2022
#>                Sector: Manufacturing (MANUF)
#>                Destination: China (CHN)
#> ======================================================================
#>  VA_components                                       USD_MM Percent
#>  EXGR (Gross exports of goods and services)          400.89 100.00 
#>    T01 DVA_FIN (DVA, finals)                          12.79   3.19 
#>    T02 DVA_INT (DVA, interm. for absorption)          13.95   3.48 
#>    T03 DVA_INTrex1 (DVA, int. reexp. for finals 3rd)   8.81   2.20 
#>    T04 DVA_INTrex2 (DVA, interm. for finals reexp.)   36.55   9.12 
#>    T05 DVA_INTrex3 (DVA, interm. for reexp. interm.)  35.08   8.75 
#>    T06 RDV_FIN1 (Reflection, finals from partner)     13.25   3.31 
#>    T07 RDV_FIN2 (Reflection, finals from 3rd cou)      8.62   2.15 
#>    T08 RDV_INT (Reflection, intermediates)             2.19   0.55 
#>    T09 DDC_FIN (Domestic Double Counting, finals)      9.13   2.28 
#>    T10 DDC_INT (Domestic Double Counting, interm.)    23.82   5.94 
#>    T11 FVA_FIN1 (FVA from partner, finals)             6.11   1.52 
#>    T12 FVA_FIN2 (FVA from 3rd countries, finals)      12.33   3.08 
#>    T13 FVA_INT1 (FVA from partner, intermediates)      6.22   1.55 
#>    T14 FVA_INT2 (FVA from 3rd countries, interm.)     12.56   3.13 
#>    T15 MDC (Double Counting, partner)                 66.07  16.48 
#>    T16 ODC (Double Counting, 3rd countries)          133.42  33.28 
#> ======================================================================
#> Method: Wang et al. (2013), terms output
#> Mix of country and world perspective, mix of source and sink approach

Direction of value added in exports: origin and destination

We have seen that the foreign content in Spanish exports amounts to USD 2501.78 million. Where does it come from? If we do not need a detailed breakdown of the value added, but we are interested in knowing the specific geographical and sector origin of the value added content in exports, we can use the command make_exvadir():

exvadir <- make_exvadir(wio, exporter = "ESP", va_type = "FC", 
                        flow_type = "EXGR")

Please note that the exvadir object that we have obtained is different from the exvadec object, in the sense that ‘exporters’ in an exvadir object are the different countries and sectors of origin of the value added included in the exports of the country specified with make_exvadir()(in this case, Spain). We can better understand this by typing summary(exvadir):

summary(exvadir)
#> 
#> ====================================================================== 
#>   ORIGIN AND DESTINATION OF VALUE ADDED IN EXPORTS OF SPAIN IN 2022 
#> ====================================================================== 
#> Value added type: Foreign VA content (FC) 
#> In type of flow: Total gross exports (EXGR) 
#> That goes via country: any 
#> Using inputs from sector: all sectors 
#> Of country: all countries 
#> With sector perspective: exporter 
#> ====================================================================== 
#> 
#> Available countries of origin of VA (G): 6 
#> ESP, FRA, MEX, USA, CHN, ROW 
#>  
#> Available sectors of origin of VA (N): 3 
#> D01T09, D10T39, D41T98 
#>  
#> Available destinations of VA (G): 6 
#> ESP, FRA, MEX, USA, CHN, ROW 
#> 

Get specific data with custom groups

We can use get_data() to summarize the foreign content of Spanish exports, with a breakdown between EU and Non-EU origin (specifying a few countries) and also distinguishing between goods (with utilities) and services. We can also break down the destination of those exports between EU and non-EU:

get_data(exvadir, exporter = c("WLD", "EU27", "FRA",
                               "NONEU27", "USA"),
         sector = c("TOTAL", "GOODSWU", "SRVWC"),
         importer = c("WLD", "EU27", "NONEU27"))
#>                        WLD      EU27    NONEU27
#> WLD_TOTAL       2501.78421 367.55781 2134.22640
#> WLD_GOODSWU     1772.66226 236.16941 1536.49285
#> WLD_SRVWC        729.12195 131.38840  597.73355
#> EU27_TOTAL       340.74928  49.39794  291.35134
#> EU27_GOODSWU     252.80996  33.55120  219.25877
#> EU27_SRVWC        87.93932  15.84674   72.09258
#> FRA_TOTAL        340.74928  49.39794  291.35134
#> FRA_GOODSWU      252.80996  33.55120  219.25877
#> FRA_SRVWC         87.93932  15.84674   72.09258
#> NONEU27_TOTAL   2161.03493 318.15987 1842.87505
#> NONEU27_GOODSWU 1519.85229 202.61821 1317.23408
#> NONEU27_SRVWC    641.18263 115.54166  525.64097
#> USA_TOTAL        433.65389  64.94868  368.70521
#> USA_GOODSWU      286.90179  38.50383  248.39796
#> USA_SRVWC        146.75210  26.44485  120.30725

On the other hand, the flexibility of get_data() allows for the creation of custom-made groups of countries and/or sectors.

For instance, let’s create a group of countries called LATAM, with Spain and Mexico. We would just have to define the variable in the current environment.

LATAM <- c("ESP", "MEX")

And now we can use it as a normal variable, just introducing it as "LATAM" (with double quotes). We will use the wwz decomposition and extract the domestic value added in intermediates (DVA_INT) from LATAM to USA. Note that, if we use custom groups, we need to select the option custom = TRUE in get_data().

get_data(exvawwz, "DVA_INT", exporter = "LATAM", 
         sector = c("TOTAL", "MANUF", "SRVWC"), 
         importer = "USA", custom = TRUE)
#>                  USA
#> LATAM_TOTAL 39.85574
#> LATAM_MANUF 11.80574
#> LATAM_SRVWC 14.75979

Let us now see an example of the exception marker "x", that allows to define exceptions for countries and for sectors. We can, for instance, calculate the NAFTA exports, both intra-regional and extra-regional, employing just two sectors: non-services and services.

get_data(exvawwz, "EXGR", exporter = "NAFTA", 
         sector = c("TOTAL", "TOTALxSRVWC", "SRVWC"), 
         importer = c("WLD", "NAFTA", "WLDxNAFTA"), custom = TRUE)
#>                         WLD    NAFTA WLDxNAFTA
#> NAFTA_TOTAL       13087.740 2602.338 10485.402
#> NAFTA_TOTALxSRVWC  8736.552 1502.340  7234.212
#> NAFTA_SRVWC        4351.188 1099.998  3251.189

Other useful commands

The flexibility of the commands make_exvadir() and get_data() allows for the creation of several ready-made commands in exvatools. One is get_va_exgr(), to get a detailed sector and geographical origin and destination of value added, i.e., how the inputs of specific sectors in specific countries contribute to the value added in exports of a particular sector of a particular country. For instance, if we want to check the value added in US services incorporated in Spanish exports of manufactures, we just have to type:

get_va_exgr(wio,geo_orig = "USA", sec_orig = "SRVWC",
            geo_export = "ESP", sec_export = "MANUF")
#> [1] 51.31605

Sometimes we are not only interested in the origin, but also in the country of final absorption. For that we have get_va_exgry(). For instance, if we want to know what part of the US value added incorporated in China’s exports of manufactures ends up absorbed back in the US, we can type:

get_va_exgry(wio, geo_orig = "USA", geo_export = "CHN",
             sec_export = "MANUF", geo_fd = "USA")
#> [1] 53.81984

At the beginning we manually calculated the value added induced by final demand. There is also a specific command for that in exvatools called get_va_fd(). This allows, for instance, the calculation of the Chinese total value added (or GDP) induced by US final demand for manufactures:

get_va_fd(wio, geo_orig = "CHN", sec_orig = "TOTAL",
          geo_fd = "USA", sec_fd = "MANUF")
#>               WLD
#> CHN_TOTAL 229.385

TiVA useful indicators

Finally, if we want to get a list of common trade indicators (exports, imports, value added, production) similar to those of the TiVA database, we could just use make_exvadec() with the method "oecd" and output = "tiva".

exvativa <- make_exvadec(wio, exporter = "all", method = "oecd",
                         output = "tiva", quiet = TRUE)

And then get the decomposition for Spain:

get_exvadec_bkdown(exvativa, exporter = "ESP")
#> ======================================================================
#>        DECOMPOSITION OF VALUE ADDED IN EXPORTS OF SPAIN IN 2022
#>                Sector: All sectors
#>                Destination: All countries
#> ======================================================================
#>  VA_components                               USD_MM  Percent
#>  Gross exports of goods and services (EXGR)  4666.96 100.00 
#>    Gross exports, finals (EXGR_FNL)          1343.03  28.78 
#>    Gross exports, intermediates (EXGR_INT)   3323.92  71.22 
#>    Gross imports (IMGR)                      5292.12 113.40 
#>    Gross imports, finals (IMGR_FNL)          2386.14  51.13 
#>    Gross imports, intermediates (IMGR_INT)   2905.98  62.27 
#>    Domestic absorption (DOM)                  739.92  15.85 
#>    Domestic absorption, finals (DOM_FNL)      224.26   4.81 
#>    Domestic absorption, interm. (DOM_INT)     515.66  11.05 
#>    Gross balance (BALGR)                     -625.17 -13.40 
#>    Domestic Content in VA (EXGR_DVA)         2165.17  46.39 
#>    Direct domestic VA content (EXGR_DDC)     1757.25  37.65 
#>    Indirect domestic VA content (EXGR_IDC)    123.34   2.64 
#>    Reimported domestic VA content (EXGR_RIM)  284.58   6.10 
#>    Value Added in final demand (FD_VA)       1985.24  42.54 
#>    DVA in dom. final dem. (VAD) (DXD_DVA)     361.05   7.74 
#>    DVA in foreign final dem. (VAX) (FFD_DVA) 1624.18  34.80 
#>    FVA in dom. final dem. (VAM) (DFD_FVA)    2249.35  48.20 
#>    Balance of VA (VAX - VAM) (BALVAFD)       -625.17 -13.40 
#>    Foreign VA Content (EXGR_FVA)             2501.78  53.61 
#>    Backward participation in GVC (DEXFVAP)   2501.78  53.61 
#>    Forward participation in GVC (FEXDVAP)    3047.87  65.31 
#>    Value added (VA)                          1985.24  42.54 
#>    Production (PROD)                         5406.87 115.85 
#> ======================================================================
#> Method: OECD (2022), TiVA output
#> Country perspective, source approach

Available sectors and countries in each input-output edition

To check the information about sectors, it suffices to print info_sec():

info_sec("iciotest")
#> 
#> ======================================================================
#>  Test Input Output Table, ICIO-type, 2022 edition
#> ======================================================================
#> 
#> Individual sectors:
#> PRIMARY: D01T09 (Primary sector), MANUF: D10T39 (Manufacturing),
#> SRVWC: D41T98 (Services, including construction)
#> 
#> Sector groups:
#> TOTAL: D01T98 (Total goods and services), GOODSWU: D01T39 (Goods,
#> total, incl. utilities)

To check the information about available countries, the command is info_geo():

info_geo("iciotest")
#> 
#> ======================================================================
#>  Test Input Output Table, ICIO-type, 2022 edition
#> ======================================================================
#> 
#> Individual countries:
#> FRA (France), MEX (Mexico), ESP (Spain), USA (United States), CHN
#> (China), ROW (Rest of the world)
#> 
#> Groups of countries:
#> WLD (World), EU27 (EU-27), NONEU27 (Non-EU27), NAFTA (NAFTA), USMCA
#> (USMCA)

These commands do not require to have a wio in the environment, so we can just check what sectors are available in the OECD’s ICIO tables, 2023 edition.

info_sec("icio2023")
#> 
#> ======================================================================
#>  OECD's Inter-Country Input-Output Table (ICIO), 2023 edition
#> ======================================================================
#> 
#> Individual sectors:
#> AGR: D01T02 (Agriculture), FSH: D03 (Fishing), MN1: D05T06 (Mining,
#> energy products), MN2: D07T08 (Mining, non-energy products), MN3: D09
#> (Mining, support activities), FOD: D10T12 (Food and beverages), TEX:
#> D13T15 (Textiles and clothing), WOD: D16 (Wood products), PPR: D17T18
#> (Paper products and printing), PET: D19 (Petroleum products), CHM:
#> D20 (Chemical products), PHR: D21 (Pharmaceutical products), RBP: D22
#> (Rubber and plastic products), NMM: D23 (Other non-metalic mineral
#> products), MET: D24 (Basic metals), FMP: D25 (Fabricated metal
#> products), CEO: D26 (Computer, electronic and optical products), ELQ:
#> D27 (Electrical equipment), OMQ: D28 (Other machinery and equipment),
#> VEH: D29 (Motor vehicles), OTQ: D30 (Other transport equipment), OMF:
#> D31T33 (Other manufacturing equipment), EGS: D35 (Electricity and
#> gas), WTR: D36T39 (Water and water treatment), CON: D41T43
#> (Construction), WRT: D45T47 (Wholesale and retail trade), LTP: D49
#> (Land transport), WTP: D50 (Water transport), ATP: D51 (Air
#> transport), STO: D52 (Warehousing and support activities), POS: D53
#> (Post and courier), HTR: D55T56 (Accommodation and food services),
#> PAV: D58T60 (Publishing, audiovisual activities), TEL: D61
#> (Telecommunications), CIS: D62T63 (Computer prog. & information
#> services), FIN: D64T66 (Financial and insurance services), REA: D68
#> (Real estate activities), PRS: D69T75 (Professional activities), ADM:
#> D77T82 (Administrative and support), GOV: D84 (Public admin., defence
#> and social security), EDU: D85 (Education services), HHS: D86T88
#> (Human health and social services), AER: D90T93 (Arts, entertainment
#> services), OSA: D94T96 (Other services), PVH: D97T98 (Private
#> household services)
#> 
#> Sector groups:
#> TOTAL: D01T98 (Total goods and services), GOODSWU: D01T39 (Goods,
#> total, incl. utilities), GOODS: D01T33 (Goods, total), PRIMARY:
#> D01T09 (Primary sector), AGF: D01T03 (Agriculture and fishing),
#> MINWU: D05T09pD35T39 (Mining and utilities), MIN: D05T09 (Mining and
#> quarrying), MANUF: D10T33 (Manufacturing), MNFXPET: D10T33x19
#> (Manufacturing, except coke and petroleum), WPPR: D16T18 (Wood, paper
#> and printing), CHNMP: D20T23 (Chemical, pharma, plastic and
#> non-metallic products), CHPH: D20T21 (Chemical and pharma products),
#> BMMP: D24T25 (Basic metals and metal products), CEOE: D26T27
#> (Computer, electronic, optical and electrical equipment), TREQ:
#> D29T30 (Transport equipment), EGWT: D35T39 (Electricity, gas, water
#> supply), SRVWC: D41T98 (Services, including construction), SERVS:
#> D45T98 (Services), BIZSV: D45T82 (Business services), TPST: D49T53
#> (Transportation and storage), PTL: D53T61 (Post and
#> telecommunications), INFO: D58T63 (Information industries), ITCS:
#> D61T63 (ITC Services), OBZS: D69T82 (Other business services),
#> NONBIZSV: D84T98 (Non-business services), OSPS: D90T98 (Other social
#> and personal services), AEO: D90T96 (Arts, entertainment and other),
#> RDIHI: D21, D28 (R&D Intensity High), RDIMH: D20, D27T30, D62T65 (R&D
#> Intensity Medium-High), RDIME: D22T24, D31T33, D69T77 (R&D Intensity
#> Medium), RDIML: D05T09, D10T19, D25, D58T63 (R&D Intensity
#> Medium-Low), RDILO: D01T03, D35T56, D64T68, D77T82, D90T100 (R&D
#> Intensity Low), RDINM: D84T90 (Non-Market Activities)

Additionally, the commands get_geo_codes() and get_sec_codes provide details about the components of the different groups. These commands are also directly applicable for any available input-output table. For instance, for "wiod2016" we would have the following components of EU27:

get_geo_codes("EU27", wiotype = "wiod2016")
#> [1] "AUT|BEL|CZE|DNK|EST|FIN|FRA|DEU|GRC|HUN|IRL|ITA|LVA|LTU|LUX|NLD|POL|PRT|SVK|SVN|ESP|SWE|BGR|HRV|CYP|MLT|ROU"

And for "icio2023" we have the following components of the business services sector:

get_sec_codes("BIZSV", wiotype = "icio2023")
#> [1] "D45T47|D49|D50|D51|D52|D53|D55T56|D58T60|D61|D62T63|D64T66|D68|D69T75|D77T82"