Structural overview#
Tax-Calculator has been designed using object-oriented programming (OOP) principles. There are seven classes and a collection of global utility functions, but most Python programming involves using only a few methods in three classes.
Quick summary#
Typical Tax-Calculator usage involves creating two Calculator class objects: both containing the same sample of filing units (that is, Records class object), but each containing a different tax policy (that is, Policy class object). The idea is to compare the calculated tax liabilities of the sample units under the two different tax policies, one of which is usually current-law policy and the other is a tax reform of interest.
rec
→ Records class object.
Created byRecords()
when containing IRS-SOI-PUF-derived filing-unit data or created byRecords.cps_constructor()
when containing CPS-derived filing-unit data.clp
→Policy
class object containing parameters that characterize current-law policy.
Created byPolicy()
.ref
→Policy
class object containing parameters that characterize a tax reform.
Created using a Python dictionaryrefdict
representing the reform by using theimplement_reform(refdict)
method on aPolicy
object created byPolicy()
. Or created using a JSON filefilename
representing the reform by using theimplement_reform(Policy.read_json_reform(filename))
method on aPolicy
object created byPolicy()
.calc_clp
→ Calculator class object for current-law policy.
Created byCalculator(records=rec, policy=clp)
.calc_ref
→ Calculator class object for reform policy.
Created byCalculator(records=rec, policy=ref)
.calc_all()
→ Calculator class method that computes tax liability (and many intermediate variables such as AGI) for each filing-unit.itax_clp
→ Variable containing aggregate income tax liability under current-law policy.
Created byweighted_total('iitax')
method called oncalc_clp
object aftercalc_all()
called.diff_table
→ Pandas DataFrame object containing reform-minus-current-law difference table for income tax liability by expanded-income deciles.
Created bycalc_clp.difference_table(calc_ref, 'weighted_deciles', 'iitax')
method called aftercalc_all()
has been called on both Calculator objects.
For examples of Python scripts that use these classes and methods, see Recipes.
For detailed documentation and source code for these three classes, see:
records.py for Records class and all its methods.
policy.py for Policy class and all its methods.
calculator.py for Calculator class and all its methods.
Complete story#
Tax-Calculator contains eight basic classes, and a collection of global utility functions, that together provide the full range of Tax-Calculator capabilities. Here is a description of their role in Tax-Calculator and a link to each the detailed documentation and source code for each class and all its methods.
Classes#
Data
→ Contains basic logic for manipulating cross-sectional data that need to have growth factors and sample weights to age the data to years after the data start year.
Documentation and source code are in data.py.Records
→ Derived fromData
and contains attributes of each tax filing unit.
Documentation and source code are in records.py.GrowFactors
→ Contains CBO-derived baseline annual growth factors that are used to specify price inflation and wage growth rates in thePolicy
class object and to specify annual growth factors that are applied to monetary attributes of the filing units in theRecords
class object.
Documentation and source code are in growfactors.py.Parameters
→ Contains basic value extrapolation, revision, and validation logic for time-varying parameters that can be any of four types and can be either scalar-valued or vector-valued.
Documentation and source code are in parameters.py.Policy
→ Derived fromParameters
and contains tax policy parameters.
Documentation and source code are in policy.py.GrowDiff
→ Derived fromParameters
and contains differences from CBO-derived baseline growth factors in theGrowFactors
class object.
Documentation and source code are in growdiff.py.Consumption
→ Derived fromParameters
and contains parameters related to consumption that are used in theCalculator
class object.
Documentation and source code are in consumption.py.Calculator
→ Contains aPolicy
class object, aRecords
class object, and aConsumption
class object, plus functions that contain the logic required to calculate income and payroll tax liability for each filing unit.
Documentation and source code are in calculator.py and in calcfunctions.py.
Utilities#
Documentation and source code for the global utility functions are in utils.py.