Jeff Clawson and Kerk Phillips, Department of Economics
For the past year, this project has involved taking a trade simulation model, recreating it in a modern programming language and making it freely available through the Open Source Policy Center (OSPC). The program takes real world population data provided by the user and then simulates trade between countries. Unlike the natural sciences, Economists cannot always study their subjects in a controlled environment. Models like this project allow us to get an idea of what would happen, for example, in trade between the US and EU if there were to be a change in China’s taxes. Our project is still ongoing, but there have been some key improvements and new tools made that will be very useful to future research.
The original model was created by Larry Kotlikoff, professor of Economics at Boston University. It is written in Fortran, an older programming language, and has been a useful research tool for economists. However, with the many additions and changes made to it over the years, it has become very unwieldy to use. Its documentation is partially written in German and the English portions are diffcult to follow. The original is fundamentally sound and therefore our project began as a direct translation from Fortran to Python. Python is much simpler to read and, unlike Fortran, isn’t proprietary to a particular operating system. Any computer, whether running Windows, Mac OS X or Linux can run our python code. This isn’t necessarily true of the Fortran code, which used a Windows specifc program.
After working on a translation for about a month, it quickly became apparent that it was not the best way to go. It was really diffcult to fnd bugs, therefore we decided to abandon it in favor of building it from the ground up. Using a mathematical model known as “overlapping generations” (OLG), we used the principles of Kotlikoff’s research to inform our construction. Without being too technical, the OLG allows for people of different ages to exist at the same time. With that framework, we started to add extra features, one stage at a time. Stage 2 added real world population data, Stage 3 allowed workers to choose between working work and leisure, Stage 4 added children, Stage 5 would add skill classes and Stage 6 would add taxes. As we went along, we would save and archive the code up to the completed stage, just in case we made a mistake.
The end user would simply have to supply the number of countries he or she wants to simulate trade between, how many time periods their simulated people live for, real world population data (fertility rates, mortality rates, migration and population over the stretch of sixty four years) and any other parameters and the code would do all of the rest.
Currently, the project is complete through Stage 4, as there are some unforeseen theoretical issues that are currently being worked through. Putting in skill classes added an extra dimension that made our calculations more diffcult than we anticipated. While the project isn’t complete yet, there were two key improvements that came as a result of our work. The frst is the dramatic speed increase and the second was a tool within our code that automatically adjusts demographics based on the number of time periods the user selects for simulated people to live.
When we were doing our ground-up construction, we had a major issue with completion time. During the third stage, we had the code running on a desktop computer and it took nearly two months to complete but it did give promising results. This speed paled in comparison to the Fortran original, which only takes about 15 minutes to complete. It took weeks of research into python coding to fnd an alternative solver that allowed our code to fnish in only two hours.
Since the user can choose the number of time periods the simulated people can live, we needed to adjust the population data based on the number of periods the user chooses. For example, our data may be annualized, but if the user selects people to live for 20 periods instead of 80 periods, the data has to refect rates for every four years instead of every year. Within the code, we run a regression of the rates on time and age and then use the results of the regression to to scale the data that is fed into the code for calculations.
The project is not complete yet, however the improvements in speed and adjustments in demographics are very likely to be used in other research projects within the OSPC, which involves BYU professors. There’s a sister project that simulates a single country’s economy with multiple industries that can use the methods that we’ve developed along the way. Those who continue on the project will need to work through the theoretical issues, but there is a solid base to build upon.
There was much progress made, but there is still a lot left to do. We have successfully created a trade simulation model, but it is still missing the key components of Kotlikoff’s original. The remaining features will be added in the coming months. To see the project in its latest iteration, please visit: https://github.com/open-source-economics/OG-Multi-Country