Calculate state and federal taxes using TASXSIM 35.
Source:R/calculate_taxes.R
taxsim_calculate_taxes.Rd
This function calculates state and federal income taxes using the TAXSIM 35 tax simulator. See http://taxsim.nber.org/taxsim35/ for more information on TAXSIM 35. The function uses a compiled WebAssembly (wasm) version of the TAXSIM app that is part of the package to calculate taxes. Details about generating the wasm file can be found here: https://github.com/tmm1/taxsim.js
Arguments
- .data
Data frame containing the information that will be used to calculate taxes. This data set will be sent to TAXSIM. Data frame must have specified column names and data types.
- marginal_tax_rates
Variable to use when calculating marginal tax rates. One of 'Wages', 'Long Term Capital Gains', 'Primary Wage Earner', or 'Secondary Wage Earner'. Default is 'Wages'.
- return_all_information
Boolean (TRUE or FALSE). Whether to return all information from TAXSIM (TRUE), or only key information (FALSE). Returning all information returns 42 columns of output, while only returning key information returns 9 columns. It is faster to download results with only key information.
Value
The output data set contains all the information returned by TAXSIM 35, using the same column names. Descriptions of these columns can be found at the bottom of the page containing TAXSIM 35's documentation.
Formatting your data
In the input data set, .data
, each column is a tax characteristic (year, filing status, income, etc.)
and each row is a tax filing unit.
Columns should take the same names, and fulfill the same requirements, as those needed for TAXSIM 35. Potential columns, with there names and descriptions, can be found at: http://taxsim.nber.org/taxsim35/.
The following columns are required: taxsimid
, year
, mstat
, and state
.
There are two points where taxsim_calculate_taxes
departs from TAXSIM 35.
For filing status,
mstat
, users can either enter the number allowed by TAXSIM 35 or one of the following descriptions:
"single"
"married, jointly"
"married, separately"
"dependent child"
"head of household"
For
state
, users can either enter the SOI code, as required by TAXSIM 35, the two-letter state abbreviation, or the full name of the state.
It is OK if the input data set, .data
, contains columns in addition to the ones that are used by TAXSIM 35.
Giving credit where it is due
The NBER's TAXSIM 35 tax simulator does all tax calculations. This package simply lets users interact with the tax simulator through R. Therefore, users should cite the TASXSIM 35 tax simulator when they use this package in their work:
Feenberg, Daniel Richard, and Elizabeth Coutts, An Introduction to the TAXSIM Model, Journal of Policy Analysis and Management vol 12 no 1, Winter 1993, pages 189-194.
Examples
family_income <- data.frame(
taxsimid = c(1, 2),
state = c('North Carolina', 'NY'),
year = c(2015, 2015),
mstat = c('single', 'married, jointly'),
pwages = c(10000, 100000),
page = c(26, 36)
)
family_taxes <- taxsim_calculate_taxes(family_income)
merge(family_income, family_taxes, by = 'taxsimid')
#> taxsimid state year mstat pwages page fiitax siitax
#> 1 1 North Carolina 2015 single 1e+04 26 -369.12 143.75
#> 2 2 NY 2015 married, jointly 1e+05 36 11437.50 4761.98
#> fica frate srate ficar tfica
#> 1 1530 7.65 5.75 15.3 765
#> 2 15300 25.00 6.45 15.3 7650