-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathREADME.Rmd
More file actions
271 lines (236 loc) · 10.4 KB
/
README.Rmd
File metadata and controls
271 lines (236 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
---
title: "GVTr"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Global Value Trees in R
This package presents a set of functions to implement the Global Value Tree (GVT) analysis approach of world input-output data (WIOD) developed by:
Zhu Z, Puliga M, Cerina F, Chessa A, Riccaboni M (2015) Global Value Trees. PLoS ONE 10(5): e0126699. <https://doi.org/10.1371/journal.pone.0126699>
The packagae allows you to:
-Load WIOD data for 2000 - 2014
-Create a value added contribution matrix/edgelist/network from the WIOD
-Create a GVT for a root country-industry node
-Plot GVT
## Packages
This package uses a number of other packages.
```{r packages,eval=FALSE}
library(igraph)
library(dplyr)
library(plyr)
library(ggplot2)
library(GGally)
library(intergraph)
library(sna)
library(decompr)
#Install this package:
#library(devtools)
#devtools::install_github("MatthewSmith430/GVTr")
library(GVTr)
```
```{r packagesRUN,eval=TRUE,echo=FALSE,results='hide',cache=TRUE,message=FALSE,warning=FALSE}
library(igraph)
library(dplyr)
library(plyr)
library(ggplot2)
library(GGally)
library(intergraph)
library(sna)
library(decompr)
library(GVTr)
```
## Load Data
You can load the WIOD using the following:
```{r data,eval=FALSE}
data("wiot2000")
```
This load in the world-input output table, in the above example, this is loaded for the year 2000 (years 2000-2014 are currently available).
## Value Added Contribution matrix/edgelist/network
The following functions creates a value added contribution objects from the wiot data.
```{r VAC,eval=FALSE}
EL<-VACel(wiot2000) #Value added contribution edgelist
NET<-VACnet(wiot2000) #Value added contribution network
MAT<-VACmat(wiot2000) #Value added contribution matrix
```
## GVT - Tree Prune
This command creates a Global Value Tree (as an igraph object) for specific root country-industry node. In creating this GVT - we examine the ties incoming, directed towards the root node.
The edge threshold is employed as the complete and unfiltered Global Value Network is almost completely connected, therefore an edge threshold aids in helping retain only the more important value added ties. This produces a tree that shows the upstream value system of the country-industry. We only have a function for the upstream value system in the first instance, as upstream ties are noted to be more important for many manufacturing sectors, such as the automotive sector.
For the `GVTprune` function, you need to specify the wiot data (that can be loaded using the package)edge threshold,root country-sector node, (see <http://www.wiod.org/release16> for data description and coverage details) and the maximum number of layers to be included in the GVT.
```{r TreePrune,eval=FALSE}
#Example Root Node - USA Automotive Sector
USAauto<-GVTprune(wiot2000,0.019,"USA.C29",5)
```
## Plots
There are two plot options that come with this package.
1.) Tree Plot - uses a tree layout to plot the GVT
2.) Standard network layout
### Tree Plot
In the tree plot, the nodes are coloured by country or industry. The root node is at the top of the tree. You need to specify the GVT (calculated using `GVTprune`) and what you want the colour to be country/industry.
```{r TreePlot,eval=TRUE}
library(GVTr)
library(igraph)
library(plyr)
##Load Data
data("wiot2000")
##Create Tree
USAauto<-GVTprune(wiot2000,0.019,"USA.C29",5)
##Create Plot
gvtBasePlot(USAauto,"country")
```
The `pryr` package can be used to plot a panel of tree plots, showing visualisation of the same tree over time, or showing tree in the same sector for different countries. Below is the example of a panel of plots for the USA auto sector over time.
```{r TreePlotCOW,eval=TRUE,message=FALSE,warning=FALSE}
library(GVTr)
library(igraph)
library(pryr)
##Load Data
data("wiot2000")
data("wiot2004")
data("wiot2008")
##Create Trees
USAauto2000<-GVTprune(wiot2000,0.019,"USA.C29",5)
USAauto2004<-GVTprune(wiot2004,0.019,"USA.C29",5)
USAauto2008<-GVTprune(wiot2008,0.019,"USA.C29",5)
##Create & save plots using gvtBasePlot & pryr
p1 %<a-% {
gvtBasePlot(USAauto2000,"country")
}
p2 %<a-% {
gvtBasePlot(USAauto2004,"country")
}
p3 %<a-% {
gvtBasePlot(USAauto2008,"country")
}
##Plot GVTs
split.screen(c(1, 3))
screen(1)
p1
screen(2)
p2
screen(3)
p3
close.screen(all=TRUE)
```
### Standard Plot
In this plot, the network takes a more typical layout (and not a tree layout). Node are coloured on the basis of country, and ties colour indicates whether links are intra or inter country. You need to specify the GVT (calculated using `GVTprune`) and whether labels are present (TRUE/FALSE).
```{r BasePlot,eval=TRUE,message=FALSE,warning=FALSE}
library(GVTr)
library(ggplot2)
library(GGally)
##Load Data
data("wiot2000")
##Create Tree
USAauto<-GVTprune(wiot2000,0.019,"USA.C29",5)
##Create Plot
GVTplot(USAauto,FALSE)
```
### Additional Plots
There are additional plot functions, that use other packages, that with specialised functions to plots tree strucutres. The example we present here is the `networkD3` package, and draw on `data.tree` for processing the data into the correct form.
```{r netD3,eval=FALSE}
library(GVTr)
library(networkD3)
library(data.tree)
library(igraph)
##Load Data
data("wiot2008")
##Create Tree
USAauto<-GVTprune(wiot2008,0.019,"USA.C29",5)
##Use data.tree to process the data into a hierarchical
##list that can be ploted with networkD3
GVTdf<-get.data.frame(USAauto) ##Get data frame from igraph objecy
tree1 <- FromDataFrameNetwork(GVTdf)
tree2 <- ToListExplicit(tree1, unname = TRUE) ##identify root node of tree
###The following commands with produce html visualisations
##Diagonal Plot
diagonalNetwork(tree2,nodeColour = "red")
##Radial Plot
radialNetwork(List = tree2,
nodeColour = "blue",
fontSize = 6, opacity = 0.9)
```
# Coverage
Below is the coverage of the 2016 WIOD release. It lists the sectors covered - including the sector code and corresponding description. The country coverage lists the countries codes covered and the full country name.
## Sector Coverage
| **Sector Code** | **Description** |
| :---: | :--- |
| A01 | Crop and animal production, hunting and related service activities |
| A02 | Forestry and logging |
| A03 | Fishing and aquaculture |
| B | Mining and quarrying |
| C10-C12 | Manufacture of food products, beverages and tobacco products |
| C13-C15 | Manufacture of textiles, wearing apparel and leather products |
| C16 | Manufacture of wood and of products of wood and cork, except furniture; manufacture of articles of straw and plaiting materials |
| C17 | Manufacture of paper and paper products |
| C18 | Printing and reproduction of recorded media |
| C19 | Manufacture of coke and refined petroleum products |
| C20 | Manufacture of chemicals and chemical products |
| C21 | Manufacture of basic pharmaceutical products and pharmaceutical preparations |
| C22 | Manufacture of rubber and plastic products |
| C23 | Manufacture of other non-metallic mineral products |
| C24 | Manufacture of basic metals |
| C25 | Manufacture of fabricated metal products, except machinery and equipment |
| C26 | Manufacture of computer, electronic and optical products |
| C27 | Manufacture of electrical equipment |
| C28 | Manufacture of machinery and equipment n.e.c. |
| C29 | Manufacture of motor vehicles, trailers and semi-trailers |
| C30 | Manufacture of other transport equipment |
| C31_C32 | Manufacture of furniture; other manufacturing |
| C33 | Repair and installation of machinery and equipment |
| D35 | Electricity, gas, steam and air conditioning supply |
| E36 | Water collection, treatment and supply |
| E37-E39 | Sewerage; waste collection, treatment and disposal activities; materials recovery; remediation activities and other waste management services |
| F | Construction |
| G45 | Wholesale and retail trade and repair of motor vehicles and motorcycles |
| G46 | Wholesale trade, except of motor vehicles and motorcycles |
| G47 | Retail trade, except of motor vehicles and motorcycles |
| H49 | Land transport and transport via pipelines |
| H50 | Water transport |
| H51 | Air transport |
| H52 | Warehousing and support activities for transportation |
| H53 | Postal and courier activities |
| I | Accommodation and food service activities |
| J58 | Publishing activities |
| J59_J60 | Motion picture, video and television programme production, sound recording and music publishing activities; programming and broadcasting activities |
| J61 | Telecommunications |
| J62_J63 | Computer programming, consultancy and related activities; information service activities |
| K64 | Financial service activities, except insurance and pension funding |
| K65 | Insurance, reinsurance and pension funding, except compulsory social security |
| K66 | Activities auxiliary to financial services and insurance activities |
| L68 | Real estate activities |
| M69_M70 | Legal and accounting activities; activities of head offices; management consultancy activities |
| M71 | Architectural and engineering activities; technical testing and analysis |
| M72 | Scientific research and development |
| M73 | Advertising and market research |
| M74_M75 | Other professional, scientific and technical activities; veterinary activities |
| N | Administrative and support service activities |
| O84 | Public administration and defence; compulsory social security |
| P85 | Education |
| Q | Human health and social work activities |
| R_S | Other service activities |
| T | Activities of households as employers; undifferentiated goods- and services-producing activities of households for own use |
| U | Activities of extraterritorial organizations and bodies |
## Country Coverage
| **Country Code** | **Country Name** | **Country Code** | **Country Name** |
| :---: | :---: | :---: | :---: |
| AUS | Australia | IRL | Ireland |
| AUT | Austria | ITA | Italy |
| BEL | Belgium | JPN | Japan |
| BGR | Bulgaria | KOR | Korea |
| BRA | Brazil | LTU | Lithuania |
| CAN | Canada | LUX | Luxembourg |
| CHE | Switzerland | LVA | Latvia |
| CHN | China | MEX | Mexico |
| CYP | Cyprus | MLT | Malta |
| CZE | Czech Republic | NLD | Netherlands |
| DEU | Germany | NOR | Norway |
| DNK | Denmark | POL | Poland |
| ESP | Spain | PRT | Portugal |
| EST | Estonia | ROU | Romania |
| FIN | Finland | ROW | Rest of the world |
| FRA | France | RUS | Russia |
| GBR | Great Britain | SVK | Slovakia |
| GRC | Greece | SVN | Slovenia |
| HRV | Croatia | SWE | Sweden |
| HUN | Hungary | TUR | Turkey |
| IDN | Indonesia | TWN | Taiwan |
| IND | India | USA | United States of America |