-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathREADME.Rmd
More file actions
138 lines (106 loc) · 3.9 KB
/
README.Rmd
File metadata and controls
138 lines (106 loc) · 3.9 KB
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
---
output:
md_document:
variant: markdown_github
toc: false
---
[](https://app.codecov.io/github/HughParsonage/grattan?branch=master)
# grattan
Utilities for costing and evaluating Australian tax policy, including high-performance tax and transfer calculators, a fast method of projecting tax collections from ATO sample files, and an interface to common indices from the Australian Bureau of Statistics. Written to support Grattan Institute's Australian Perspectives program.
```{r knitrOpts, include=FALSE}
library(knitr)
opts_chunk$set(dev = 'svg',
fig.path = "man/figures/README_")
```
# Overview
```{r eval=FALSE}
install.packages("grattan")
```
```{r loadPackages}
library(grattan)
```
## `income_tax`
Calculates the income tax for a given taxable income and financial year:
```{r income_tax_1}
income_tax(50e3, "2015-16")
```
### 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:
```{r install_taxstats}
# 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:
```{r income_tax_s1314}
s1314 <- as.data.table(sample_file_1314)
s1314 %>%
.[, tax := income_tax(Taxable_Income, "2013-14", .dots.ATO = s1314)] %>%
.[, .(Taxable_Income, tax)]
```
## `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,
```{r model_income_tax}
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)]
```
## `project`
Given a sample file, we can project forward a number of years
```{r s1617}
s1617 <- project(s1314, h = 3L)
```
or to a particular financial year
```{r s1718}
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:
```{r model1819}
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
```
### `compare_avg_tax_rates`:
Create comparison of average tax rates:
```{r compare-30-37-42-thresholds}
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()
```
# NEWS
```{r NEWS, results='asis', echo=FALSE}
cat(readLines("NEWS.md"), sep = "\n")
```
# CRAN Notes
```{r CRAN-comments, results='asis', echo=FALSE}
cat(readLines("cran-comments.md"), sep = "\n")
```