forked from common2016/MeasureGVC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
206 lines (206 loc) · 5.93 KB
/
.Rhistory
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
usethis::use_data_raw('reg')
library(decompr)
?load_tables_vectors
source('E:/27_MyRPackages/MeasureGVC/data-raw/reg.R', echo=TRUE)
View(decompr_object)
str(decompr_object)
decompr_object[["X"]]
library(matlab)
hatx <- matrix(0,9,9)
diag(hatx) <- out
diag(hatx) <- out
inter %*% solve(hatx)
decompr_object[["Am"]]
# test Vc
colSums(inter)
# test Vc
out - colSums(inter)
# test Vc
va <- out - colSums(inter)
va %*% solve(hatx)
decompr_object[["L"]]
A <- inter %*% solve(hatx)
# test L
solve(eye(3)- A[1:3,1:3])
# test ESR
decompr_object$Am %*% out
# test ESR
decompr_object$Am %*% out + decompr_object$Ym
decompr_object$Ym
decompr_object[["Yd"]]
decompr_object[["Y"]]
decompr_object[["Yd"]]
decompr_object[["Ym"]]
# test ESR
decompr_object$Am %*% out + rowSums(decompr_object$Ym)
decompr_object[["E"]]
decompr_object$Am %*% out
decompr_object[["Ym"]]
rowSums(decompr_object[["Yd"]])
decompr_object$Am %*% out
rowSums(decompr_object[["Yd"]]) + rowSums(decompr_object$Ym)
decompr_object$Am %*% out
decompr_object$Eint
rowSums(decompr_object$Eint)
# test ESR
Eint <- decompr_object$Am %*% out
Efd <- rowSums(decompr_object$Ym)
Eint + Efd
source('E:/27_MyRPackages/MeasureGVC/data-raw/draft.R', echo=TRUE)
colSums(hatv %*% wwz$L %*% wwz$Am %*% wwz$B %*% haty)
up <- colSums(hatv %*% wwz$L %*% wwz$Am %*% wwz$B %*% haty)/(wwz$Vc %*% wwz$B %*% haty)
which((wiot$IndustryCode %in% 'C19') & (wiot$Country %in% 'CHN'))
View(up)
library(gvc)
a <- upstream(wwz)
View(wwz)
wwz[["Am"]]
?decomp
?load_tables_vectors
library(devtools)
use_package('decompr')
wwz$k
data.frame(wwz$k[1],wwz$i)
a <- data.frame(wwz$k[1],wwz$i)
View(a)
wwz$G
a <- lapply(1:wwz$G, function(i) data.frame(wwz$k[i],wwz$i))
View(a)
a[[1]]
view(a[[1]])
a <- lapply(1:wwz$G, function(i) data.frame(cnts = wwz$k[i],industry = wwz$i))
View(a)
a <- dplyr::bind_rows(lapply(1:wwz$G, function(i) data.frame(cnts = wwz$k[i],industry = wwz$i)))
View(a)
id <- dplyr::bind_rows(lapply(1:wwz$G, function(i) data.frame(cnts = wwz$k[i],industry = wwz$i)))
# down stream and up stream
ans <- dplyr::bind_rows(lapply(1:wwz$G, function(i) data.frame(cnts = wwz$k[i],industry = wwz$i)))
ans$down <- as.numeric(dw)
View(ans)
ans$up <- as.numeric(up)
rm(list = ls())
library(matlab)
library(decompr)
library(reshape2)
library(tidyverse)
devtools::load_all()
load('data-raw/wiot_r_Nov16/WIOT2014_October16_ROW.RData')
# contries, industries, inter
cnts <- unique(wiot$Country)[-45]
indus <- wiot$IndustryDescription[1:56]
G <- length(cnts)
N <- length(indus)
z <- select(wiot[1:(G*N),],AUS1:ROW56) %>% as.matrix()
# final demand
ymed <- select(wiot[1:(G*N),],AUS57:ROW61)
ysum <- function(country){
ans <- select(ymed, contains(country)) %>% rowSums()
}
ans <- lapply(cnts, ysum)
ans <- bind_cols(ans)
names(ans) <- cnts
y <- as.matrix(ans)
# output
out <- wiot$TOT[1:(G*N)]
# get basic data
wwz <- load_tables_vectors(z, y, cnts, indus, out)
ans <- partici_idx(wwz,'forward')
View(ans)
check()
use_package("matlab")
document()
check()
use_gpl3_license()
?use_gpl3_license
use_gpl3_license('P. Chen')
check()
use_package('dplyr')
check()
?install_github
devtools::install_github('common2016/MeasureGVC')
source('E:/27_MyRPackages/MeasureGVC/data-raw/ReproductWang2017.R', echo=TRUE)
View(dw)
dw[(dw$cnts %in% c('CHN','DEU','IND')) & (dw$industry %in% c('Manufacture of coke and refined petroleum products
')),]
(dw$industry %in% c('Manufacture of coke and refined petroleum products
')
(dw$industry %in% c('Manufacture of coke and refined petroleum products
'))
?filter
filter(dw, cnts %in% c('CHN','DEU','IND'))
filter(dw, cnts %in% c('CHN','DEU','IND') & industry %in% c('Manufacture of coke and refined petroleum products
'))
filter(dw, cnts == c('CHN','DEU','IND') & industry == c('Manufacture of coke and refined petroleum products
'))
ans <- filter(dw, cnts %in% c('CHN','DEU','IND'))
View(ans)
ans <- filter(dw, (cnts %in% c('CHN','DEU','IND')) &(industry %in% c("Education")))
View(dw)
ans <- filter(dw, (cnts %in% c('CHN','DEU','IND')) &(industry %in% c("Manufacture of coke and refined petroleum products")))
dw$industry[10]
ans <- filter(dw, (cnts %in% c('CHN','DEU','IND')) &(industry %in% c("Manufacture of coke and refined petroleum products ")))
View(ans)
filter(dw, (cnts %in% c('CHN','DEU','IND','JPN','RUS','USA')) &
(industry %in% c("Manufacture of coke and refined petroleum products ")))
filter(dw, (cnts %in% c('CHN','DEU','IND','JPN','RUS','USA')) &
(industry %in% c("Manufacture of machinery and equipment n.e.c.")))
filter(dw, (cnts %in% c('CHN','DEU','IND','JPN','RUS','USA')) &
(industry %in% c("Manufacture of coke and refined petroleum products ")))
filter(dw, (cnts %in% c('CHN','DEU','IND','JPN','RUS','USA')) &
(industry %in% c("Manufacture of machinery and equipment n.e.c.")))
filter(up, (cnts %in% c('CHN','DEU','IND','JPN','RUS','USA')) &
(industry %in% c("Manufacture of coke and refined petroleum products ")))
filter(up, (cnts %in% c('CHN','DEU','IND','JPN','RUS','USA')) &
(industry %in% c("Manufacture of machinery and equipment n.e.c.")))
library(devtools)
example(decompr::load_tables_vectors)
example(decompr::load_tables_vectors())
library(decompr)
example("load_tables_vectors")
wwz <- decompr_object
wwz$Yd
devtools::load_all()
partici_idx(wwz, 'inner')
devtools::load_all()
partici_idx(wwz, 'inner')
devtools::load_all()
partici_idx(wwz, 'inner')
library(devtools)
document()
?partici_idx
?data
document()
check()
check()
check()
document()
?partici_idx
library(devtools)
use_readme_rmd()
data(leather)
library(decompr)
data("leather")
?load_tables_vectors
# create intermediate object (class decompr)
decompr_object <- load_tables_vectors(inter,
final,
countries,
industries,
out)
decompr_object <- load_tables_vectors(leather)
partici_idx(decompr_object, 'inner')
library(MeasureGVC)
partici_idx(decompr_object, 'inner')
library(MeasureGVC)
library(decompr)
data(leather)
# create intermediate object (class decompr)
decompr_object <- load_tables_vectors(leather)
partici_idx(decompr_object, 'inner')
document()
check()
check()
?FAVAR::FAVAR
check()
library(ggplot2)
?scale_x_continuous