Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. library(dplyr)
  2. library(dtplyr)
  3. library(magrittr)
  4. library(data.table)
  5. library(taxstats)
  6. library(grattan)
  7.  
  8. MYEFO <-
  9. data.table(fy_year = yr2fy(2017:2020),
  10. r = c(0.023, 0.025, 0.033, 0.035))
  11.  
  12. Pessimistic <-
  13. data.table(fy_year = yr2fy(2017:2020),
  14. r = c(0.021, 0.021, 0.031, 0.031))
  15.  
  16. tax_by_scenario <- function(FY, assumption = c("MYEFO", "Pessimistic")){
  17. h <- as.integer(fy2yr(FY) - 2013L)
  18. assumption <- match.arg(assumption)
  19. if (assumption == "MYEFO"){
  20. sample_file_MYEFO <-
  21. sample_file_1213 %>%
  22. copy %>%
  23. project(fy.year.of.sample.file = "2012-13", h = h, wage.series = MYEFO)
  24.  
  25. tax_collected <-
  26. sample_file_MYEFO %$%
  27. sum(income_tax(Taxable_Income,
  28. fy.year = "2016-17",
  29. .dots.ATO = copy(sample_file_MYEFO)) * WEIGHT) / 1e9
  30. } else {
  31. sample_file_Pessimistic <-
  32. sample_file_1213 %>%
  33. copy %>%
  34. project(fy.year.of.sample.file = "2012-13", h = h, wage.series = Pessimistic)
  35.  
  36. tax_collected <-
  37. sample_file_Pessimistic %$%
  38. sum(income_tax(Taxable_Income,
  39. fy.year = "2016-17",
  40. .dots.ATO = copy(sample_file_Pessimistic)) * WEIGHT) / 1e9
  41. }
  42. return(tax_collected)
  43. }
  44.  
  45. Answer <-
  46. CJ(FY = yr2fy(2017:2020), Assumption = c("MYEFO", "Pessimistic")) %>%
  47. as.data.frame %>%
  48. rowwise %>%
  49. mutate(tax = tax_by_scenario(FY, Assumption))
  50.  
  51. Answer %>%
  52. fwrite("~/outbox/Tax-collected-billions-by-fy-year-and-assumptions.csv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement