-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
282 lines (217 loc) · 11.6 KB
/
Copy pathREADME.Rmd
File metadata and controls
282 lines (217 loc) · 11.6 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
---
title: "US tariffs on China"
author: "Mitsuo Shiota"
date: "2019-04-17"
output:
github_document:
toc: TRUE
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Updated: `r Sys.Date()`
I separated the codes of extracting HTS from USTR site to [another page](Extract-hts-from-USTR.md).
I added an analysis of who pays tariffs in [another page](Who-pays.md).
## Summary
- [Chinese shares in US imports in tariff imposed goods and others in pdf](output/chinese-shares.pdf)
- [Chinese shares in HTS 8 digit imports by tariff schedule (2018) in pdf](output/chinese-shares2.pdf)
I load an rdata file containing tariff lists and an exclusion list, which I have saved in [the separate page](Extract-hts-from-USTR.md). Note that I assume wrongly that granted product exclusion will never expire, as I can't take in expiration information.
Next, I get data via API from [Census Bureau U.S. International Trade Data](https://www.census.gov/foreign-trade/data/), and confirm the each list is really worth 34, 16 and 200 billion dollars respectively.
I calculate the Chinese shares on those tariff-imposed goods, excluded goods and not-imposed goods, and look at the shares movements from January 2017 to now to know how much trade diversion is going. I also draw a boxplot of Chinese shares in HTS 10 digit imports in 2018.
## Libraries and functions
As usual, I attach tidyverse package. As I have found censusapi package works, I use it.
```{r libraries, include=FALSE}
library(tidyverse)
```
Following the recommendation in [Internatinal Trade Data API User Guide](https://www.census.gov/foreign-trade/reference/guides/Guide%20to%20International%20Trade%20Datasets.pdf) provided by the US Census Bureau, I register API Key. I have added a line CENSUS_API_KEY=xxxx to my .Renviron file, and I recall it by `Sys.getenv("CENSUS_API_KEY")`.
```{r census_api_key}
census_api_key <- Sys.getenv("CENSUS_API_KEY")
```
I make functions to facilitate data transformation and acquisition.
```{r self-made functions, echo=FALSE}
# transform df to 4 column df of time, hs10, hs8 and value
sum2hs8 <- function(df) {
df$GEN_CIF_MO <- as.numeric(df$GEN_CIF_MO)
df$time <- as.Date(paste0(df$time, "-01"), "%Y-%m-%d")
df %>%
rename(hs10 = I_COMMODITY,
value = GEN_CIF_MO) %>%
mutate(
hs8 = str_sub(hs10, end = -3L) # cut codes from 10 to 8 digits
) %>%
select(time, hs10, hs8, value) %>%
arrange(hs10, time)
}
# get country import data by year
import_from_country <- function(country, year) {
df <- censusapi::getCensus(
name = "timeseries/intltrade/imports/hs",
key = census_api_key,
vars = c("GEN_CIF_MO", "I_COMMODITY"),
time = year,
CTY_CODE = country,
COMM_LVL = "HS10"
)
df %>%
sum2hs8()
}
# get total import data by year
import_total <- function(year) {
df <- censusapi::getCensus(
name = "timeseries/intltrade/imports/hs",
key = census_api_key,
vars = c("GEN_CIF_MO", "I_COMMODITY"),
time = year,
COMM_LVL = "HS10",
SUMMARY_LVL2="HS"
)
df %>%
sum2hs8()
}
```
## Load tariff lists and an exclusion list
```{r load_tariff_list, echo=TRUE, results="hide", cache=FALSE}
load("data/tariff_list.rdata")
df_list_excl <- tibble(
trf_excl = TRUE,
hs10 = exclusion_list %>% unlist() %>% unique()
) %>%
arrange(hs10)
```
## Get international trade data, and confirm USTR claims
I struggle with which table I should use, and reach [this page](https://www.census.gov/data/developers/data-sets/international-trade.html). Next I struggle with which variables I should use, and reach [this page](https://api.census.gov/data/timeseries/intltrade/imports/hs/variables.html). I experiment a little, and know that GEN_CIF_MO = GEN_VAL_MO + GEN_CHA_MO. Looks like CIF basis = FOB basis + Freight, insurance and other charges. I choose GEN_CIF_MO as import value.
I get to know the country code of China is 5700 from [this page](https://www.census.gov/foreign-trade/schedules/c/countryname.html). OK, let us get data. Each download takes approximately half a minute.
```{r china_2018, echo=FALSE, warning=FALSE, cache=FALSE}
df_china <- import_from_country(country = 5700,
year = "from 2017 to 2024")
df2018 <- df_china %>%
filter(time >= "2018-01-01", time <= "2018-12-01")
real34b <- df2018 %>%
semi_join(df_list_34b, by = "hs8") %>%
summarize(sum = sum(value), .groups = "drop_last") %>%
as.numeric()
real16b <- df2018 %>%
semi_join(df_list_16b, by = "hs8") %>%
summarize(sum = sum(value), .groups = "drop_last") %>%
as.numeric()
real200b <- df2018 %>%
semi_join(df_list_200b, by = "hs8") %>%
summarize(sum = sum(value), .groups = "drop_last") %>%
as.numeric()
real300b_a <- df2018 %>%
semi_join(df_list_300b_a, by = "hs8") %>%
summarize(sum = sum(value), .groups = "drop_last") %>%
as.numeric()
real300b_c <- df2018 %>%
semi_join(df_list_300b_c, by = "hs8") %>%
summarize(sum = sum(value), .groups = "drop_last") %>%
as.numeric()
```
Using the tariff lists of 8 digit HTS codes I extracted before, I check if 2018 imports are really worth as much as 34, 16 and 200 billion dollars as USTR claims. According to my calculation, 2018 imports are `r round(real34b/1000000000, 1)`, `r round(real16b/1000000000, 1)` and `r round(real200b/1000000000, 1)` billion dollars. Ratios to the USTR claims are `r round(real34b/1000000000/34, 2)`, `r round(real16b/1000000000/16, 2)` and `r round(real200b/1000000000/200, 2)`. Little bit smaller, but basically confirm the USTR claims.
2018 imports in List 4 Annex A ("300b_a", effective on September 1, 2019) and Annex C ("300b_c", scheduled to be effective on December 15, 2019, but postponed) are `r round(real300b_a/1000000000, 1)` and `r round(real300b_c/1000000000, 1)` billion dollars respectively.
## How much imports are excluded so far?
```{r how_much_excluded, echo=FALSE}
real_excl <- df2018 %>%
semi_join(df_list_excl, by = "hs10") %>%
summarize(sum = sum(value), .groups = "drop_last") %>%
as.numeric()
```
So far USTR announced exclusion lists `r length(exclusion_list)` times. They specify products simply by HTS 10 digit code, or by product description and HTS 10 digit code it belong to. When I caluculate simply by HTS 10 digit code, exclusions amount to `r round(real_excl/1000000000, 1)` billion dollars annually.
## Look at the Chinese share movements
I get imports from China and total imports from January 2017 up to now, and calculate Chinese shares in imports in each category of "34b", "16b", "200b", "300b_a", "300b_c", "excl", and "rest". "34b", "16b", "200b", "300b_a", "300b_c" are imposed tariffs effective on July 6 2018, August 23 2018, September 24 2018, September 1 2019 and (postponed) December 15 2019, respectively. "excl" is exclusion granted so far. "rest" is the rest.
What can I say from the chart below?
1. Chinese shares are the lowest in 34b, next lowest in 16b, higher in 200b, even higher in 300b_a and much much higer in 300b_c, exactly the same order of imposing tariffs. Actually USTR states that they separate 300b into 300b_a and 300b_c based on whether the Chinese shares are less than 75 percent or not in [this page](https://ustr.gov/sites/default/files/enforcement/301Investigations/Notice_of_Modification_%28List_4A_and_List_4B%29.pdf). USTR tends to choose lower Chinese share goods to impose tariffs first to avoid supply chain distruptions.
1. In both 34b and 16b, Chinese shares rise just before the effective date, and decline thereafter. This pattern reflects that importers rush before and flee after.
1. In 200b, I can see the small same pattern, but see bigger rise in December 2018 just before the tariff rates were scheduled to rise from 10 to 25 percent, and bigger decline thereafter. Looks like importers care little of 10 percent, but care much of 25 percent.
1. Seasonality is observed. Chinese shares fall around March every year, as Chinese take long vacations when their New Year begins around February.
1. China exports declined in February 2020, due to Covid-19 turmoil.
1. In the tariff imposed goods, Chinese shares are declining. This means other countries' shares are rising. Trade diversion is going on. However, there is a caveat.
1. There is a gap between the US data and the Chinese data, probably because importers want to avoid tariffs. (I was impressed by [a tweet by Brad Setser](https://twitter.com/Brad_Setser/status/1667958832667021312)) As I rely on the US data here, China's share in the US imports may be underestimated.
```{r get_data, echo=FALSE, cache=FALSE, fig.width=6, fig.height=8}
# Total import
# get data, takes time
df_total <- import_total("from 2017 to 2024")
# value.x as total, value.y as china
df_total <- df_total %>%
left_join(df_china, by = c("hs10", "time")) %>%
select(-hs8.y) %>%
rename(hs8 = hs8.x)
# add category
df_total <- df_total %>%
left_join(df_list_34b, by = "hs8") %>%
left_join(df_list_16b, by = "hs8") %>%
left_join(df_list_200b, by = "hs8") %>%
left_join(df_list_300b_a, by = "hs8") %>%
left_join(df_list_300b_c, by = "hs8") %>%
left_join(df_list_excl, by = "hs10") %>%
replace_na(list(
trf_34b = FALSE,
trf_16b = FALSE,
trf_200b = FALSE,
trf_300b_a = FALSE,
trf_300b_c = FALSE,
trf_excl = FALSE
)) %>%
mutate(
category_old = if_else(trf_34b, "34b",
if_else(trf_16b, "16b",
if_else(trf_200b, "200b",
if_else(trf_300b_a, "300b_a",
if_else(trf_300b_c, "300b_c", "rest"))))),
category = if_else(trf_excl, "excl", category_old)
) %>%
select(-starts_with("trf_"), -category_old) %>%
rename(
total = value.x,
china = value.y
) %>%
replace_na(list(china = 0))
# Calculate share by category and month
df_total %>%
group_by(category, time) %>%
summarize(
total = sum(total),
china = sum(china),
share = china / total * 100,
.groups = "drop_last"
) %>%
mutate(taxed = if_else(category %in% c("34b", "16b", "200b", "300b_a"),
"Tariffs levied by the Trump Administration", "No tariffs")) %>%
ggplot(aes(x = time, y = share, color = fct_reorder2(category, time, share))) +
geom_line(linewidth = 1) +
expand_limits(y = 0) +
facet_wrap(vars(taxed), ncol = 1, scales = "free_y") +
labs(
title = "Chinese shares in US imports",
x = NULL,
y = "percent",
color = "category"
)
ggsave(filename = "output/chinese-shares.pdf",
width = 6, height = 8, units = "in", dpi = 300)
```
To confirm the point #1 above, I draw the distribution of 2018 Chinese shares in HTS 10 digit goods by each tariff schedule category. Chinese shares in "excl" are much higher than "34b", "16b" and "200b" from which "excl" is excluded. As the shares in "300b_c" (postponed from the scheduled December 15, 2019) are much much higer than those of "excl", USTR will receive massive product exclusion requests.
```{r boxplot, echo=FALSE, warning=FALSE, fig.width=6, fig.height=6}
df_total %>%
mutate(category = factor(category, levels = c("34b", "16b", "200b", "300b_a", "300b_c", "excl","rest"))) %>%
filter(time >= "2018-01-01", time <= "2018-12-01") %>%
group_by(category, hs10) %>%
summarize(
total = sum(total),
china = sum(china),
share = china / total * 100,
.groups = "drop_last"
) %>%
ggplot(aes(x = category, y = share)) +
geom_boxplot() +
labs(
title = "Chinese shares by tariff schedule (2018)",
x = NULL,
y = "percent"
)
ggsave(filename = "output/chinese-shares2.pdf",
width = 6, height = 6, units = "in", dpi = 300)
```
EOL