-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Democracy.qmd
332 lines (271 loc) · 7.21 KB
/
_Democracy.qmd
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# Data
- Top 1% Data from WID.World
- Democracy and other Data from ANRR
## Imports
```{r}
library(tidyverse)
library(wid)
library(countrycode)
library(plm)
```
## Democracy Data
```{r}
DDCG <- haven::read_dta("data/DDCGdata.dta")
```
Clean the Data
```{r}
DDCG <- DDCG %>%
dplyr::select("country_name","wbcode","dem","y", "yeardem", "year", "demreg")
```
Get the Country Codes from the DDCG to download the respective WID Data
```{r}
iso3 <- DDCG$wbcode %>% unique()
iso2 <- countrycode(iso3,
origin = "iso3c", destination = "iso2c",
custom_match = c(
"NAU" = "NR",
"ROM" = "RO",
"SER" = "RS",
"SIN" = "SG",
"TAW" = "TW",
"UAE" = "AE",
"ZAR" = "CD"
))
```
## 1% Data WID
```{r}
WID <- download_wid(
indicators = "sptinc", # Shares of pre-tax national income
areas = iso2, # In the United States
years = 1960:2010, # Time period: 2010-2015
perc = "p99p100", # Top 1% only
pop = "j", # Population
include_extrapolations = TRUE, # Include extrapolations
)
```
Convert WID to ISO3 Country Codes
```{r}
#| cache: true
WID <- WID %>%
mutate(iso3 = countrycode(country, origin = "iso2c", destination = "iso3c",
custom_match = c(
"NR" = "NAU",
"RO" = "ROM",
"RS" = "SER",
"SG" = "SIN",
"TW" = "TAW",
"AE" = "UAE",
"CD" = "ZAR")
)) %>%
rename(top = value) %>%
#only take values where variable = sptinc992j
filter(variable == "sptinc992j")
```
Merge the two Data Sets
```{r}
data <- DDCG %>%
left_join(WID, by = c("wbcode" = "iso3", "year" = "year")) %>%
select(country_name, wbcode, year, dem, y, yeardem, top, demreg) %>%
mutate(ltop = log(top)) #logarithmize
```
## 1% Fixed Effects Models
Build general model
```{r}
pdf <- pdata.frame(data, index = c("wbcode", "year"))
```
### Simple Model with Log
```{r}
model <- plm(
ltop ~ dem,
data = pdf,
model = "within",
effect = "twoways"
)
summary(model)
```
- 0.07\*100 = 7% change in share= lower share of top 1% rises
- statistically significant
- but R2 is very low (not good at explaining)
- but R2 is in Fix Ef Model not that good at explaining?
### Model with 2 Lags
```{r}
model2 <- plm(
ltop ~ dem + plm::lag(ltop, 1:2),
data = pdf,
model = "within",
effect = "twoways"
)
summary(model2)
```
- coefficient not significant!
- R2 very good because of the lag...
## IV Model
```{r}
iv_model_1 <- plm(
y ~ dem |
plm::lag(demreg,1:4),
data=pdf,
effect = "twoways",
)
summary(iv_model_1)
```
= nope
## shorter time frame
with years from 1980
```{r}
data_t2 <- data %>%
filter(year >= 1980)
```
```{r}
pdf_t2 <- pdata.frame(data_t2, index = c("wbcode", "year"))
model_t2 <- plm(
ltop ~ dem,
data = pdf_t2,
model = "within",
effect = "twoways"
)
summary(model_t2)
```
= nope, similar to normal
## Wealth instead of Income
WID Code = shweal992j
```{r}
WID_wealth <- download_wid(
indicators = "shweal", # Shares of pre-tax national income
areas = iso2, # In the United States
years = 1960:2010, # Time period: 2010-2015
perc = "p99p100", # Top 1% only
pop = "j", # Population
include_extrapolations = TRUE, # Include extrapolations
)
```
Fix
```{r}
WID_wealth <- WID_wealth %>%
mutate(iso3 = countrycode(country, origin = "iso2c", destination = "iso3c",
custom_match = c(
"NR" = "NAU",
"RO" = "ROM",
"RS" = "SER",
"SG" = "SIN",
"TW" = "TAW",
"AE" = "UAE",
"CD" = "ZAR")
)) %>%
rename(top = value) %>%
#only take values where variable = sptinc992j
filter(variable == "shweal992j")
```
```{r}
data_wealth <- DDCG %>%
left_join(WID_wealth, by = c("wbcode" = "iso3", "year" = "year")) %>%
select(country_name, wbcode, year, dem, y, yeardem, top, demreg) %>%
mutate(ltop = log(top)) #logarithmize
```
```{r}
pdf_wealth <- pdata.frame(data_wealth, index = c("wbcode", "year"))
```
Model
```{r}
model_wealth <- plm(
ltop ~ dem,
data = pdf_wealth,
model = "within",
effect = "twoways"
)
summary(model_wealth)
```
## Tests with other Income Shares
### 10%
```{r}
WID10 <- download_wid(
indicators = "sptinc", # Shares of pre-tax national income
areas = iso2, # In the United States
years = 1960:2010, # Time period: 2010-2015
perc = "p90p100", # Top 1% only
pop = "j", # Population
include_extrapolations = TRUE, # Include extrapolations
)
```
Convert WID to ISO3 Country Codes
```{r}
#| cache: true
WID10 <- WID10 %>%
mutate(iso3 = countrycode(country, origin = "iso2c", destination = "iso3c",
custom_match = c(
"NR" = "NAU",
"RO" = "ROM",
"RS" = "SER",
"SG" = "SIN",
"TW" = "TAW",
"AE" = "UAE",
"CD" = "ZAR")
)) %>%
rename(top = value) %>%
#only take values where variable = sptinc992j
filter(variable == "sptinc992j")
```
Merge the two Data Sets
```{r}
data10 <- DDCG %>%
left_join(WID10, by = c("wbcode" = "iso3", "year" = "year")) %>%
select(country_name, wbcode, year, dem, y, yeardem, top)
pdf10 <- pdata.frame(data10, index = c("wbcode", "year"))
```
Simple Model
```{r}
model10_1 <- plm(
log(top) ~ dem,
data = pdf10,
model = "within",
effect = "twoways"
)
summary(model10_1)
```
= similar to before
### 50%
```{r}
WID50 <- download_wid(
indicators = "sptinc", # Shares of pre-tax national income
areas = iso2, # In the United States
years = 1960:2010, # Time period: 2010-2015
perc = "p50p100", # Top 1% only
pop = "j", # Population
include_extrapolations = TRUE, # Include extrapolations
)
```
Convert WID to ISO3 Country Codes
```{r}
WID50 <- WID50 %>%
mutate(iso3 = countrycode(country, origin = "iso2c", destination = "iso3c",
custom_match = c(
"NR" = "NAU",
"RO" = "ROM",
"RS" = "SER",
"SG" = "SIN",
"TW" = "TAW",
"AE" = "UAE",
"CD" = "ZAR")
)) %>%
rename(top = value) %>%
#only take values where variable = sptinc992j
filter(variable == "sptinc992j")
```
Merge the two Data Sets
```{r}
data50 <- DDCG %>%
left_join(WID50, by = c("wbcode" = "iso3", "year" = "year")) %>%
select(country_name, wbcode, year, dem, y, yeardem, top)
pdf50 <- pdata.frame(data50, index = c("wbcode", "year"))
```
Simple Model
```{r}
model50_1 <- plm(
log(top) ~ dem,
data = pdf50,
model = "within",
effect = "twoways"
)
summary(model50_1)
```
= bad at everything