MyNixOS website logo
Description

Calculate Federal and State Income Taxes in the United States.

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.

Calculate Federal and State Income Taxes

usincometaxes is an R package that calculates federal and state income taxes in the United States. It relies on the National Bureau of Economic Research’s (NBER) TAXSIM 35 tax simulator for calculations. The package takes care of the behind-the-scenes work of getting the data in the proper format, converting it to the proper file type for uploading to the NBER server, uploading the data, downloading the results, and placing the results into a tidy data frame.

NOTE: This package is not associated with the NBER. It is a private creation that uses their wonderful tax calculator.

Installation

You can install usincometaxes from CRAN:

install.packages('usincometaxes')

Quick example

usincometaxes helps users estimate household income taxes from data sets containing financial and household data. This allows users to estimate income taxes from surveys with financial information, as the United States Census Public Use Micro Data (PUMS).

The short example below uses taxsim_calculate_taxes() to calculate income taxes.

library(dplyr)
library(knitr)
library(usincometaxes)

family_income <- data.frame(
  taxsimid = c(1, 2),
  state = c('North Carolina', 'NY'),
  year = c(2015, 2020),
  mstat = c('married, jointly', 'single'),
  pwages = c(50000, 100000), # primary wages
  page = c(26, 36) # primary age
)

family_taxes <- taxsim_calculate_taxes(
  .data = family_income,
  marginal_tax_rates = 'Wages',
  return_all_information = FALSE
)
kable(family_taxes)
taxsimidfiitaxsiitaxficafratesrateficartfica
13487.52012.507650155.7515.33825
215103.55377.8615300246.4115.37650

Users can use the taxsimid column to join the tax data with the original data set. Every taxsimid in the input data is represented in the output tax data.

family_income %>%
  left_join(family_taxes, by = 'taxsimid') %>%
  kable()
taxsimidstateyearmstatpwagespagefiitaxsiitaxficafratesrateficartfica
1North Carolina2015married, jointly50000263487.52012.507650155.7515.33825
2NY2020single1000003615103.55377.8615300246.4115.37650

Output

taxsim_calculate_taxes() returns a data frame where each row corresponds to a row in .data and each column is a piece of tax information. The output and .data can be linked by the taxsimid column.

The amount of output (tax information) received is controlled by the return_all_information parameter to taxsim_calculate_taxes(). Setting return_all_information to FALSE returns minimal information such as federal and state tax liabilities and FICA taxes. When return_all_information is TRUE 44 different tax items are returned.

usoncometax’s output contains the same information and column names as TAXSIM 35. Therefore, please consult either the Description of Output Columns vignette or TAXSIM 35 documentation for more output information.

family_taxes_full_output <- taxsim_calculate_taxes(
  .data = family_income,
  marginal_tax_rates = 'Wages',
  return_all_information = TRUE
)

kable(family_taxes_full_output)
taxsimidfiitaxsiitaxficafratesrateficartficav10_federal_agiv11_ui_agiv12_soc_sec_agiv13_zero_bracket_amountv14_personal_exemptionsv15_exemption_phaseoutv16_deduction_phaseoutv17_itemized_deductionsv18_federal_taxable_incomev19_tax_on_taxable_incomev20_exemption_surtaxv21_general_tax_creditv22_child_tax_credit_adjustedv23_child_tax_credit_refundablev24_child_care_creditv25_eitcv26_amt_incomev27_amt_liabilityv28_fed_income_tax_before_creditv29_ficav30_state_household_incomev31_state_rent_expensev32_state_agiv33_state_exemption_amountv34_state_std_deduction_amountv35_state_itemized_deductionv36_state_taxable_incomev37_state_property_tax_creditv38_state_child_care_creditv39_state_eitcv40_state_total_creditsv41_state_bracket_ratev42_self_emp_incomev43_medicare_tax_unearned_incomev44_medicare_tax_earned_incomev45_cares_recovery_rebate
13487.52012.507650155.7515.338255000000126008000000294003487.50000005000003487.5765050000.01050000.01015000035000.0100000.0050000000
215103.55377.8615300246.4115.37650100000001240000008760015103.5000000100000015103.515300100001.010100000.0108000092000.0100006.41100000000

Input

Taxes are calculated with taxsim_calculate_taxes() using the financial and household characteristics found in the data frame represented by the .data parameter. Each column is a different piece of information and each row contains a tax payer unit.

All columns must have the column names and data types listed in the Description of Input Columns vignette. These are the same column names found in the TAXSIM 35 documentation. Therefore, you can consult the package documentation or TAXSIM 35 documentation for more information on input columns. There are two differences between usincometaxes and TAXSIM 35:

  1. usincometaxes allows users to specify the state with either the two letter abbreviation or state SOI code. usincometaxes will convert the abbreviation to an SOI code for TAXSIM 35.
  2. For filing status, mstat, users can either use the TAXSIM 35 integer found in TAXSIM 35’s documentation or one of the following descriptions:
    • “single” or 1 for single;
    • “married, jointly” or 2 for married, filing jointly;
    • “married, separately” or 6 for married, filing separately;
    • “dependent child” or 8 for dependent, usually a child with income; or
    • “head of household” or 1 for head of household filing status.

The input data frame, .data, can contain columns beyond those listed in the vignette. The additional columns will be ignored.

Marginal tax rates

By default, marginal tax rates are calculated using wages. The default can be changed with the marginal_tax_rates parameter to taxsim_calculate_taxes(). Possible options are: ‘Wages’ (default), ‘Long Term Capital Gains’, ‘Primary Wage Earner’, or ‘Secondary Wage Earner’.

Giving credit

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 TAXSIM 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.

Aman Gupta Karmani created the WebAssembly / JavaScript files. These files also power his tax calculator web app at taxsim.app.

Metadata

Version

0.7.1

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows