-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_main.R
339 lines (282 loc) · 7.71 KB
/
00_main.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
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
333
334
335
336
337
338
339
###############################################################
# load libraries #
###############################################################
# install.packages(
# c(
# "dplyr", "data.table", "sf", "zoo", "ggplot2",
# "readxl", "fixest", "sp", "gstat", "tmap",
# "psych", "openxlsx", "fst", "lemon", "lubridate",
# "scales", "MetBrewer", "tidyr", "qs", "docstring",
# "jsonlite", "haven", "stringr", "ggmap", "cartography"
# )
# )
suppressPackageStartupMessages(
{
library(dplyr)
library(data.table)
library(sf)
library(zoo)
library(ggplot2)
library(readxl)
library(fixest)
library(sp)
library(gstat)
library(tmap)
library(psych)
library(openxlsx)
library(fst)
library(lemon)
library(lubridate)
library(scales)
library(MetBrewer)
library(tidyr)
library(qs)
library(docstring)
library(stringr)
library(ggmap)
library(cartography)
library(broom)
}
)
################################################################
# Globals #
################################################################
immo_version <- "v9"
utmcrs <- 32632
owndpi <- 800
# ggplot theme (line graphs)
owntheme <- ggplot2::theme(
axis.text.x = element_text(size = 14, angle = 45, hjust = 1),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 17, vjust = 2),
axis.text.y = element_text(size = 15),
panel.background = element_rect(colour = "white", fill = "white"),
axis.line = element_line(linewidth = 0.5, linetype = "solid", color = "black"),
legend.key.size = unit(1, "cm"),
legend.text = element_text(size = 15),
axis.ticks.length = unit(0.25, "cm"),
legend.key = element_blank()
)
################################################################
# Path Specification #
################################################################
# directory
main_path <- "N:/Corona_FDZ/Fluglaerm_PT"
# airport related data and general data storage
data_path <- file.path(main_path, "data")
# source of the RED data
data_immo <- file.path(
"M:/_FDZ/RWI-GEO/RWI-GEO-RED/daten/On-site/",
immo_version
)
# source of data on boundaries and regions
data_gebiete <- "M:/_FDZ/interne Daten/Gebietseinheit/"
# source of the coding files
code_path <- file.path(main_path, "code")
# auxiliary code
code_aux <- file.path(main_path, "code/aux_code")
# output path
output_path <- file.path(main_path, "output")
################################################################
# Set Directory #
################################################################
setwd(main_path)
################################################################
# Global functions #
################################################################
# intersection function
source(
file.path(
code_path,
"functions/intersection_function.R"
)
)
# subsetting and intersecting housing data with noise contour (using
# intersection function)
source(
file.path(
code_path,
"functions/housing_cont.R"
)
)
# preparation data for estimation
source(
file.path(
code_path,
"functions/prep_est.R"
)
)
# reading housing data
source(
file.path(
code_path,
"functions/read_housing.R"
)
)
################################################################
# Preparation Files #
################################################################
#----------------------------------------------
# preparation of airport contours
source(
file.path(
code_path,
"01_00_preparation_airport_data.R"
)
)
#----------------------------------------------
# Preparation of raw housing data
# Creates the files: TYPES_prepared.qs (with TYPES equals WK, HK, or WM)
# Preparation of the apartment sales data
source(
file.path(
code_path,
"01_01_preparation_basic_wk.R"
)
)
# Preparation of the houses sales data
source(
file.path(
code_path,
"01_02_preparation_basic_hk.R"
)
)
# Preparation of the apartment rents data
source(
file.path(
code_path,
"01_03_preparation_basic_wm.R"
)
)
#----------------------------------------------
# Combine housing data and contour data for each housing type
# Creates the files: TYPES_contour.qs (with TYPES equals WK, HK, or WM)
source(
file.path(
code_path,
"01_04_preparation_contour_wk.R"
)
)
source(
file.path(
code_path,
"01_05_preparation_contour_hk.R"
)
)
source(
file.path(
code_path,
"01_06_preparation_contour_wm.R"
)
)
#----------------------------------------------
# Add additional control variables to the final housing data sets for each
# housing type (WK, HK, WM)
# Additional variables include: Distance to regional centers and other noise
# sources
# Creates the files: TYPES_complete.qs (with TYPES equals WK, HK, or WM)
source(
file.path(
code_path,
"01_07_preparation_add_variables_wk.R"
)
)
source(
file.path(
code_path,
"01_08_preparation_add_variables_hk.R"
)
)
source(
file.path(
code_path,
"01_09_preparation_add_variables_wm.R"
)
)
#----------------------------------------------
# Preparation of noise data (based on measuring stations)
source(
file.path(
code_path,
"01_10_preparation_aggregation_noise.R"
)
)
################################################################
# Mapping and Descriptives #
################################################################
#----------------------------------------------
# Descriptives for comparing treatment and control region
# Using grid-level data
source(
file.path(
code_path,
"02_01_descriptives_griddata.R"
)
)
#----------------------------------------------
# Descriptives for the housing data
source(
file.path(
code_path,
"02_02_descriptives_housing_data.R"
)
)
#----------------------------------------------
# Descriptives for plotting the airport locations and the contour
source(
file.path(
code_path,
"02_03_descriptives_contour_airport_locations.R"
)
)
#----------------------------------------------
# Plotting the noise data
source(
file.path(
code_path,
"02_04_descriptives_noise_data.R"
)
)
#----------------------------------------------
# Plotting the flight activity data
source(
file.path(
code_path,
"02_05_descriptives_flight_activity.R"
)
)
#----------------------------------------------
# Plotting the stock development
source(
file.path(
code_path,
"02_06_descriptives_stocks_expectations.R"
)
)
################################################################
# Estimation Files #
################################################################
#----------------------------------------------
# Baseline estimation
source(
file.path(
code_path,
"03_01_estimation_baseline.R"
)
)
#----------------------------------------------
# Heterogeneity Analysis
source(
file.path(
code_path,
"03_02_estimation_heterogeneity.R"
)
)
#----------------------------------------------
# Robustness Analysis
source(
file.path(
code_path,
"03_03_estimation_robustness.R"
)
)