Title: | Calculate Federal and State Income Taxes in the United States |
---|---|
Description: | Calculates federal and state income taxes in the United States. It acts as a wrapper to the NBER's TAXSIM 35 (<http://taxsim.nber.org/taxsim35/>) tax simulator. TAXSIM 35 conducts the calculations, while 'usincometaxes' prepares the data for TAXSIM 35, sends the data to TAXSIM 35's server or communicates with the Web Assembly file, retrieves the data, and places it into a data frame. All without the user worrying about this process. |
Authors: | Shane Orr [aut, cre, cph], Thomas Wells [ctb] |
Maintainer: | Shane Orr <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.7.1 |
Built: | 2025-02-26 04:00:58 UTC |
Source: | https://github.com/shanejorr/usincometaxes |
The usincometaxes
package is a single function packages that calculates state and federal income
taxes in the United State. It relies on the NBER's TAXSIM 35 tax calculator for the calculations.
See https://taxsim.nber.org/taxsim35/ for more information on TAXSIM 35.
Maintainer: Shane Orr [email protected] [copyright holder]
Other contributors:
Thomas Wells [email protected] [contributor]
Useful links:
Report bugs at https://github.com/shanejorr/usincometaxes/issues
This function takes a data set that is in the format required for taxsim_calculate_taxes
,
checks it to make sure it is in the proper format for TAXSIM 35, and then cleans so it can be sent to TAXSIM 35.
This function is useful for troubleshooting. It is not needed to calculate taxes. The function is useful
if you continue receiving unreasonable errors from taxsim_calculate_taxes
. In such as case,
you can run this function on your data set. You should then save the resulting
data frame as a csv file. Then, upload the file to TAXSIM 35.
create_dataset_for_taxsim(.data)
create_dataset_for_taxsim(.data)
.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. |
create_dataset_for_taxsim
takes the same columns as column names as TAXSIM 35.
A data frame that that can be manually uploaded to TAXSIM 35.
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 <- create_dataset_for_taxsim(family_income)
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 <- create_dataset_for_taxsim(family_income)
Converts state names or state abbreviations to numeric SOI codes, which are required for TAXSIM.
get_state_soi(state_column)
get_state_soi(state_column)
state_column |
Vectors containing the states to calculate taxes for. Generally, this is the state column from the data set that will be sent to TAXSIM. |
Named integer vector with each number between 1 and 51 representing the state's SOI. Names are the state's two letter abbreviation.
A data set containing financial and household characteristics of 1,000 taxpayer units.
The data set was randomly generated and does not reflect real data.
It is formatted and ready for use in the usincometaxes
package.
taxpayer_finances
taxpayer_finances
A data frame with 1,000 rows and 16 variables. Variable definitions can be found in the following article: https://www.shaneorr.io/r/usincometaxes/articles/taxsim-input.html
Created through random data generation.
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
taxsim_calculate_taxes( .data, marginal_tax_rates = "Wages", return_all_information = FALSE )
taxsim_calculate_taxes( .data, marginal_tax_rates = "Wages", return_all_information = FALSE )
.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. |
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.
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.
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.
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')
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')