-
Notifications
You must be signed in to change notification settings - Fork 1
/
sign_rank_1.R
44 lines (31 loc) · 927 Bytes
/
sign_rank_1.R
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
### preamble
library(tidyverse)
### read in the data
trefler <- read_csv("trefler.csv")
### initial setup
# number of countries and factors
no_countries <- trefler %>%
select(country) %>%
n_distinct()
no_factors <- trefler %>%
select(factor) %>%
n_distinct()
# calculating global (world) output per factor, trade balance per factor, and endowments
gdp_w <- trefler %>%
select(gdp) %>%
sum() / no_factors
tradebal_w <- trefler %>%
select(trade_balance) %>%
sum() / no_factors
V_fw <- trefler %>%
select(factor, endowment) %>%
group_by(factor) %>%
summarise(endowment = sum(endowment))
# calculating country shares of consumption
trefler <- trefler %>%
mutate(share = (gdp - trade_balance) / (gdp_w - tradebal_w))
### conduct the sign tests
# final correlation should be 0.28
### test for missing trade
# missing trade should be 0.032
### conduct the rank tests