Docsity

David Kendrick - Computational Economics, Notas de estudo de Economia

Pré-visualização parcial do texto

Baixe David Kendrick - Computational Economics e outras Notas de estudo em PDF para Economia, somente na Docsity!

Computational Economics

David A. Kendrick

P. Ruben Mercado

Hans M. Amman

Contents

Introduction

Part I Once Over Lightly …

Growth

  1. Growth Model in Excel Finance
  2. Neural Nets in Excel Microeconomics
  3. Partial Equilibrium in Mathematica
  4. Transportation Model in GAMS Database
  5. Database Systems in Access Finance
  6. Thrift in GAMS with Genevieve Solomon
  7. Portfolio Model in MATLAB

Part II Once More …

Microeconomics

  1. General Equilibrium Models in GAMS Game Theory
  2. Cournot Duopoly in Mathematica with Daniel Gaynor
  3. Stackelberg Duopoly in Mathematica with Daniel Gaynor
  4. Genetic Algorithms and Evolutionary Games in MATLAB Finance
  5. Genetic Algorithms and Portfolio Models in MATLAB Macroeconomics
  6. Macroeconomics in GAMS Agent-based Computational Economics
  7. Agent-based Model in MATLAB Environmental Economics
  8. Global Warming in GAMS

Preface

One of the best ways to learn computational economics is to do computational economics. One of the best ways to do computational economics is to begin with existing models and modify them as you experiment with them. This is the approach used in this book. In each chapter an economic model is presented. First the economics and mathematics of the model is discussed and then the computational form of the model is analyzed. This process enables one to learn the economics and the mathematics of the problem area as well as the computational methods that are used in that area. For example, in the economic growth area we make use of a Ramsey type model. The economics of growth theory are first discussed along with the equations that model this process. Then the software representation of the model is presented so that the reader can see how the model can be solved on a computer. The student can then modify the model in order to analyze its sensitivity to various parameters and functional specifications. In the process of experimenting with the model one can gain an improved understanding of both the software and of the economic modeling. This book grew out of undergraduate and graduate level courses on computational economics taught by us at the University of Texas, ISEG (Argentina) and the University of Amsterdam. Also, a number of teaching assistants and undergraduate students participated in the development of chapters, notably Daniel Gaynor and Genevieve Solomon. This book is intended for use by advanced undergraduates and professional economists and even, as a first exposure to Computational Economics, for graduate students. We expect the development in coming years of undergraduate courses with a focus on economic modeling along the lines outlined in this book. Also, we envisage the development of a two course sequence in Computational Economics in graduate programs. The introductory course would have a broad economic modeling focus with an approach similar to that used in some chapters of this book. The second course would focus on algorithms and numerical methods. Part of our motivation for writing this book is spelled out in a couple of paragraphs that are taken from a paper the three of us wrote with the title “Computational

Preface

Economics: Help for the Underestimated Undergraduate”. 1 These comments – though written for that paper – apply equally as well to this book.

“The ubiquitous personal computer has filtered deeply through the lives of college undergraduates; however undergraduate education in economics has so far failed to take full advantage of this sweeping change. We are underestimating the learning ability and insufficiently challenging a whole generation of undergraduate students in economics. Our thesis is that computational economics offers a way to improve this situation and to bring new life into the teaching of economics in colleges and universities.

With its early focus on algorithms, computational economics seemed well- suited for a relatively small group of graduate students and unlikely to have much impact on undergraduates. However, that is changing as we are discovering that computational economics provides an opportunity for some students to move away from too much use of the lecture-exam paradigm and more use of a laboratory-paper paradigm in teaching undergraduate economics. This opens the door for more creative activity on the part of the students by giving them models developed by previous generations and challenging them to modify those models. The modifications can be altering the models to make them applicable to the student’s interest or finding weaknesses in the model that can be strengthened by changes in the structure of the model. In the process the students become much more involved in their own education.”

The organization of the chapters in the book reflects primarily the outline of the courses at the University of Texas. The aim is to let the students find an area of computational economics that interest them and to pursue that area. Since some of the students are interested in microeconomics, others in macroeconomics and others in finance an effort is made to give a quick and broad exposure to models across a range of fields early in the semester. Then the range is covered again later in the semester in greater depth. The book is structured to follow this pattern. In Part I there is a “once over lightly” treatment of computational economics examples from a number of fields. This is then repeated in greater depth and complexity in Part II. Part III covers an

(^1) Kendrick, Mercado and Amman (2005).

Introduction

One can think of learning computational economics by following one of three different routes - via computational methods, via mathematical methods or via economic areas. The computational methods route would focus on the use of a particular computer software system like MATLAB or Mathematica and teach the students the capabilities of those languages with examples from economics. The mathematical route would focus on algorithms to solve various classes of mathematical models such as linear or nonlinear programming models, differential or difference equations, and dynamic programming models and provide examples of the use of each kind of model in economics. The economic areas approach would focus on microeconomics, macroeconomics, finance, game theory, environmental economics etc. and teach the students how to formulate and solve economic models in each of these areas. For this book we have chosen the last of these three approaches. Thus this is a book about computational economics , but also about economic modeling. As a student approaches a new area of interest we want to help him or her first think through the economics of the subject. Then we develop this economics into a mathematical model. Finally we specify the mathematical model as a computational model in a particular software system. We believe that this process can be greatly facilitated by encouraging the students to follow Professor Paul Samuelson’s advice and “stand on the shoulders” of those who have gone before. This is done by beginning from subject areas and problems that other economists have studied and learning how the economics was converted to mathematics and then to computational models in those areas. Therefore this book is organized around economic topics rather than around mathematical or computational topics. However, we did not put all the microeconomics in the first section, then the macroeconomics etc. Rather the book is divided into two rounds of relatively simple models and then more complex models as was discussed above in the Preface.

Introduction

Software Systems

Students who begin studying computational economics frequently ask the question, “What programming language should I learn?” 2 The answer given in this book is to first become acquainted with a number of high-level languages such as GAMS, Mathematica, MATLAB and Duali as well as the Solver in Excel and the Access database software. Moreover, it is useful to become acquainted with each of these software systems in the midst of solving the kind of economic models that are naturally developed in each of these systems. Then later one can dig deeper into one or more of the software systems and gain some level of mastery of it while writing a short mid-term paper, a term paper or doing research. At a still later stage, students who find that they have a continuing interest in computational economics would be well advised to progress to lower level languages such as Visual Basic, Fortran, C, C++, C# or Java. There are different types of software paradigms, each of them more or less suitable to represent specific types of models. In this book, we present a selected set of high-level software systems, each corresponding to a specific paradigm. We start the book with relatively simple models represented in Excel (“spreadsheet paradigm”) as a way of beginning with a software paradigm that is well known and accessible to almost everybody, since this software system is available on most PC’s. Excel is useful to solve small models that do not involve simultaneous systems of equations; however, is not well designed for vector-matrix operations. For this type of operations we will use MATLAB later in the book. However, Excel has a nonlinear optimization solver which can handle constrained optimization problems and is very handy to set up and solve interesting models such as a Ramsey type model of economic growth and a small neural net. Also, early in the book we introduce Access (“relational database paradigm”), which like Excel is a very accessible software system. Access is well suited to develop relatively simple relational databases and its use is illustrated with a prototype U.S. database. The “set driven” paradigm is introduced with GAMS. This software system, particularly well suited to deal with medium and large size models involving from tens to hundreds of variables and equations, allows us to specify problems in an organized and compact way, defining sets to be used as indexes, and specifying scalars, parameters, variables and equations in a parsimonious way. We solve with GAMS models of

(^2) For a discussion of some of the software systems used in economics see Amman and Kendrick (1999b).

Introduction

Numerical Methods

In this book we present not only a variety of models and software paradigms, but also introductions to diverse numerical methods needed to solve them. As with the software systems, we think that is useful to become acquainted with each of those numerical methods in the midst of solving the kind of economic models that are naturally involved with each of these methods. A number of the models presented in the book are solved with linear programming methods or nonlinear optimization methods based on gradient and/or Newton methods. Thus we provide an introduction to these methods in appendices at the end of the book. Other methods are introduced directly in particular chapters. Neural nets are applied to a stock price prediction problem, Monte Carlo methods are applied to a portfolio selection problem and genetic algorithms are applied to an evolutionary game and to a portfolio selection problem. Quadratic linear dynamic programming is illustrated with a simple macroeconomic policy analysis application. Finally, the Fair and Taylor iterative method to solve rational expectations models, together with the Amman and Kendrick method to solve optimal control models with forward looking variables is applied to a prototype macro model developed by Taylor.

Teaching Methods

A description of the teaching methods used in the computational economics courses at the University of Texas will help the reader to understand the way in which the materials in this book have been developed. One aspect of these courses is that they have a weekly cycle. As was described above, the first class each week is on the economic theory and mathematical model of the subject for the week. The second class is on the computational methods used to solve the model. The third class of the week is not in a lecture room but rather in a computer laboratory where the students are ask to solve the base model and then to modify (and solve) the model several times in order to study its structure and operation. One week after the computer laboratory class the students are asked to turn in a short paper a few pages in length that describes their own experiments with the model during the week and the results obtained. The weekly teaching cycle is reflected in this book with some suggested experiments listed at the end of each chapter. However, the students are encouraged to strike out on their own – a process which enhances both enjoyment and learning.

Introduction

Since the emphasis in these computational economics courses is on creativity, there is both a mid-term paper and a final paper. The students are asked in the mid-term paper to modify one of the models from the course or to select an existing model from the GAMS library or another similar source and then to make minor improvements in the model. In the final paper they are asked to carry this process forward and make major modifications to an existing model or to create a model of their own. Several alternative approaches to the one used in this book are available for the study of computational economics. However, until now most books in this field have focused on graduate level instruction while we are hoping to be helpful to both undergraduates and graduate students. For an approach using the GAMS software exclusively and focusing on linear and nonlinear programming methods see Thompson and Thore (1992). For approaches using numerical methods see Judd (1998) who uses several computer languages or Miranda and Fackler (2002) who use MATLAB. Varian (1993a) and (1996) presents a variety of models in Mathematica. For a web site that supports a course on applied macroeconomics using computational methods taught by Prof. Harris Dellas at the University of Bern that is somewhat similar to the approach taken in this book see http://www.vwi.unibe.ch/amakro/Lectures/computer/ For books that focus on numerical methods in macroeconomics with some applications in MATLAB see Marimon and Scott (1999) and Adda and Cooper (2003). For a book with a collection of articles that consider a variety of numerical methods to solve macroeconomic models see Hughes Hallett and McAdam (1999). For a handbook with a collection of articles about computational economics see Amman, Kendrick and Rust (1996). Also, you are encouraged to browse the Internet site of the Society for Computational Economics at http://comp-econ.org where you will find information about meetings, journals and book series. Given the array of materials that are becoming available for teaching computational economics, we are hopeful that courses in this field will become a part of the core curriculum in both undergraduate and graduate education in economics as happened before with Mathematical Economics and Econometrics. Moreover, we hope our book will motivate and help instructors in those areas to offer courses in Computational Economics. We are aware of courses in Computational Economics that have been offered in recent years at Stanford, Yale, Maryland, Ohio State, Bern, Harvard and Texas and believe that some of these courses will migrate toward the core as courses are added at other universities.

Chapter 1

Growth Model in Excel

Most economists are familiar with the spreadsheet and even with the database capabilities of the Excel software, but fewer are aware that Excel also contains powerful solution procedures for solving both linear and nonlinear programming problems. Because the Excel interface is so familiar to many and because the specification of programming problems in Excel is relatively straightforward, there are times when Excel is the software of choice for solving certain types of optimization problems. In particular, when the models are small enough that the set driven nature of GAMS does not give it an advantage over Excel, it may be advantageous to solve optimization problems in Excel. To illustrate this we will use a one-sector growth model of the type that is widely used in the economics literature. The model we will use is the famous Ramsey model of economic growth. Models of this type have been widely used in the economic growth literature. In particular, we will follow the versions developed by Chakravarty (1962) and Taylor and Uhlig (1990). We will employ a finite horizon version with a terminal capital stock constraint. The model will first be introduced in a mathematical form and then in a computational form. 3 The essential economics of the simple growth model used in this chapter is a trade-off between consumption and investment. More consumption in a time period means more utility in that time period but less investment and therefore less capital stock and less production in future time periods. So the key elements of the model are the production function with capital being used to produce output, the capital accumulation relationship with investment creating new capital and the utility function with consumption resulting in utility.

(^3) Most models used in this book cannot be solved analytically so numerical methods are required.

However, even when analytical solutions can be obtained, as shown later in Appendix J, it is still useful to obtain numerical solutions so that the code can be checked on simple models. Then the numerical methods can be used with more confidence when they are applied to more complex models that cannot be solved analytically.

Chapter 1 Growth Model in Excel

1 Mathematical Form

The production side of the economy is specified in a stylized form by means of an aggregate production function

(1) Yt = θ Kt^ α

where Yt = output in period t

θ = a technology parameter

K (^) t = the capital stock in period t

α = exponent of capital in the production function

This is the widely used Cobb-Douglas form of a production function except that function usually includes both capital and labor inputs. However, for the sake of simplicity, the production function in this model includes only capital. Consider next the capital accumulation constraint

(2) K (^) t + 1 = K (^) t + Yt − Ct

t

where C t = consumption in period t

which says that the capital stock next period will be the same as this period plus the difference between output and consumption which is saving or investment. For the moment depreciation of the capital stock is ignored though you might want to add that to the model in an experiment. Also, the production function (1) can be substituted into the capital accumulation equation (2) to obtain the equation

(3) K t + 1 = Kt + θ Kt^ α− C

In addition, the model has an initial condition that specifies the size of the capital stock in the initial period.

(4) K 0 given.

Chapter 1 Growth Model in Excel

(^1) ( 1 ) t 0 1 t

J N^ − β t^1 C^ τ

− = −

In summary, t

= (^) ∑

he model consists of the criterion function (8), the capital ccumulation equation (3) and the initial and terminal conditions (4) and (5) and can be stated as f

, C (^) N − ) to maximize

a ind

( C 0 , C 1 (^) ," 1

(^1) ( 1 ) 0

N (^) t J (^) t Ct

− (^) −

∑ −

subject to

(3) K t + 1 = Kt + θ Kt^ α − Ct

(4) K (^) 0 given. (5) (^) K (^) N ≥ K *

So the essential problem is to choose those levels of consumption, over the time and

n future years. This growth model is a nonlinear programming problem because of the nonlinearities in the criterion function (8) and the capital accumulation equation (3). It can be stated and solved rather nicely in Excel as is discussed below.

periods covered by the model that strike the right balance between consumption investment. Lower consumption in any given period means less utility in that period but more savings and therefore larger capital stocks and more production i

Chapter 1 Growth Model in Excel

2. Computational Form

Consider first a spreadsheet layout of the model as shown in Figure 1.1 below. The corresponding Excel file is in the book web page.

Figure 1.1 Growth Model in Excel with Total Utility Highlighted

Notice first that the model horizon covers time periods numbered from zero through nine so that period zero will be the initial period and period nine will be the terminal peri The rows below the time periods d

od. isplays the consum production, capital stock, utility,

in each time period. All of these values are calculated when the model is solved and we shall show shortly how the calculations are structured. However, for now look only at

ption, Ct Y t K t

U C ( t )

Chapter 1 Growth Model in Excel

beta^D This means that beta is raised to the power of the number in cell D4. This makes use of the “naming” capability for constants in Excel and is equivalent to B17^D4. The number in cell D4 is two so this term becomes

β^2

which is the discount factor squared. Beta is defined in line 17 of the spreadsheet as .98. Also, since 1 1

we can infer that the discount rate, ρ , is equal to about .02.

Next consider the term (1/(1-tau))*D5^(1-tau) which can be rewritten as (^1 51) − tau 1

D

− tau and since the cell D5 contains consumption we can further rewrite this expression as (^11) 1 t C^ τ τ

− − which is the same as the utility function in Eq. (6) above. So, the cell D12 contains the mathematics (^11) 1

β^ t Ct −^ τ

tau 0.5. ary, line 12 of the ulate the discounted utility

− τ which is the discounted utility for period t. Also, the param eter of the utility function is defined in line 16 of the spreadsheet as being equal to In summ spreadsheet is used to calc in each period and then to sum those values so as to obtained the total discounted utility in cell L12. Thus the criterion function for the model is contained in line 12. Next consider the constraints of the model. Begin with the expression for production which is illustrated in Figure 1.3 below.

Chapter 1 Growth Model in Excel

Figure 1.3 The Calculation of Production in Each Period

In this figure cell D6 is highlighted and the formula bar contains the expression theta*D9^alpha which is the same as Eq. (1) above for production, i.e. Y t = θ Kt^ α

since cell D9 contains the capital stock for period t and theta is defined near the bottom of the spreadsheet in line 19 as being equal to 0.3 and alpha is defined in line 18 as being equal to 0.33. Next consider the expression for the capital accumulation constraint which is shown in Figure 1.4 below where cell D9 is highlighted.