Getting started on Numerical Methods
|
1. Choosing a software package If you have never used your computer to solve economic models numerically, you probably don't have any software installed. There are a few programming languages to choose from. Matlab and Fortran are probably the most widely used languages among economist, although other options exist, such as NEOS, GAMS, or AMPL. The advantage of AMPL is that you can easily change the solution algorithms (i.e. solvers) used to solve your problem. This is especially useful if you have non-standard problems that may not work with some solvers. The disadvantage of AMPL is that you cannot use subroutines. There exists a free student version of AMPL. Your decision on what language you choose from should mainly depend on two things: who you know and what you want to do. Who you know is important because sooner or later you'll need some help with your projects. Whether it is when you start out or when you get hung up on difficult problems later on, it is always good to have people around who could potentially help you. If everybody you know uses Matlab, there is probably little reason for you to choose anything but Matlab, at least to start out with. Same goes for Fortran. Having said that, it is also important to think about what kind of problems you plan on solving. Fortran runs considerably faster than Matlab does. If you know that you will need a lot of computing power and that computing speed will be important, you may want to go with Fortran instead of Matlab. Although programming in Fortran is very similar to Matlab, there are a few differences. Matlab is very good with matrices, Fortran is not. Matlab has a very easy to use interface, Fortran does not. For example, after running a program, Matlab will provide you the results for all your variables and parameter values and allow you to graph the result. In Fortran you have to write extra routines that output your results. In the absence of such routines, you won't have anything to show for. If you want to do serious quantitative GE macro research, learn Fortran early. 2. Buying and installing the software Note that most of the algorithms economist are likely to need (e.g. solving a system of equations, constraint and unconstraint optimization problems, etc.) are not included in the basic Matlab or Fortran programs. These routines usually come in the form of libraries that need to be purchased separately. If you are a Stanford student (or faculty or staff for that matter), the first place to look when shopping for software is Stanford Software Licensing. This list shows you what software Stanford supports on the Unix servers and/or sells to students at discounted prices. Sometimes you can get the best deals from them. 2.1 Buying and installing Matlab Software Licensing recommends buying the Matlab Student version at the MathWorks student center or the Stanford Bookstore. The current price for the student version is $99. A very useful library you should invest in is the optimization toolbox (currently $59), which includes a range of algorithms useful for solving economic problems. Installing Matlab and the optimization toolbox is straight forward - just follow the instructions. 2.2 Buying and installing a Fortran compiler There are many Fortran compilers available, some are free (take a look at these sites for a list of free compilers: 1, 2), some are not. One good option is the Intel Visual Fortran Compiler, which comes in two versions: standard or professional. The only difference is that the professional version includes the IMSL Fortran Library. Student can order the Student Edition (which is a greatly discounted Standard version) from Custom Solutions for $40. To install and run the Intel Visual Fortran Compiler, you will also need MS Visual Studio 2005 Standard Edition. You can buy the academic edition at the Stanford Bookstore or online for about $50. WARNING: MS Visual Studio 2005 is only compatible with the Intel Visual Fortran Compiler 9.1 and higher. For your Fortran system to be useful, you should also get a numerical library such as the IMSL Fortran Library or the NAG Fortran Library. According to Ken Judd, the NAG library is better than IMSL and contains some of the best available optimization routines (such as NPSOL from the Stanford System Optimization Laboratory). Note that Stanford Software Licensing owns licenses for both libraries. You can either use them for free on the Stanford Unix system, or you can contact Software Licensing to get an inexpensive personal license. Visual Numerics also sells student licenses for the IMSL library for $99. To install your system do the following:
Once you have installed your compiler, try to compile and run one of the sample programs that comes with your software. To do so, you need to follow three steps.
3. Books and web resources for Fortran An excellent Fortran book for beginners and a great reference is Fortran 90 Programming. Other Fortran resources include
Resources for numerical methods in economics include Ken Judd's website and his book Numerical Methods in Economics. There also exists a Summer Institute on Computational Economics. |