1 / 17

How to Write A Tax Benefit Model

How to Write A Tax Benefit Model. Asghar Adelzadeh Graham Stark. Coding Style. Use meaningful names; Organize code into procs; Use constants instead of magic numbers Group related data together using structs; Read one good programming book. Coding Style: Use Meaningful Names.

riona
Download Presentation

How to Write A Tax Benefit Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to Write A Tax Benefit Model Asghar Adelzadeh Graham Stark

  2. Coding Style • Use meaningful names; • Organize code into procs; • Use constants instead of magic numbers • Group related data together using structs; • Read one good programming book

  3. Coding Style: Use Meaningful Names Try to avoid: if( x[202,1] <= yy[203,9] ); what is x? What's special about element [202,1]? Better: if( income > tax_allowance);

  4. Coding Style: Use Constants Try to avoid: if( sex == 2 ); what does the 2 mean (the second sex?) Better (though longer): declare Male = 2; ... if( sex == Male );

  5. Coding Style: Use Structs to Model complex Data struct Adult{ scalar age; scalar sex; scalar economic_position; matrix incomes; }; longer to write, but worth it in long run

  6. Coding Style: Use Procs to break up code into chunks proc calculate_tax( struct Adult ad, struct Income_Tax inc_tax ); local tax; local income; income = ad.incomes[ EARNINGS ] - inc_tax.allow; tax = 0.0; if( income > 0 ); tax = income * inc_tax.rate; endif; retp( tax ); endp; Don't use this routine!

  7. Gathering Information • Before you start coding: • Gather tax returns, tax law, claim forms; • Work out examples of each calculation on paper; • Check characteristics of your dataset against aggregate statistics. • Check the exact questions in the survey

  8. Structure Of The Example Tax Benefit Model • Household.prg – model a household; routines to load households from a file, uprate them and so on • RunSettings.prg – general settings for a run, for example, inflation rates , switches to turn on special procedures such as labour supply routines, and the like. • Parameters.prg - Tax System Parameters, for example tax rates and allowances, money amounts for pensions and the like, and associated routines (uprating, for example); • Results.prg – The results for one full calculation for one household (taxes due, net incomes, pensions payable, net incomes, poverty states and so forth); routines to compare two sets of results; • Calculator.prg – once we've got all the above in place, we can actually do some sums. This file contains routines to calculate one Results record for one Household, using one set of Parameters and RunSettings. The file supplied to you is very basic, with just two simple routines. In reality, this module might get very large, and be best split into sub-modules (income tax, indirect taxes and so on); • TaxBenefitModel.prg – finally, the module to run the whole thing can be quite short: it needs to import all the other modules, initialize them and run the calculations by looping over all the households available, calling the calculator and accumulating the results.

  9. Household.prg • Holds structs to represent a household • Also, constants for commonly used items (gender, regions..) • Model data as nested structs (household contains people, people contain incomes, demographics, etc) • Follow structure of original dataset, where possible

  10. RunSettings.prg • Holds information common to run • Examples: inflation rates for uprating • Advanced models might have lots of information here (behavioral parameters, macroeconomic information ...)

  11. Parameters.prg • Hold structs for storing tax rates, benefit levels, etc. • Examples: • sys.income_tax.rate=0.26; • sys.vat.rate[ FOOD ] = 0.22;

  12. Results.prg • Holds results for one set of calculations on one household • Examples: tax due, poverty state (in/out of poverty) • Follow structure of Household.prg (results for individuals, then for the household as a whole..)

  13. Calculator.prg • Now we've got all this, we can do some sums! • Calculator.prg does the actual tax/benefit calculations; • Produce one results record for one household and one set of parameters and one run settings struct • As such should provide a public proc like: proc calculate_results( struct Household hh, struct Fiscal_System tb_sys, struct Run_Settings settings );

  14. Calculator.prg (continued) • Write a proc for each component of the system being modeled: income tax, vat, poverty state.. • Break complex systems up into sub procs..

  15. TaxBenefitModel.prg • This drives the program • Initialize household data, parameters, output routines, run settings; • Loop round households, call calculate.prg main proc for each one, for current and reformed tax systems; • Accumulate the results • If the modules have been set up as above, this should be short (50-60 lines, perhaps)

  16. Test! • Write a GAUSS test for every single proc that you write; • Keep the the test programs in a separate file (preferably in a separate directory); • Run your tests every time you modify your program.

  17. Does the model match reality? • Check your aggregate outputs against official figures (tax revenues, benefits paid... ). • May not always match: • Data may undersample some groups (rich, sick..) • Survey may ask wrong questions (e.g. Incomes of people not receiving a regular wage); • People may lie: I don't drink, smoke that much!; • People may avoid paying taxes, or not claim benefits

More Related