-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincentive_paper_stats_corrs.qmd
419 lines (314 loc) · 11.1 KB
/
incentive_paper_stats_corrs.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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
---
title: "Incentive Classification Time-Series Dataset"
subtitle: "Assessing Data Collinearity and Relationships Over Time"
author: "Michael Van Hulle & Alea Wilbur-Mujtaba"
date: "July 8, 2024"
format:
html:
embed-resources: true
theme: lumen
code-fold: true
code-line-numbers: true
code-overflow: wrap
toc: true
toc-location: left
df-print: paged
knitr:
opts_chunk:
warning: true
message: false
---
```{r setup}
#| output: FALSE
# Load packages
library(tidyverse)
library(corrr)
library(glue)
library(DT)
library(flextable)
library(kableExtra)
library(crosstable)
library(scales)
# Set table formatting defaults
set_flextable_defaults(theme_fun = theme_vanilla,
padding = 2,
#line_spacing = 1,
big.mark = ","
)
options(DT.options = list())
FitFlextableToPage <- function(ft, pgwidth = 6){
ft_out <- ft %>% autofit()
ft_out <- width(ft_out, width = dim(ft_out)$widths*pgwidth /(flextable_dim(ft_out)$widths))
return(ft_out)
}
comm_ind <- read_csv("./Output/comm_ind_PINs_2006to2022_timeseries.csv") %>% group_by(pin) %>% mutate(years_existed = n()) %>% ungroup()
```
```{r runscript, eval = FALSE}
# Run helper file
source("./scripts/helper_pull_comm_ind_allyears.R")
# Remove distracting objects and values from R environment
helper_objects <- ls()
keep <- "comm_ind"
comm_ind <- comm_ind_pins_ever
rm(list = setdiff(helper_objects, keep))
rm(helper_objects, keep)
```
```{r alea_check}
comm_ind |>
# filter(year %in% c("2006", "2011", "2022")) |>
filter(land_use %in% c("Industrial", "Commercial")) |>
# select(year, pin, fmv, incent_prop, land_use) |>
group_by(year, incent_prop) |>
summarize(fmv=sum(fmv)) |>
ggplot() +
geom_line(aes(x=year, y=fmv, color = incent_prop))
comm_ind |>
filter(land_use %in% c("Industrial", "Commercial")) |>
group_by(year, land_use) |>
summarize(av_clerk=sum(av_clerk)) |>
ggplot() +
geom_line(aes(x=year, y=av_clerk, color = land_use))
```
# Data "Quirks"
## Missing Values
We want to make sure that we aren't missing values for key variables and also want to know if the missing values change by year.
These factors are especially salient to determining our ability to assemble a panel data and used fixed effects as opposed to some other form of time-series analysis or spatial analysis.
_Note: 186 tax code rates were accidently excluded before July 7 2024. \nCause: Used taxcodes that are taxed by Municipalities to pull tax codes instead. This caused all PINs from unincorporated areas to not have tax code rates and resulted in many NAs for those PINs._
```{r include = FALSE}
comm_ind %>% filter(is.na(tax_code_rate)) %>% distinct(tax_code_num)
```
```{r}
#| label: tbl-missing_values_all_years
#| tbl-cap: "**Comparison of Select Missing Values Across Years**<br>ALL Commercial and Industrial PINs: 2006, 2012, 2022"
#| tbl-cap-location: top
missing_values_all_years <- comm_ind |>
filter(year %in% c("2006", "2012", "2022")) |>
rename(land_use = land_use) |>
group_by(year) |>
summarize(
"Observations (PIN-Year)" = n(),
"Class Code" = sum(is.na(class)),
"FMV" = sum(is.na(fmv)),
"AV" = first(sum(is.na(av_clerk))),
"Land Use" = first(sum(is.na(land_use))),
"Incentive Dummy" = first(sum(is.na(incent_prop))),
# missing_rate = sum(is.na(tax_code_rate)),
"Tax Code" = first(sum(is.na(tax_code_num)))
)
mvay_long <- missing_values_all_years |>
pivot_longer(
cols = -year,
names_to = "variable",
values_to = "count"
)
mvay_wide = mvay_long |>
pivot_wider(
names_from = year,
values_from = count
)
kable(mvay_wide, format = "html", escape = FALSE) |>
kable_styling(full_width = FALSE) |>
column_spec(1, width = "3cm")
```
Zeroes were imputed for missing values at one point in our analysis, so we also check for excess zero values.
```{r}
#| label: tbl-zero_values_all_years
#| tbl-cap: "**Comparison of Zero Values Across Years**<br>ALL Industrial and Commercial PINs: 2006, 2012, 2022"
#| tbl-cap-location: top
all_year_zero_values <- comm_ind |>
filter(year %in% c("2006", "2012", "2022")) |>
group_by(year) |>
mutate(year_obs = first(n())) |>
ungroup() |>
filter(class != 0) |>
rename(land_use = land_use) |>
group_by(year) |>
summarize(
"Observations (PIN-Year)" = first(year_obs),
"Class Code" = sum(class == "0"),
"FMV" = sum(fmv == "0"),
"AV" = sum(av_clerk == "0"),
"Land Use" = sum(land_use == "0"),
"Incentive Dummy" = sum(incent_prop == "0"),
"Tax Code" = sum(tax_code_num == "0")
)
ayz_long <- all_year_zero_values |>
pivot_longer(
cols = -year,
names_to = "variable",
values_to = "count"
)
ayz_wide = mvay_long |>
pivot_wider(
names_from = year,
values_from = count
)
kable(ayz_wide, format = "html", escape = FALSE) |>
kable_styling(full_width = FALSE) |>
column_spec(1, width = "3cm")
```
## Serial autocorrelations
Depending on our statistical model, we may need to account for serial autocorrelation for some variables across time. This seems likely with AV given the triennial reassessment cycle and will help us determine the number of lags needed in our model.
[To be inserted]
# Correlations
## Correlations: 2006 - 2022 Time Period
Notes:
These correlations are across the entire 2006-2022 time period and are not stratified by year.
```{r}
#| label: tbl-all_year_corrs
#| tbl-cap: "**Correlations of Main Variables**<br>ALL Industrial & Commercial PINs: 2006-2022"
#| tbl-cap-location: top
#| warning: false
row_name_map <- c(
av_clerk = "AV",
fmv = "FMV",
years_existed = "PIN<br>Age",
base_year_fmv_2006 = "FMV<br>(2006)",
base_year_fmv_2011 = "FMV<br>(2011)"
)
col_name_map <- c(
#term = "",
av_clerk = "AV",
years_existed = "PIN<br>Age",
fmv = "FMV",
base_year_fmv_2006 = "FMV<br>(2006)",
base_year_fmv_2011 = "FMV<br>(2011)"
)
vars_4fn <- c(
#"n_pins", "min_fmv_all", "quant25_all_fmv", "quant50_all_fmv", "quant75_all_fmv", "max_fmv_all", "fmv_mean", "fmv", "cty_pins",
# "term",
"av_clerk", "years_existed","fmv", "base_year_fmv_2006",
"base_year_fmv_2011" )
labels_4fn <- c(
#"PIN Count", "Min. FMV", "25th Quantile", "50th Quantile", "75th Quantile", "Max. FMV", "Avg. FMV", "Total FMV", "PIN Count",
# "Variables",
"AV", "PIN<br>Age", "FMV", "FMV<br>2006",
"FMV<br>2011"
)
df_labels <- data.frame(vars_4fn, labels_4fn)
comm_ind$year <- as.factor(comm_ind$year)
corr_matrix <- comm_ind |>
select(av_clerk, fmv, years_existed,
base_year_fmv_2006,
base_year_fmv_2011,
incent_prop, land_use, year) |>
correlate()
corr_matrix <- corr_matrix %>%
# rename(#`Variables` = term,
# `Final AV` = av_clerk, FMV = fmv, `Years PIN Existed` = years_existed) %>%
mutate(Variables = ifelse(term %in% df_labels$vars_4fn, df_labels$labels_4fn, "Need Name")) %>%
select(Variables, everything(), -term)
corr_df_temp_1 <- corr_matrix |>
shave() |>
fashion(decimals = 3)
corr_df <- as.data.frame(corr_df_temp_1)
new_col_names <- c("Variables",
# col_name_map[colnames(corr_df)[-1]]
col_name_map
)
kable(corr_df, format = "html", escape = FALSE, col.names = new_col_names) |>
kable_styling(full_width = FALSE) |>
column_spec(1, width = "3cm")
```
```{r}
#| label: tbl-corr_2006
#| tbl-cap: "**Correlations of Main Variables**<br>ALL Industrial & Commercial PINs: 2006"
#| tbl-cap-location: top
corr_matrix_2006 <- comm_ind |>
filter(year == 2006) |>
select(av_clerk, fmv, years_existed,
base_year_fmv_2006, base_year_fmv_2011
) |>
correlate()
corr_temp_2006 <- corr_matrix_2006 |>
shave() |>
fashion(decimals = 3)
corr_2006 <- as.data.frame(corr_temp_2006)
new_2006_col_names <- c("Variable", col_name_map[colnames(corr_2006)[-1]])
kable(corr_2006, format = "html", escape = FALSE, col.names = new_2006_col_names) |>
kable_styling(full_width = FALSE) |>
column_spec(1, width = "3cm")
```
```{r}
#| label: tbl-corr_2012
#| tbl-cap: "**Correlations of Main Variables**<br>ALL Industrial & Commercial PINs: 2012"
#| tbl-cap-location: top
corr_matrix_2012 <- comm_ind |>
filter(year == 2012) |>
select(av_clerk, fmv, years_existed, base_year_fmv_2006, base_year_fmv_2011) |>
correlate()
corr_temp_2012 <- corr_matrix_2012 |>
shave() |>
fashion(decimals = 3)
corr_2012 <- as.data.frame(corr_temp_2012)
new_2012_col_names <- c("Variable", col_name_map[colnames(corr_2012)[-1]])
kable(corr_2012, format = "html", escape = FALSE, col.names = new_2012_col_names) |>
kable_styling(full_width = FALSE) |>
column_spec(1, width = "3cm")
```
```{r}
#| label: tbl-corr_2022
#| tbl-cap: "**Correlations of Main Variables**<br>ALL Industrial & Commercial PINs: 2022"
#| tbl-cap-location: top
corr_matrix_2022 <- comm_ind |>
filter(year == 2022) |>
select(av_clerk, fmv, years_existed,
base_year_fmv_2006, base_year_fmv_2011
) |>
correlate()
corr_temp_2022 <- corr_matrix_2022 |>
shave() |>
fashion(decimals = 2)
corr_2022 <- as.data.frame(corr_temp_2022)
new_2022_col_names <- c("Variable", col_name_map[colnames(corr_2022)[-1]])
kable(corr_2012, format = "html", escape = FALSE, col.names = new_2022_col_names) |>
kable_styling(full_width = FALSE) |>
column_spec(1, width = "2cm")
```
```{r}
#| label: fig-fmv_baseline_year_strat
#| fig-cap: "Comparison of FMV in 2006 vs. 2022"
#| fig-cap-location: top
comm_ind |>
filter(base_year_fmv_2006 > 0) |>
filter(year == 2022) |>
ggplot() +
geom_point(aes(x = base_year_fmv_2006, y = fmv)) +
theme_classic() +
labs(x = "FMV (2006)", y = "FMV (2022)") +
scale_x_continuous(labels = dollar_format(scale = 1e-6, suffix = "M")) +
scale_y_continuous(labels = dollar_format(scale = 1e-6, suffix = "M")) +
geom_abline(slope = 1, intercept = 0, color = "blue")
```
```{r}
#| label: fig-fmv_baseline_year_2006_incent_strat
#| fig-cap: "Comparison of FMV in 2022 and 2006<br>by Incentive Classification"
#| fig-cap-location: top
comm_ind |>
filter(base_year_fmv_2006 > 0) |>
filter(year == 2022) |>
ggplot() +
geom_point(aes(x = base_year_fmv_2006, y = fmv)) +
theme_classic() +
labs(x = "FMV (2006)", y = "FMV (2022)") +
scale_x_continuous(labels = dollar_format(scale = 1e-6, suffix = "M")) +
scale_y_continuous(labels = dollar_format(scale = 1e-6, suffix = "M")) +
geom_abline(slope = 1, intercept = 0, color = "blue") +
facet_grid(cols = vars(incent_prop))
```
```{r}
#| label: fig-fmv_baseline_year_2011_incent_strat
#| fig-cap: "Comparison of FMV in 2011 vs. 2022<br>by Incentive Classification"
#| fig-cap-location: top
comm_ind |>
filter(base_year_fmv_2011 > 0) |>
filter(year == 2022) |>
ggplot() +
geom_point(aes(x = base_year_fmv_2011, y = fmv)) +
theme_classic() +
labs(x = "FMV (2011)", y = "FMV (2022)") +
scale_x_continuous(labels = dollar_format(scale = 1e-6, suffix = "M")) +
scale_y_continuous(labels = dollar_format(scale = 1e-6, suffix = "M")) +
geom_abline(slope = 1, intercept = 0, color = "blue") +
facet_grid(cols = vars(incent_prop))
```