Coverage status Build Status

grattan

Important temporary notice (2019-02-09): The vignettes do not run on pandoc v2.4 (or take a very long time). Please upgrade to v2.6 (2019-01-30) if building vignettes. You may need to modify the PATH or change the RSTUDIO_PANDOC env. var after installing.

Australian Tax Policy Analysis

Overview

install.packages("grattan")
library(grattan)
## Last change: sysdata.rda at 2019-02-09 16:11:51 (2 mins ago).

income_tax

Calculates the income tax for a given taxable income and financial year:

income_tax(50e3, "2015-16")
## [1] 8547

With sample files

income_tax is designed to work well with the ATO’s sample files. You can obtain the sample files from my repo:

# install.packages("taxstats", repos = "https://hughparsonage.github.io/tax-drat")
library(taxstats)

library(hutils)
library(data.table) 
library(magrittr)
library(ggplot2)

Simply pass the sample file to .dots.ATO and the complexities of things like Medicare levy and the Seniors and Pensioners Tax Offset are handled for you. For example:

s1314 <- as.data.table(sample_file_1314)
s1314 %>%
  .[, tax := income_tax(Taxable_Income, "2013-14", .dots.ATO = s1314)] %>%
  .[, .(Taxable_Income, tax)]
##         Taxable_Income       tax
##      1:           4800     0.000
##      2:         126122 36503.970
##      3:          39742  4655.410
##      4:         108123 29574.355
##      5:          85957 21040.445
##     ---                         
## 258770:          24462  1111.710
## 258771:          37055  3701.525
## 258772:          45024  6530.520
## 258773:           5134     0.000
## 258774:          46368  7007.640

model_income_tax: modelling changes to personal income tax

While income_tax is designed to inflexibly return the tax payable as legislated, model_income_tax is designed to calculate income tax when changes are made. For example,

s1314 %>%
  # reduce top threshold from 180,000 to 150,000
  model_income_tax(ordinary_tax_thresholds = c(0, 18200, 37000, 80000, 
                                               150e3), 
                   baseline_fy = "2013-14") %>%
  .[, .(Taxable_Income, baseline_tax, new_tax)]
##         Taxable_Income baseline_tax   new_tax
##      1:           4800            0     0.000
##      2:         126122        36503 36503.970
##      3:          39742         4655  4655.410
##      4:         108123        29574 29574.355
##      5:          85957        21040 21040.445
##     ---                                      
## 258770:          24462         1111  1111.710
## 258771:          37055         3701  3701.525
## 258772:          45024         6530  6530.520
## 258773:           5134            0     0.000
## 258774:          46368         7007  7007.640

project

Given a sample file, we can project forward a number of years

s1617 <- project(s1314, h = 3L)

or to a particular financial year

s1718 <- project_to(s1314, "2017-18")

Together with model_income_tax, this allows us to make point-predictions of future years. The function revenue_foregone prettily prints the resultant revenue:

sample_file_1314 %>%
  project_to("2018-19") %>%
  model_income_tax(baseline_fy = "2017-18",
                   ordinary_tax_thresholds = c(0, 18200, 37000, 87000, 
                                               150e3)) %>%
  revenue_foregone
## [1] "$1.8 billion"

compare_avg_tax_rates:

Create comparison of average tax rates:

lapply(list("30k" = 30e3,
            "36k" = 36e3,
            "42k" = 42e3),
       function(T2) {
         model_income_tax(s1718,
                          baseline_fy = "2017-18",
                          ordinary_tax_thresholds = c(0, 
                                                      18200,
                                                      T2,
                                                      87000, 
                                                      180e3))
       }) %>%
  rbindlist(idcol = "id",
            use.names = TRUE,
            fill = TRUE) %>%
  compare_avg_tax_rates(baseDT = .[id %ein% "36k"]) %>%
  ggplot(aes(x = Taxable_Income_percentile,
             y = delta_avgTaxRate,
             color = id,
             group = id)) +
  geom_hline(yintercept = 0) +
  geom_line()

Access ABS data

NEWS

1.7.1.0

Bug fixes

New functions:

Enhancements:

Internal

1.7.0.0

Bug fixes

New features

Enhancements

set.seed(19952010)
from_fys <- sample(yr2fy(1995:2010), size = 1e6, replace = TRUE)
microbenchmark(cpi_inflator(from_fy = from_fys, to_fy = "2015-16"))
# Old
Unit: seconds
                                                expr      min      lq     mean   median       uq
 cpi_inflator(from_fy = from_fys, to_fy = "2015-16") 1.519483 1.54438 1.550628 1.549735 1.554507
      max neval
 1.661502   100
 
# New
Unit: milliseconds
                                                expr      min       lq     mean   median       uq
 cpi_inflator(from_fy = from_fys, to_fy = "2015-16") 40.71753 41.94061 47.93162 42.93946 48.08461
      max neval
 191.3497   100

Potentially breaking changes

  #> Last change: NAMESPACE at 2018-08-19 14:47:14 (4 mins ago).
  #> Unit: milliseconds
  #>       expr min  lq mean median  uq max neval cld
  #>   yr2fy(z)  75  88   98     90 101 161   100  a 
  #>  .yr2fy(z) 274 286  298    297 302 359   100   b

Use yr2fy(x, assume1901_2100 = FALSE) if you need the old behaviour.

Misc/Internal

1.6.0.0

2018-05-08

1.5.3.6

2018-02-21

1.5.3.1

2018-01-22

New features:

Other user-visible changes

Data:

Other changes

1.5.2.5

2017-11-16

2017-10-27

1.5.2.3

2017-10-21

1.5.2.0

2017-10-19

1.5.1.2

2017-10-15

2017-08-30

2017-08-16

2017-07-02

CRAN Notes

Test results

0 ERRORS | 0 WARNINGS | 1-2 NOTEs

Test environments:

NOTES:

Possibly mis-spelled words in DESCRIPTION: … ==> Spellings are correct: ‘repos’ and ‘taxstats’ cannot be quoted as they are within R code.

URLs in angle brackets: ==> Not appropriate since the URL is within R code.

Suggests or Enhances not in mainstream repositories: … ==> Normal due to taxstats dependency

Note to CRAN: moderately-large vignette

The vignette is quite lengthy and, while it will run on CRAN, requires the installation of ‘taxstats’, a 58 MB source package, each time the package is checked.