MYI-Tax-Analyzer

JSON CLI Examples
Login

JSON CLI Examples

Examples of Using the JSON CLI to MYI-Tax-Analyzer

This document shows you how to use the JSON CLI to analyze any kind of parametric policy reform under static assumptions.

It is recommended that you follow along with the examples below by executing the runs on your computer as you read. Start following along by reading the JSON CLI documentation and and executing the
myita --test
command.

Below we use the $ character as the command prompt symbol, rather the the > character typical on Windows.

The contents of this document are as follows:

Tabulating the Aggregate Effects of a Simple Reform

In this section, we use the model to estimate the aggregate effects of a 2018 reform that reduces by half the basic relief amount of 9000 ringgit. We specify this reform in a JSON file named reform.json, which looks like this:

$ tacat reform.json
{
    "comment00": "This JSON reform file reduces the basic relief amount",
    "comment01": "from 9000 to 4500 ringgit beginning in 2018.",

    "relief_basic": {"2018": 4500}
}

How did we know that the basic relief amount is called relief_basic? We looked at the language-words file produced by the myita --test command. That file contains a row for each parameter or variable known to the model. We could use the tacat tool to show the full contents of the file on the screen, or read the file in our text editor, or we could show on the screen just the rows that contain the phrase relief by using the tagrep tool as follows:

$ tagrep -e relief language-words
vr relief_alimony real  scalar : Relief for alimony paid
vr relief_bfeed real  scalar : Relief for purchase of breastfeeding equipment
vr relief_childcare real  scalar : Relief for child care expenses
vr relief_dis_equip real  scalar : Relief for basic supporting equipment for disabled
vr relief_educ real  scalar : Relief for education fees
vr relief_insurance real  scalar : Relief for education and medical insurance
vr relief_kids_dis real  scalar : Relief for disabled children
vr relief_kids_o17 real  scalar : Relief for children over age 17 (that is, age 18+)
vr relief_kids_u18 real  scalar : Relief for children under age 18
vr relief_lifeins real  scalar : Relief for life insurance and EPF
vr relief_lifestyle real  scalar : Relief for approved lifestyle expenses
vr relief_medexam real  scalar : Relief for medical examination
vr relief_medexps real  scalar : Relief for medical expenses
vr relief_parent real  scalar : Relief for parent(s)
vr relief_prvtret real  scalar : Relief for private retirement plan & deferred annuity
vr relief_socso real  scalar : Relief for contribution to the SOCSO
vr relief_sspn real  scalar : Relief for net deposit in SSPN saving system
vc relief_total real  scalar : Total relief
pr cap_relief_alimony real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_bfeed real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_childcare real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_dis_equip real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_educ real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_insurance real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_kids_dis real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_kids_o17 real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_kids_u18 real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_lifeins real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_lifestyle real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_medexam real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_medexps real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_medical real indexable scalar : Cap on medexam+medexps allowed as an income deduction
pr cap_relief_parent real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_prvtret real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_socso real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr cap_relief_sspn real indexable scalar : Cap on amount allowed as an income deduction as an amount
pr no_relief_allowed boolean notindexable scalar : true implies no relief amounts used to reduce taxable income
pr po_relief_alimony boolean notindexable scalar : Whether or not alimony relief amount is subject to phaseout
pr po_relief_basic boolean notindexable scalar : Whether or not basic relief amount is subject to phaseout
pr po_relief_bfeed boolean notindexable scalar : Whether or not bfeed relief amount is subject to phaseout
pr po_relief_childcare boolean notindexable scalar : Whether or not childcare relief amount is subject to phaseout
pr po_relief_dis_equip boolean notindexable scalar : Whether or not dis_equip relief amount is subject to phaseout
pr po_relief_disabled_indiv boolean notindexable scalar : Whether or not disabled_indiv relief amount is subject to phaseout
pr po_relief_disabled_spouse boolean notindexable scalar : Whether or not disabled_spouse relief amount is subject to phaseout
pr po_relief_educ boolean notindexable scalar : Whether or not educ relief amount is subject to phaseout
pr po_relief_insurance boolean notindexable scalar : Whether or not insurance relief amount is subject to phaseout
pr po_relief_kids_dis boolean notindexable scalar : Whether or not kids_dis relief amount is subject to phaseout
pr po_relief_kids_o17 boolean notindexable scalar : Whether or not kids_o17 relief amount is subject to phaseout
pr po_relief_kids_u18 boolean notindexable scalar : Whether or not kids_u18 relief amount is subject to phaseout
pr po_relief_lifeins boolean notindexable scalar : Whether or not lifeins relief amount is subject to phaseout
pr po_relief_lifestyle boolean notindexable scalar : Whether or not lifestyle relief amount is subject to phaseout
pr po_relief_medexam boolean notindexable scalar : Whether or not medexam relief amount is subject to phaseout
pr po_relief_medexps boolean notindexable scalar : Whether or not medexps relief amount is subject to phaseout
pr po_relief_parent boolean notindexable scalar : Whether or not parent relief amount is subject to phaseout
pr po_relief_prvtret boolean notindexable scalar : Whether or not prvtret relief amount is subject to phaseout
pr po_relief_socso boolean notindexable scalar : Whether or not socso relief amount is subject to phaseout
pr po_relief_sspn boolean notindexable scalar : Whether or not sspn relief amount is subject to phaseout
pr relief_basic real indexable scalar : Basic relief amount for each tax return
pr relief_disabled_indiv real indexable scalar : Amount allowed as an income deduction
pr relief_disabled_spouse real indexable scalar : Amount allowed as an income deduction
pr relief_po_begin real indexable scalar : Total income beyond which relief amounts subject to linear phaseout begin to be phased out
pr relief_po_end real indexable scalar : Total income at which relief amounts subject to linear phaseout are completely phased out
gd RELIEF real notindexable scalar : Growth difference for RELIEF growth factors, which apply to relief_alimony relief_bfeed relief_childcare relief_dis_equip relief_educ relief_insurance relief_kids_dis relief_kids_o17 relief_kids_u18 relief_lifeins relief_lifestyle relief_medexam relief_medexps relief_parent relief_sspn relief_prvtret relief_socso rebate credit

The rows with vr in the first column describe records variables read by the the model from input data; rows with vc in the first column describe records variables calculated by the model; and rows with pr in the first column describe policy parameters whose value can be changed in a JSON reform file.

How do we use this reform.json file to estimate the effects of the reform? We execute the model using the following command:

$ myita tax.csv 2018 reform.json
INPUT data are extrapolated to 2018 using default growth factors under CurLaw
INPUT data are extrapolated to 2018 using default growth factors under REFORM
Calculations for 2018 use no behavior response logic
Write minimal dump output file tax-18-reform.csv for 2018
Write table output file tax-18-reform.tab for 2018
Write REFORM parameter output file tax-18-reform.par for 2018
Write parameter changes output file tax-18-reform.pch for 2018
Run time is 2.8 seconds

Notice that three output files were written; we are going to focus on the table output. Here are the tables for this model run:

$ tacat tax-18-reform.tab
2018 Weighted CurLaw Totals by CurLaw FullInc Decile
    Returns   FullInc     PITax
       (#m)     (RMb)     (RMb)
 0    0.386      3.87     -0.00
 1    0.386     12.66      0.00
 2    0.386     16.25      0.01
 3    0.386     18.90      0.07
 4    0.386     21.50      0.18
 5    0.386     24.18      0.35
 6    0.386     27.69      0.62
 7    0.386     33.35      1.27
 8    0.386     44.56      3.20
 9    0.386    119.39     20.41
 A    3.861    322.34     26.10
Gini coeff for  pre-tax amount = 0.4435 (fullinc)
Gini coeff for post-tax amount = 0.4066 (aftertax_income)

2018 Weighted Reform Totals by CurLaw FullInc Decile
    Returns   FullInc     PITax
       (#m)     (RMb)     (RMb)
 0    0.386      3.87      0.01
 1    0.386     12.66      0.04
 2    0.386     16.25      0.07
 3    0.386     18.90      0.15
 4    0.386     21.50      0.30
 5    0.386     24.18      0.50
 6    0.386     27.69      0.82
 7    0.386     33.35      1.54
 8    0.386     44.56      3.57
 9    0.386    119.39     20.83
 A    3.861    322.34     27.83
Gini coeff for  pre-tax amount = 0.4435 (fullinc)
Gini coeff for post-tax amount = 0.4064 (aftertax_income)

2018 Weighted Reform Changes by CurLaw FullInc Decile
    Returns   FullInc     PITax
       (#m)     (RMb)     (RMb)
 0    0.386      0.00      0.01
 1    0.386      0.00      0.04
 2    0.386      0.00      0.06
 3    0.386      0.00      0.08
 4    0.386      0.00      0.12
 5    0.386      0.00      0.15
 6    0.386      0.00      0.20
 7    0.386      0.00      0.28
 8    0.386      0.00      0.38
 9    0.386      0.00      0.42
 A    3.861      0.00      1.73

The model estimates that this reform would cause aggregate 2018 PIT liability to rise from 26.10 to 27.83 billion ringgit: an increase of 1.73 billion ringgit or about 6.6 percent.

In all three tables, PIT filers are sorted by pre-reform full (that is, broad-based) income into ten equal-sized groups that are numbered from 0 to 9, with the 0 decile containing filers with the smallest full incomes (averaging about 10,000 ringgit) and the 9 decile containing filers with the largest full incomes (averaging about 309,000 ringgit). These tables can provide a rough idea of the distributional effects of this reform, but we can see the effects better in the graphs produced in the next section.

Visualizing the Distributional Effects of the Reform

The CLI provides three ways to look at the distributional effects of the simple reform discussed in the prior section. We can look at the effective tax rate, the percentage change in tax liability, or the percentage change in after-tax income.

To generate these three graphs, we execute four commands: one to generate the three needed CLI output files, and three to convert each type of output file into a graph. Here is the JSON CLI command and its screen output:

$ myita tax.csv 2018 reform.json --xsetr --xsati --xstax --nodump --notable
INPUT data are extrapolated to 2018 using default growth factors under CurLaw
INPUT data are extrapolated to 2018 using default growth factors under REFORM
Calculations for 2018 use no behavior response logic
Write no dump output file for 2018
Write no table output file for 2018
Write xstax output file tax-18-reform.xst for 2018
Write xsati output file tax-18-reform.xsa for 2018
Write xsetr output file tax-18-reform.xse for 2018
Write REFORM parameter output file tax-18-reform.par for 2018
Write parameter changes output file tax-18-reform.pch for 2018
Run time is 2.2 seconds

To convert the effective tax rate (xsetr) output file to a graph, we use the myiplot tool as follows:

$ myiplot tax-18-reform.xse --format svg
Write tax-18-reform.xse.svg graph file

The generated tax-18-reform.xse.svg file contains the graph, which looks like this:

Effective Tax Rates Before and After the Relief-Reduction Reform xsetr-graph

Another way to look at the distributional effects of this reform is to focus on the reform-induced percentage change in after-tax income, data for which is in the xsati output file. To generate a graph like that, we execute this command:

$ myiplot tax-18-reform.xsa --format svg
Write tax-18-reform.xsa.svg graph file

The generated tax-18-reform.xsa.svg file contains the graph, which looks like this:

Percentage Change in After-Tax Income Caused by the Relief-Reduction Reform xsati-graph

And finally, we can look at the reform-induced percentage change in tax liability, data for which is in the xstax output file. Because low-income filers have small pre-reform tax liabilities, even a small increase in tax liability will translate into a very large percentage increase. To make the graph more useful, we elect to not show the data points for the bottom thirty percent of the income distribution. We do that using the following command:

$ myiplot tax-18-reform.xst --xmin 30 --format svg --silent
Write tax-18-reform.xst.svg graph file

The generated tax-18-reform.xst.svg file contains the graph, which looks like this:

Percentage Change in Tax Liability Caused by the Relief-Reduction Reform xstax-graph

Try reducing the --xmin value below 30 to understand better why we have not shown the bottom thirty percent of the income distribution.