Advertisement
Guest User

Untitled

a guest
Apr 26th, 2023
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 3.04 KB | None | 0 0
  1. library(tidyverse)
  2. library(haven)
  3. library(fixest)
  4.  
  5. mj <- data.frame(State = c("CO", "WA", "DC", "AK", "OR", "CA", "NV", "ME", "A", "VT", "MI", "IL"), Treatment = c(2012, 2012, 2014, 2014, 2014, 2016, 2016, 2016, 2016, 2018, 2018, 2019))
  6.  
  7. #this is the cleaned version of the UCR's arrest file
  8. #via ICPSR/Jacob Kaplan
  9. #https://www.openicpsr.org/openicpsr/project/102263/version/V15/view
  10. #arrest <- read_dta("ucr_arrests_yearly_alcohol_or_property_crimes_age_1974_2020.dta")
  11.  
  12. #effect on possession and sales
  13. state_cannabis_arrests <- arrest %>%
  14.   filter(!arrest$state_abb %in% c("0", "CZ", "GU", "PR")) %>%
  15.   group_by(year, state_abb) %>%
  16.   summarise(sale_cannabis = sum(sale_cannabis_tot_arrests),
  17.             poss_cannabis = sum(poss_cannabis_tot_arrests),
  18.             population = sum(population)) %>%
  19.   left_join(mj, by = c('state_abb' = 'State'))  %>%
  20.   mutate(Treated = ifelse(is.na(Treatment), F, year > Treatment))
  21.  
  22. etable(feglm(data = state_cannabis_arrests, fml = sale_cannabis ~ Treated | year + state_abb),
  23.        feglm(data = state_cannabis_arrests, fml = poss_cannabis ~ Treated | year + state_abb),
  24.        feglm(data = state_cannabis_arrests, fml = log(sale_cannabis) ~ Treated | year + state_abb),
  25.        feglm(data = state_cannabis_arrests, fml = log(poss_cannabis) ~ Treated | year + state_abb))
  26.  
  27. #effect on total arrests
  28. total_arrest_cols <- arrest %>%
  29.   select(ends_with('tot_arrests')) %>%
  30.   #these appear to be redundant
  31.   select(-gamble_total_tot_arrests, -total_drug_tot_arrests, -poss_drug_total_tot_arrests, -sale_drug_total_tot_arrests) %>%
  32.   colnames()
  33.  
  34. total_arrests <- arrest %>%
  35.   filter(!arrest$state_abb %in% c("0", "CZ", "GU", "PR")) %>%
  36.   select(year, state_abb, population, matches(total_arrest_cols)) %>%
  37.   group_by(year, state_abb) %>%
  38.   summarise(total_arrests = sum(across(ends_with("tot_arrests"))),
  39.             population = sum(population)) %>%
  40.   left_join(mj, by = c('state_abb' = 'State'))  %>%
  41.   mutate(Treated = ifelse(is.na(Treatment), F, year > Treatment))
  42.  
  43. #effect on black arrests
  44.  
  45. black_arrest_cols <- arrest %>%
  46.   select(ends_with('tot_black')) %>%
  47.   #these appear to be redundant
  48.   select(-gamble_total_tot_black, -total_drug_tot_black, -poss_drug_total_tot_black, -sale_drug_total_tot_black) %>%
  49.   colnames()
  50.  
  51. black_arrests <- arrest %>%
  52.   filter(!arrest$state_abb %in% c("0", "CZ", "GU", "PR")) %>%
  53.   select(year, state_abb, population, matches(black_arrest_cols)) %>%
  54.   group_by(year, state_abb) %>%
  55.   summarise(total_black_arrests = sum(across(ends_with("tot_black"))),
  56.             population = sum(population)) %>%
  57.   left_join(mj, by = c('state_abb' = 'State'))  %>%
  58.   mutate(Treated = ifelse(is.na(Treatment), F, year > Treatment))
  59.  
  60. etable(feglm(data = total_arrests, fml = total_arrests ~ Treated | year + state_abb),
  61.        feglm(data = black_arrests, fml = total_black_arrests ~ Treated | year + state_abb),
  62.        feglm(data = total_arrests, fml = log(total_arrests) ~ Treated | year + state_abb),
  63.        feglm(data = black_arrests, fml = log(total_black_arrests) ~ Treated | year + state_abb))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement