-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0_joined_PIN_level_data_allyears.qmd
503 lines (376 loc) · 20.7 KB
/
0_joined_PIN_level_data_allyears.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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
---
title: "Create Joined PIN Level Data for each Tax Year"
author: "AWM"
date: "`r Sys.Date()`"
format:
html:
code-fold: true
df-print: paged
---
```{r setup, warning=FALSE, message=FALSE, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(tidyverse)
library(data.table)
library(ptaxsim)
library(glue)
library(DBI)
```
```{r}
options(scipen = 999)
nicknames <- readxl::read_excel("./Necessary_Files/muni_shortnames.xlsx") %>%
mutate(agency_number = as.character(agency_number),
agency_number = str_pad(string = agency_number, width = 9, side = "left", pad ="0"))
ptaxsim_db_conn <- DBI::dbConnect(RSQLite::SQLite(), "./ptaxsim.db/ptaxsim-2023.0.0.db")
#years <-(2021) # testing
years <-(2021:2023)
cross_county_lines <- c("030440000", "030585000", "030890000", "030320000", "031280000",
"030080000", "030560000", "031120000", "030280000", "030340000",
"030150000","030050000", "030180000","030500000", "031210000")
incentive_majorclasses <- c("6", "7A", "7B", "8A", "8B")
commercial_classes <- c(401:435, 490, 491, 492, 496:499,
500:535,590, 591, 592, 597:599,
700:799,
800:835, 891, 892, 897, 899) %>% as.character()
industrial_classes <- c(480:489,493,
550:589, 593,
600:699,
850:890, 893 ) %>% as.character()
is.integer64 <- function(x){
class(x)=="integer64"
}
```
```{r}
for(i in years){
year_variable = i
# PTAXSIM tables ------------------------------------------------
## Municipality taxing agencies only + Cicero
muni_agency_names <- DBI::dbGetQuery(
ptaxsim_db_conn,
"SELECT DISTINCT agency_num, agency_name, minor_type
FROM agency_info
WHERE minor_type = 'MUNI'
OR agency_num = '020060000'
"
)
agency_dt<- dbGetQuery(ptaxsim_db_conn, paste('SELECT * FROM agency WHERE year = ', i, ';'))
agency_dt <- agency_dt %>% mutate_if(is.integer64, as.double)
tax_codes <- dbGetQuery(ptaxsim_db_conn, paste('SELECT DISTINCT tax_code_num, tax_code_rate FROM tax_code WHERE year = ', i, ';'))
# identify tax codes taxed by municipalities:
sql <- "SELECT * FROM tax_code WHERE agency_num IN ({muni_agency_names$agency_num*}) AND year = ?year"
query <- sqlInterpolate(ptaxsim_db_conn, sql, year = i)
muni_tax_codes <- dbGetQuery(ptaxsim_db_conn, glue_sql(query, .con = ptaxsim_db_conn)) |>
select(-year, -agency_rate, - tax_code_rate)
# identify tax codes that collect tif revenue:
tif_distrib <- DBI::dbGetQuery(ptaxsim_db_conn, paste('SELECT * FROM tif_distribution WHERE year = ', i, ';')) |>
select(tax_code_num, tax_code_distribution_pct, tax_code_frozen_eav, tax_code_eav) %>%
mutate(tax_code_distribution_pct = tax_code_distribution_pct/100, # the tif share
)
# Combine tax code information
tc_muninames <- tax_codes %>%
left_join(muni_tax_codes, by = c("tax_code_num")) %>%
left_join(muni_agency_names, by = "agency_num") %>%
left_join(nicknames, by = c("agency_num" = "agency_number")) |>
mutate(tax_code_rate = tax_code_rate/100)#%>% select(-c(minor_type, short_name, agency_number))
# PIN data from pin datatable in PTaxSim. Has total tax bill amount from Treasurer data,
# and exemption values and assessment values from Clerk data
sql <- "SELECT * FROM pin WHERE year = ?year"
query <- sqlInterpolate(ptaxsim_db_conn, sql, year = i)
pin_data <- dbGetQuery(ptaxsim_db_conn, glue_sql(query, .con = ptaxsim_db_conn))
eq_factor <- read_csv("./Necessary_Files/eq_factor.csv") %>%
filter(year == i) %>%
select(eq_factor_final) %>%
as.numeric()
ccao_loa <- read_csv("./inputs/ccao_loa.csv") %>%
mutate(class_code = as.character(class_code)) %>%
filter(year == i) %>%
select(-year) %>%
mutate(loa = as.numeric(loa)) %>%
mutate(loa = ifelse(loa == 0, NA, loa))
# Exemptions at PIN level --------------------------------------------------
# finds all pins within Cook county and data on their exemptions
# joins tax code variable by pin
pin_data <- pin_data |>
mutate_if(is.integer64, as.double ) %>%
left_join(ccao_loa, by = c("class" = "class_code")) %>%
left_join(tc_muninames, by = c("tax_code_num")) |>
left_join(tif_distrib, by ="tax_code_num") |>
mutate(
in_tif = ifelse(tax_code_num %in% tif_distrib$tax_code_num, 1, 0),
tif_tax_code_frozen_eav = ifelse(is.na(tax_code_frozen_eav), 0, tax_code_frozen_eav),
tif_tax_code_eav = ifelse(is.na(tax_code_eav), 0, tax_code_eav), # only TIF taxcodes
tif_tax_code_increment_eav = tif_tax_code_eav - tif_tax_code_frozen_eav,
tif_tax_code_increment_eav = ifelse(tif_tax_code_increment_eav < 0, 0, tif_tax_code_increment_eav),
in_tif_andpays_revtotif = ifelse(in_tif == 1 & tif_tax_code_eav > tif_tax_code_frozen_eav, 1, 0 ),
) |>
mutate(
eq_av = av_clerk*eq_factor,
exe_total = rowSums(across(starts_with("exe_"))),
exe_total = ifelse(exe_total > eq_av, eq_av, exe_total),
# create variables that appear from taxbill() function
taxed_eav = av_clerk*eq_factor - exe_total,
tax_amt_exe = exe_total*tax_code_rate,
tax_amt_pre_exe = av_clerk*eq_factor*tax_code_rate,
tax_amt_post_exe = tax_amt_pre_exe - tax_amt_exe,
tax_amt_post_exe = ifelse(tax_amt_post_exe < 0, 0, tax_amt_post_exe),
final_tax_to_tif = ifelse(!is.na(tif_tax_code_frozen_eav) < !is.na(tif_tax_code_eav),
tax_amt_post_exe*tax_code_distribution_pct, 0),
final_tax_to_dist = (tax_amt_post_exe - final_tax_to_tif),
incent_prop = ifelse(between(class, 600, 899), 1, 0),
res_prop = ifelse(between(class, 200, 399), 1, 0),
c2_prop = ifelse(between(class, 200, 299), 1, 0),
# for A and B property types of commercial and industrial properties
class_1dig = str_sub(class, 1, 1),
class_group = case_when(
(class_1dig == 5 & class %in% commercial_classes) ~ "5A",
(class_1dig == 5 & class %in% industrial_classes) ~ "5B",
class_1dig == 7 & class < 742 ~ "7A",
class_1dig == 7 & class >= 742 ~ "7B",
(class_1dig == 8 & class %in% commercial_classes ) ~ "8A",
(class_1dig == 8 & class %in% industrial_classes ) ~ "8B",
TRUE ~ as.character(class_1dig))) %>%
# NOTE: the number of $0 tax bills identified when using the tax_bill() command from ptaxsim is differnet than using the tax bill total value directly from the pin db table
mutate(zero_bill = ifelse(tax_bill_total == 0, 1, 0)) |>
mutate(flag_missingdata = ifelse(taxed_eav > 1000 & tax_bill_total == 0 & c2_prop == 1, 1, 0)) |>
mutate(exe_missing_disvet = ifelse(taxed_eav > 1000 & tax_bill_total == 0 & c2_prop == 1, taxed_eav, 0)) |>
mutate(taxed_eav_adj = ifelse(taxed_eav > 1000 & flag_missingdata == 1, 0 , taxed_eav),
taxed_eav_AWM = tax_bill_total / tax_code_rate,
taxed_eav_TIFincrement = taxed_eav_AWM *tax_code_distribution_pct,
taxed_eav_nonTIF = taxed_eav_AWM*(1-tax_code_distribution_pct)
) |>
mutate(exe_total_adj = rowSums(across(starts_with("exe_")))- exe_total) # don't double count the total value when summing the values
pin_data <- pin_data |>
mutate(
# all exemptions calculated using original data in pin datatable
all_exemptions = exe_homeowner + exe_senior + exe_freeze + exe_longtime_homeowner +
exe_disabled + exe_vet_returning + exe_vet_dis_lt50 + exe_vet_dis_50_69 + exe_vet_dis_ge70 ,
abatements = exe_abate, #abatements get their own variable
fmv = av_clerk / loa,
fmv = ifelse(is.na(fmv), 0, fmv)) %>%
# Create binary variables for exemptions
mutate(# zero_bill = ifelse(eav <= all_exemptions, 1, 0), ## old way of creating zero bill but has missing vet exemptions data problem
has_HO_exemp = ifelse(exe_homeowner > 0, 1, 0),
has_SF_exemp = ifelse(exe_senior > 0, 1, 0),
has_FR_exemp = ifelse(exe_freeze > 0, 1, 0),
has_LTHO_exemp = ifelse(exe_longtime_homeowner > 0, 1, 0),
has_DI_exemp = ifelse(exe_disabled > 0, 1, 0),
has_VR_exemp = ifelse(exe_vet_returning > 0, 1, 0),
has_DV_exemp = ifelse(exe_vet_dis_lt50 + exe_vet_dis_50_69 + exe_vet_dis_ge70 > 0, 1, 0),
has_DV_exemp_adj = ifelse(exe_missing_disvet > 0 | (exe_vet_dis_lt50 + exe_vet_dis_50_69 + exe_vet_dis_ge70) > 0, 1, 0),
has_AB_exemp = ifelse(exe_abate > 0, 1, 0),
)
## Test Point -------------------------
## add a test and break here if there are any observations with CHECK ME
# pin_data %>%
#
# mutate(
# av = av_clerk,
# final_tax_to_dist = ifelse(in_tif == 0, (taxable_eav-all_exemptions)*tax_code_rate,
# ifelse(in_tif == 1, (taxable_eav-all_exemptions)*tax_code_rate * (1-tax_code_distribution_pct), "CHECK ME")),
# final_tax_to_tif = ifelse(in_tif == 1, (taxable_eav-all_exemptions)*tax_code_rate * tax_code_distribution_pct, 0),
#
# final_tax_to_dist_adj = ifelse(in_tif == 0, (taxable_eav_adj-all_exemptions)*tax_code_rate,
# ifelse(in_tif == 1, (taxable_eav-all_exemptions)*tax_code_rate* (1-tax_code_distribution_pct), "CHECK ME")),
# final_tax_to_tif_adj = ifelse(in_tif == 1, (taxable_eav_adj-all_exemptions)*tax_code_rate * tax_code_distribution_pct, 0)) |>
#
# summarize(n_checkmes = sum(final_tax_to_dist == "CHECK ME"),
# n_checkmesadj = sum(final_tax_to_dist_adj == "CHECK ME"))
# More pin variables ------------------------
pin_data <- pin_data %>%
mutate(
av = av_clerk, # basic av variable is the final assessed value from clerk data
### EXPERIMENTAL COMPARISON of AWM calculations and ptaxsim::taxbill() calculations ------------
# adjusted tax revenue amount. taxed eav is calculated from the total tax bill / tax code rate
# assumes that tax bill amount from Treasurer data is more correct than exemption amounts from Clerk data
# ptaxsim::taxbill() calculates the amount taxed by districts by subtracting exemptions instead of using the tax bill amount directly from the pin db table
final_tax_to_dist_AWM = ifelse(in_tif == 0, (taxed_eav_AWM)*tax_code_rate,
ifelse(in_tif == 1, (taxed_eav_AWM)*tax_code_rate * (1-tax_code_distribution_pct), 0)),
final_tax_to_tif_AWM = ifelse(in_tif == 1, (taxed_eav_AWM-all_exemptions)*tax_code_rate * tax_code_distribution_pct, 0),
# -----------------------
# uses revenue amounts as they would be calculated by ptaxsim::tax_bill()
total_value_eav = ((final_tax_to_dist + final_tax_to_tif)/ tax_code_rate) + all_exemptions + abatements,
taxed_av = taxed_eav / eq_factor, # current value that taxing agencies can tax for their levies
## FMV * assessment rate = AV
taxed_fmv = taxed_av / loa,
#taxed_fmv = ifelse(is.nan(taxed_fmv), 0, taxed_fmv),
fmv = av / loa,
fmv = ifelse(is.na(fmv), 0, fmv),
## untaxable value = exempt EAV from abatements and exemptions
untaxable_value_eav = all_exemptions + abatements +
## TIF increment EAV above frozen EAV, which becomes TIF revenue
(final_tax_to_tif / tax_code_rate) +
## difference between 25% and reduced level of assessment for incentive class properties. Excludes TIF increment when calculating the difference!
ifelse(incent_prop==1, (taxed_av/loa*0.25 - taxed_av)*eq_factor, 0),
# manually adjust untaxable value of class 239 properties
untaxable_value_eav = ifelse(class == 239,
eq_av-taxed_eav, untaxable_value_eav),
untaxable_value_av = untaxable_value_eav / eq_factor,
untaxable_value_fmv = untaxable_value_av / loa,
untaxable_value_fmv = ifelse(is.nan(untaxable_value_av), 0, untaxable_value_av),
exempt_eav_inTIF = ifelse(in_tif == 1 & tif_tax_code_frozen_eav>0,
all_exemptions, 0),
exempt_eav = all_exemptions + abatements, # EAV exempt from taxation due to homestead exemptions and abatements
exempt_fmv = exempt_eav / eq_factor / loa, # FMV exempt from taxation due to homestead exemptions and abatements
fmv_inTIF = ifelse(in_tif==1,
av/loa, 0),
fmv_tif_increment = ifelse(final_tax_to_tif > 0,
((final_tax_to_tif / tax_code_rate) / eq_factor ) / loa, 0),
fmv_incents_inTIF = ifelse(incent_prop == 1 & in_tif == 1,
fmv, 0),
fmv_incents_tif_increment = ifelse(incent_prop == 1 & final_tax_to_tif > 0 ,
((final_tax_to_tif / tax_code_rate) / eq_factor ) / loa, 0),
eav_incents_inTIF = fmv_incents_inTIF * loa * eq_factor,
# tax_amt_exe = all_exemptions*tax_code_rate,
# tax_amt_pre_exe = av_clerk*eq_factor*tax_code_rate,
# tax_amt_post_exe = (av_clerk*eq_factor-all_exemptions)*tax_code_rate
)
write_csv(pin_data, file = paste0("./Output/Dont_Upload/0_joined_PIN_data_", i, "_test.csv"))
# Composite Tax Rate Change for Municipalities -------------------------------------
pin_data <- read_csv(paste0("./Output/Dont_Upload/0_joined_PIN_data_", i, "_test.csv"))
muni_ratechange <- pin_data |>
group_by(clean_name) |>
summarize(
pincount = n(),
pins_withincents = sum(ifelse(class >= 600 & class < 900, 1,0)),
fmv_incentive = sum(ifelse(class >=600 & class <900, fmv, 0), na.rm = TRUE),
#fmv_taxed = sum(taxed_fmv, na.rm=TRUE),
fmv_incents_inTIFs = sum(ifelse(class >=600 & class <900 & final_tax_to_tif > 0, fmv, 0), na.rm = TRUE),
fmv_inTIF = sum(ifelse(final_tax_to_tif > 0, fmv, 0), na.rm=TRUE),
fmv_tif_increment = sum(fmv_tif_increment, na.rm=TRUE),
fmv_untaxable_value = sum(untaxable_value_fmv , na.rm=TRUE),
fmv_exemptions = sum(all_exemptions/eq_factor/loa, na.rm=TRUE),
fmv_abatements = sum(exe_abate/eq_factor/loa, na.rm=TRUE),
zero_bill = sum(zero_bill, na.rm=TRUE),
fmv_residential = sum(ifelse(class %in% c(200:399), fmv, 0), na.rm = TRUE),
fmv_C2 = sum(ifelse(class %in% c(200:299), fmv, 0), na.rm = TRUE),
fmv_industrial = sum(ifelse(class %in% industrial_classes, fmv, 0), na.rm = TRUE),
fmv_commercial = sum(ifelse(class %in% commercial_classes, fmv, 0), na.rm = TRUE),
current_rate_avg = mean(tax_code_rate, na.rm=TRUE),
avg_C2_bill_noexe = mean(ifelse(between(class,200,299) & all_exemptions == 0, (final_tax_to_dist + final_tax_to_tif), NA), na.rm=TRUE),
avg_C2_bill_withexe = mean(ifelse(between(class,200,299) & all_exemptions > 0, (final_tax_to_dist + final_tax_to_tif), NA), na.rm=TRUE),
av_taxed = sum(taxed_av, na.rm = TRUE),
untaxable_value_av = sum(untaxable_value_av, na.rm=TRUE),
av = sum(av),
eav_taxed = sum(taxed_eav, na.rm=T),
eav_untaxable = sum(untaxable_value_eav, na.rm=TRUE),
eav_tif_increment = sum(final_tax_to_tif/tax_code_rate, na.rm=TRUE),
eav_max = sum(fmv*loa*eq_factor, na.rm=TRUE),
fmv = sum(fmv, na.rm=TRUE),
pins_in_class = n(),
all_exemptions = sum(all_exemptions, na.rm=T), # in EAV
exe_homeowner = sum(exe_homeowner),
abatements = sum(exe_abate), # in EAV
eav_incents_inTIFs = sum(ifelse(class >=600 & class <=900 & in_tif == 1, taxed_av*eq_factor, 0), na.rm = TRUE),
final_tax_to_dist = sum(final_tax_to_dist, na.rm=T),
final_tax_to_dist_AWM = sum(final_tax_to_dist_AWM, na.rm=T),
final_tax_to_tif = sum(final_tax_to_tif, na.rm=T),
final_tax_to_tif_AWM = sum(final_tax_to_tif_AWM, na.rm=T),
eav = sum(eq_av, na.rm=T),
new_TEAV_noIncents = sum(ifelse(class >=600 & class < 900,
(taxed_av*eq_factor/loa)*0.25, taxed_av*eq_factor), na.rm=TRUE),
new_TEAV_vacant_noIncents = sum(ifelse(class >=600 & class <900,
0, taxed_av*eq_factor), na.rm=T)
) |>
ungroup() |>
mutate(
new_TEAV_noGHE = eav_taxed + exe_homeowner,
new_TEAV_noExemps = eav_taxed + all_exemptions, # does not include abatements
new_TEAV_noAbates = eav_taxed + abatements, # include only abatements, not other exemption types
# amount of EAV from taxing an additional 15% of the AV if incentive properties didn't exist
forgone_EAV_incent = #class_group %in% incentive_majorclasses,
#incent_prop == "Incentive",
new_TEAV_noIncents - eav_taxed) |>
mutate(
# Absolute maximum TEAV: No Exemptions, no abatements, no TIFS, no Incentive properties
# Commercial and industrial assessed at 25%
TEAV_max = eav_taxed + all_exemptions + abatements + eav_tif_increment + forgone_EAV_incent,
# no exemptions or incentive classifications:
TEAV_neither = eav_taxed + all_exemptions + forgone_EAV_incent,
rate_noExe = final_tax_to_dist / new_TEAV_noExemps,
rate_noGHE = final_tax_to_dist / new_TEAV_noGHE,
rate_noAbate = final_tax_to_dist / new_TEAV_noAbates,
rate_noInc = final_tax_to_dist / new_TEAV_noIncents,
rate_neither = final_tax_to_dist / TEAV_neither,
rate_noTIFs = final_tax_to_dist / (eav_taxed + eav_tif_increment),
rate_vacant = final_tax_to_dist / new_TEAV_vacant_noIncents,
rate_lowest = final_tax_to_dist / TEAV_max,
rate_current = final_tax_to_dist / eav_taxed,
change_noInc = rate_current - rate_noInc,
change_neither = rate_current - rate_neither,
change_noTIF = rate_current - rate_noTIFs,
change_noExe = rate_current - rate_noExe,
change_vacant = rate_current - rate_vacant,
change_lowest = rate_current - rate_lowest
) |>
mutate(across(contains("rate_"), round, digits = 4)) |>
mutate(across(contains("change_"), round, digits = 4))
write_csv(muni_ratechange, paste0("./Output/muni_ratechange_", i, "_test.csv"))
muni_rates <- muni_ratechange |> select(clean_name, current_rate_avg, rate_noExe, rate_current)
# Tax Burden by municipality and major class ---------------
#burden shift calculated using tax code level current tax rates and hypothetical tax rates from policy scenario
mc_burden <- pin_data |>
left_join(muni_rates) |>
# left_join(taxcode_taxrates, by = c("tax_code_num")) |>
group_by(clean_name) |>
mutate(
muni_taxbase = sum(taxed_eav, na.rm=T),
muni_levy = sum(final_tax_to_dist, na.rm = T),
muni_levy_AWM = sum(final_tax_to_dist_AWM, na.rm=T)
) |>
ungroup() |>
group_by(clean_name, class_1dig, muni_taxbase, muni_levy) |>
## calculate taxbase from each major class
## and the amount of taxes currently collected from each
summarize(group_taxbase = sum(taxed_eav, na.rm=T),
group_taxes_current = sum(taxed_eav*rate_current, na.rm=T),
hyp_group_taxbase = sum(taxed_eav + all_exemptions, na.rm = T),
hyp_group_taxes = sum( (taxed_eav + all_exemptions)*rate_noExe, na.rm = T),
avg_rate_formuniMC = mean(tax_code_rate, na.rm=T),
avg_rate_current = mean(rate_current)
) |>
ungroup()|>
mutate(
pct_taxbase = group_taxbase / muni_taxbase,
pct_taxburden_current = group_taxes_current / muni_levy,
hyp_pct_taxburden = hyp_group_taxes / muni_levy) |>
mutate(
burden_shift = (pct_taxburden_current - hyp_pct_taxburden))
write_csv(mc_burden, paste0("./Output/muni_mc_burden_", i, "_test.csv"))
burden_shift <- pin_data |>
filter(class_1dig != 0) |>
mutate(Group = case_when(
class_1dig == 2 ~ "Single-family",
class_1dig == 3 | class_1dig == 9 ~ "Multi-family",
TRUE ~ "Commercial & Industrial"
)) |>
left_join(muni_rates) |>
group_by(clean_name) |>
mutate(muni_levy = sum(final_tax_to_dist, na.rm=TRUE),
muni_taxbase = sum(taxed_eav, na.rm=T)) |>
ungroup() |>
group_by(clean_name, Group, muni_levy, muni_taxbase) |>
## calculate taxbase from each major class
## and the amount of taxes currently collected from each
summarize(group_taxbase = sum(taxed_eav, na.rm = T),
group_taxes_current = sum(taxed_eav * (rate_current), na.rm = T),
hyp_group_taxbase = sum(taxed_eav + all_exemptions, na.rm = T),
hyp_group_taxes = sum((taxed_eav + all_exemptions)*rate_noExe, na.rm = T)) |>
ungroup() |>
mutate(
pct_taxbase_current = group_taxbase / muni_taxbase,
pct_taxburden_current = group_taxes_current/ muni_levy,
hyp_pct_taxburden = hyp_group_taxes / muni_levy) |>
mutate(burden_shift = pct_taxburden_current - hyp_pct_taxburden)
write_csv(burden_shift, paste0("./Output/muni_burden_shift_", i, "_test.csv"))
}
```
Note: The EAV from the pin table is the original EAV (AV \* equalizer) without considering TIFs or exemptions.
taxed eav is the amount of eav that is taxable by local taxing agencies (non-TIF districts). It is the post-exemption amount of EAV.
```{r}
#| eval: false
#| include: false
# check output
mc_burden
burden_shift
muni_ratechange
muni_rates
```