Lurker News
I wanted to share a simple web app I created recently, which lets you estimate income taxes owed in the US: https://taxsim.app

All the calculations occur directly in the browser, and are powered by a Fortran program that has been converted to WASM using emscripten. This calculator was originally developed in the 1970s [1] by the non-profit National Bureau of Economic Research. NBER has been maintaining this F77 codebase for the last 50 years, and uses it primarily for academic research on tax policy. The Fortran source code itself is over 1MB of text, because it codifies both federal and all 50 states' tax laws for each of the last 62 years.
I first learned about NBER TAXSIM [2] a few months ago via an interesting paper they published "Automatic Tax Filing: Simulating a Pre-Populated Form 1040" [3]. The Fortran code itself is not open-source, but is available on request for research purposes. I reached out to NBER and proposed compiling it to WASM, so it could be run directly in a browser. With relatively little effort I was able to create a js/wasm version [4], thanks in huge part to previous open-source work [5].
This WASM build now powers https://taxsim.app, which is my attempt to create an interactive UI to allow for easier exploration of the US tax code. Specific tax scenarios can also be shared easily, by simply copying the browser URL. The code for this webapp is also open-source [6].
This was my first time experimenting with WASM, and I am already a huge fan. Not only was I able to take a 60 year old codebase and get it working on every modern browser and device, this work is also now benefiting the academic community. For example, the js/wasm can be run directly in V8, which means it can also now be run locally within R using libv8 [7]. Previously most researchers were uploading their tax scenarios to NBER's servers via ftp/ssh/http.
[1] https://taxsim.nber.org/feenberg-coutts.pdf
[2] https://taxsim.nber.org/
[3] https://www.nber.org/papers/w30008
[4] https://github.com/tmm1/taxsim.js
[5] https://chrz.de/2020/04/21/fortran-in-the-browser/
[6] https://github.com/tmm1/taxsim.app
[7] https://github.com/shanejorr/usincometaxes/pull/11

Comments (155) 41 threads

Earlier comments
FullyFunctional4 replies#
That's brilliant work, thanks!

Imagine if IRS would produce something like this (open sourced) and we could file our returns like this.

ErikVandeWater4 replies#
The IRS can already calculate your taxes for you. In other countries you just have to confirm what the revenue department calculates as your liability and hit "submit". You have to do the calculations yourself because TurboTax et al., and accountants lobbied so taxes are complicated and must be completed by the filer (or their accountant).
tmm11 reply#
From the abstract of NBER paper I mentioned [1]:

> Each year Americans spend over two billion hours and $30 billion preparing individual tax returns, and these filing costs are regressive. To lower and redistribute the filing burden, some commentators have proposed having the IRS pre-populate tax returns for individuals. We evaluate this hypothetical policy using a large, nationally representative sample of returns filed for the tax year 2019. Our baseline results indicate that between 62 and 73 million returns (41 to 48 percent of all returns) could be accurately pre-populated using only current-year information returns and the prior-year return. Accuracy rates decline with income and are higher for taxpayers who have fewer dependents or are unmarried. We also examine 2019 non-filers, finding that pre- populated returns tentatively indicate $9.0 billion in refunds due to 12 million (22 percent) of them.
[1] https://www.nber.org/system/files/working_papers/w30008/w300...

sokoloff#
One problem is that information is not tabulated by the IRS in time for a mid-April return date.

Order your tax “transcript of account” in late March and again in late August. It’ll be substantially more complete in late August.

FullyFunctional2 replies#
I didn't point that out: I originate from a country in which I used to get a postcard summarizing what they thought I owed with a "Yes, I agree" checkbox and a field to sign. You could always file an extensive return if desired, but unless you had complicated (notably international) transactions, the return was basically accurate.

This only works because there's a high level of trust in the government and low corruption, and having detailed tracking isn't (very) controversial. The US is almost the exact opposite on every metric so it wouldn't work for it.

pessimizer1 reply#
The US demands extremely detailed tracking of your income. We just get nothing in return for it.

Continue this thread — 1 reply

hippich#
I am from the country where most people don't even have to agree to anything - their income taxes already handled by employer on behalf of the government before each paycheck. But there is very low trust in government and it is dictatorship...

I do not know if that was intentionally forced on citizens in the USA to do their own taxes (even tho IRS had accurate information from W3s for nearly half of payers) for that purpose, but I think such exposure to the behind scenes calculation of taxes might force citizens to be more aware of what they are paying.
For example, back to my home country - I think income tax is something like 11% or 13% today. And most folks see this tax on their pay stubs. But what they do not see (although some are aware of) - employer pays extra 36% of the salary into social security. In the USA employee sees at least half of it (6.20% of 12.40%). The health insurance premiums are also prominent on the tax return, same with retirement. None of that is visible in any form to employees in my home country.

Melatonic#
As much as I hate doing it now the first few years I did my taxes I went all paper and it really helped give me a foundational understanding of it all. Especially when you make that one typo.
ac29#
> The IRS can already calculate your taxes for you

Only if 100% of your income is reported to the IRS. Small amounts (under $600) often aren't, and while you might be able to get away with not reporting it, its obviously not legal. I had some slightly unusual small sources of income the past couple of years that I had to keep records of, report, and pay taxes on.
Granted, a lot of people arent going to have much more than a W2 and maybe some interest income.

runlevel11 reply#
NBER's biggest contributors are the US government. Ironically, the IRS isn't one of them.[1]

As an aside, I'd love to see US gov research grants start requiring the work product to be made open source.
[1]: https://www.nber.org/about-nber/support-funding

analog312 replies#
Imagine if the tax code itself were written in Python.

  def computeTax(**kwargs):
    .. blah blah ..
    return how_much_you_owe
Of course we all know what comes next...

  from scipy.optimize import minimize
tmm13 replies#
In 2014, the Policy Simulation Library [1] added a model called Tax-Simulator [2], which is a Python reimplementation of TAXSIM [3][4]. It is available as open-source [5], and designed to let researchers both change existing policy variables and implement new tax reforms in Python.

[1] https://pslmodels.org/
[2] https://taxcalc.pslmodels.org/
[3] https://taxcalc.pslmodels.org/about/history.html
[4] https://github.com/PSLmodels/Tax-Calculator/blob/master/taxc...
[5] https://github.com/PSLmodels/Tax-Calculator

Continue this thread — 1 reply

MaxGhenis#
My team at PolicyEngine [1] is also now further reimplementing Tax-Calculator in the Python-based OpenFisca framework [2]. OpenFisca US [3] includes all tax logic in Tax-Calculator, plus many means-tested benefit programs like SNAP, and some state tax logic (currently only Massachusetts is complete, though we'll finish the country in the next 12-18 months). You can try it in our PolicyEngine US web app [4].

(OpenFisca US is part of the Policy Simulation Library, and it's developed by a number of former Tax-Calculator developers, myself included.)
[1] https://policyengine.org
[2] https://openfisca.org
[3] https://github.com/policyengine/openfisca-us
[4] https://policyengine.org/us

PopAlongKid1 reply#
It has been proposed in professional tax forums that this is in fact how tax code should be legislated, using some kind of pseudo-code. Even just using symbols for things such as >=, <, and so on would eliminate a lot of the garbage in the verbal version.
philsnow#
This would be incredible -- it feels like the tax form documentation is written in a dialect of Accounting English from the 50s, and just little things like adding some parentheses to group and/or con/disjunctions would go a long ways.

Nearly every year I don't feel confident that I've filled out my taxes accurately, and it's not for lack of trying.

HWR_14#
Congress won't let the IRS do it. To avoid that, Turbo Tax and the others promised to give free filing software out. That it didn't have all the deductions (pay for that) and was filled with anti-patterns to get people to sign up was something Congress ignored.

I assume there were also some campaign contributions that changed hands.

ideamotor1 reply#
This is amazing. Would there be a way to estimate future year taxes? For example, knowing past years inflation numbers could you run possible scenarios of future tax brackets?

The adjustment process seems to be opaque[1] but perhaps you could use a regression to estimate it. Then you would only need the ability to make those adjustments in this program to run future year scenarios.
1: https://www.irs.gov/newsroom/irs-provides-tax-inflation-adju... (I’m uncertain whether this is based on some predetermined formula)

PopAlongKid1 reply#
>Would there be a way to estimate future year taxes?

You can't even always estimate current year taxes, since Congress has lately taken to making retroactive changes to the tax code even after the end of the tax year (just extending their long-term habit of making changes in late December of the current year).

ideamotor#
Well I’m not looking for 100% accuracy, and it doesn’t need to cover all types of income. I’m interested in long term investment income with various input types of accounts and investments given different inflation and tax policy scenarios. It just needs to be better than the software I’ve seen which is basically trash (assumes a flat percent tax).
aidangrimshaw1 reply#
Sort of tangentially, I'm working with other contributors on https://ustaxes.org, an open source tax filing webapp https://github.com/ustaxes/UsTaxes.

Currently, many Federal tax forms are supported, as well as tax filing for the state of Illinois. Filing for Oregon and California is under development!

dhosek1 reply#
When you say “filing” does this mean it actually electronically file the return or it just is able to print out the returns for sending in by post?
aidangrimshaw#
It calculates the tax amounts and fills them into the IRS and state forms to be printed out
zeckalpha1 reply#
I made tiny typo (an extra digit in spouse age) and got a giant error, though at least it was actionable

“TAXSIM: Unbelievable spouse age”

omoikane#
This error message is hilarious, so I tried to find where the threshold is.

Apparently it's not believable that people 115 years or older would be filing taxes.

Load more comments