Key Concepts: Economic Computation, Part III

Similar documents
Applied Computational Economics Workshop. Part 3: Nonlinear Equations

Review of Optimization Methods

Math Review ECON 300: Spring 2014 Benjamin A. Jones MATH/CALCULUS REVIEW

SYSTEMS OF NONLINEAR EQUATIONS

Lecture 5. September 4, 2018 Math/CS 471: Introduction to Scientific Computing University of New Mexico

Tvestlanka Karagyozova University of Connecticut

September Math Course: First Order Derivative

1 The best of all possible worlds

Chaos and Liapunov exponents

Approximation, Taylor Polynomials, and Derivatives

CHAPTER 10 Zeros of Functions

Zeros of Functions. Chapter 10

CS 542G: Robustifying Newton, Constraints, Nonlinear Least Squares

Unit 2: Solving Scalar Equations. Notes prepared by: Amos Ron, Yunpeng Li, Mark Cowlishaw, Steve Wright Instructor: Steve Wright

Slope Fields: Graphing Solutions Without the Solutions

MITOCW watch?v=vu_of9tcjaa

Main topics for the First Midterm Exam

17 Solution of Nonlinear Systems

Notes IV General Equilibrium and Welfare Properties

Taylor approximation

FINANCIAL OPTIMIZATION

Fixed Point Theorems

Analysis Methods in Atmospheric and Oceanic Science

Section 1.8 Matrices as Linear Transformations

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Numerical Methods I Solving Nonlinear Equations

Numerical Methods in Informatics

Lecture 8. Root finding II

1 Newton s Method. Suppose we want to solve: x R. At x = x, f (x) can be approximated by:

16. . Proceeding similarly, we get a 2 = 52 1 = , a 3 = 53 1 = and a 4 = 54 1 = 125

A nonlinear equation is any equation of the form. f(x) = 0. A nonlinear equation can have any number of solutions (finite, countable, uncountable)

1. Algebra and Functions

5 Handling Constraints

Tangent Plane. Nobuyuki TOSE. October 02, Nobuyuki TOSE. Tangent Plane

ARE202A, Fall 2005 CONTENTS. 1. Graphical Overview of Optimization Theory (cont) Separating Hyperplanes 1

1. Method 1: bisection. The bisection methods starts from two points a 0 and b 0 such that

Solution of Nonlinear Equations

Tangent spaces, normals and extrema

Lecture 1: Introduction to computation

Chapter 1. Root Finding Methods. 1.1 Bisection method

Economics 101. Lecture 2 - The Walrasian Model and Consumer Choice

Perturbation and Projection Methods for Solving DSGE Models

Equilibrium in a Production Economy

SYDE 112, LECTURE 7: Integration by Parts

g(x,y) = c. For instance (see Figure 1 on the right), consider the optimization problem maximize subject to

ECON607 Fall 2010 University of Hawaii Professor Hui He TA: Xiaodong Sun Assignment 2

POLI 8501 Introduction to Maximum Likelihood Estimation

L p Functions. Given a measure space (X, µ) and a real number p [1, ), recall that the L p -norm of a measurable function f : X R is defined by

1 Bewley Economies with Aggregate Uncertainty

OPRE 6201 : 3. Special Cases

Solving non-linear systems of equations

Vector Spaces. Addition : R n R n R n Scalar multiplication : R R n R n.

MA 8019: Numerical Analysis I Solution of Nonlinear Equations

HOMEWORK #3 This homework assignment is due at NOON on Friday, November 17 in Marnix Amand s mailbox.

Nonlinear Equations. Not guaranteed to have any real solutions, but generally do for astrophysical problems.

Sequences and the Binomial Theorem

ECONOMETRICS II (ECO 2401S) University of Toronto. Department of Economics. Spring 2013 Instructor: Victor Aguirregabiria

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

Stephen F Austin. Exponents and Logarithms. chapter 3

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER / Functions

Numerical Methods of Approximation

Understanding Exponents Eric Rasmusen September 18, 2018

Part 1: You are given the following system of two equations: x + 2y = 16 3x 4y = 2

COSMOS: Making Robots and Making Robots Intelligent Lecture 3: Introduction to discrete-time dynamics

ter. on Can we get a still better result? Yes, by making the rectangles still smaller. As we make the rectangles smaller and smaller, the

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

EC5555 Economics Masters Refresher Course in Mathematics September 2013

Quasi-Newton Methods

Solving nonlinear equations (See online notes and lecture notes for full details) 1.3: Newton s Method

MITOCW ocw f07-lec39_300k

NONLINEAR EQUATIONS AND TAYLOR S THEOREM

3 Algebraic Methods. we can differentiate both sides implicitly to obtain a differential equation involving x and y:

Linear Discrimination Functions

Dynamical Systems. August 13, 2013

MITOCW MITRES18_006F10_26_0501_300k-mp4

Chapter 3: The Derivative in Graphing and Applications

Math 137 Calculus 1 for Honours Mathematics. Course Notes

CONSTRAINED NONLINEAR PROGRAMMING

Graphical Analysis and Errors MBL

5.1 Simplifying Rational Expressions

Notes on Random Variables, Expectations, Probability Densities, and Martingales

MATH 350: Introduction to Computational Mathematics

1 Implicit Differentiation

Infinite series, improper integrals, and Taylor series

Line Search Methods for Unconstrained Optimisation

IE 5531 Practice Midterm #2

Lecture 4: Dynamic Programming

is the intuition: the derivative tells us the change in output y (from f(b)) in response to a change of input x at x = b.

10725/36725 Optimization Homework 4

Conjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b.

Constrained optimization.

x 2 x n r n J(x + t(x x ))(x x )dt. For warming-up we start with methods for solving a single equation of one variable.

Math 409/509 (Spring 2011)

Mathematics for Intelligent Systems Lecture 5 Homework Solutions

where u is the decision-maker s payoff function over her actions and S is the set of her feasible actions.

New Notes on the Solow Growth Model

Optimization. A first course on mathematics for economists Problem set 4: Classical programming

Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2:

1-D Optimization. Lab 16. Overview of Line Search Algorithms. Derivative versus Derivative-Free Methods

Transcription:

Key Concepts: Economic Computation, Part III Brent Hickman Summer, 8 1 Using Newton s Method to Find Roots of Real- Valued Functions The intuition behind Newton s method is that finding zeros of non-linear functions is hard, but finding zeros of linear functions is trivial. Thus, for a function f(x) and an initial guess x, we linearize the function around x with a first-order Taylor approximation: f(x) f(x ) + f (x )(x x ). Now, setting the RHS to zero and solving for x gives the following: x = x f(x ) f (x ). Taking another step, we adopt the solution to this equation as our updated guess and repeat the process. We then continue on until our successive guesses render functional values within a given tolerance of zero, at which point we adopt the final guess as our approximate zero. Figure 1 provides a visualization of Newton updating for f(x) = ln(x). University of Iowa Brent-Hickman@UIowa.Edu 1

Figure 1: Finding the Zero of ln(x) by Newton s Method 1. 1. x 1 (invalid update!) x 1 (updated guess) f(x). 1 1. x (good initial guess) x (bad initial guess). f(x)=ln(x) 3 3 1 1 3 4 x

Newton s method is known for its rapid rate of convergence, but it does have some drawbacks. Notice that when we derived the process, we implicitly assumed that f was well behaved enough to make it work. Obviously, the function must be differentiable near its root, but if you look at Figure 1, you will see that this is not enough. As the graph shows, Newton s method may be sensitive to the quality of the initial guess. Even if you code the algorithm flawlessly, it may not work if the initial guess is not close enough to the root. The problem In Figure 1 stems from the fact that f(x) is undefined for x, but even if this were not the case we could still run into problems. Consider the function f(x) = x + 4. It has zeros at x = and x =. Most initial guesses will cause Newton s method to converge with lightning speed, but an initial guess of x = will cause it to fall apart (why?). One remedy to the problem of initial-guess sensitivity is to augment Newton s method with some sort of adaptive step-size control subroutine. Miranda and Fackler (, pp. 4-4) recommend a procedure that they call back-stepping, which prevents Newton s method from taking a large step in the wrong direction. At each Newton iteration, the back-stepping subroutine compares the Euclidean norm of f(x k ) and f(x k+1 ), to see whether the updated guess produced a functional value that is closer to zero (i.e. one that constitutes an improvement). If no improvement is found, then the step-size from x k to x k+1 is cut in half and the new updated guess becomes ( ) xk+1 x k x k+1 = x k + = x k f(x k) f (x k ) 1. This new guess is also tested and revised in similar fashion before moving on to the next Newton iteration. Exercise 1 Write a MATLAB program to find the unique root of the function f(x) = log(x) by Newton s method. Include a back-stepping routine to ensure that the program will terminate correctly for any initial guess. It is easy to see that in the logarithmic example, back-stepping will make Newton s method perfectly robust to choice of initial guess. A solution for Exercise 1 is contained 3

Figure :. A Pathological Example with an Interval where Newton s Method Completely Fails.4.3..1.1..3.4 3 1 1 3 4 in the accompanying file Part III solutions.m. The power of Newton s method can readily be seen by experimenting with different tolerance levels and different initial guesses for this function. By incorporating adaptive step-size control, Newton s method converges to the correct root from an initial guess of 7,, within 18 steps! On the other hand, back-stepping also introduces additional complications for nonmonotone functions, as it makes it possible for the algorithm to get stuck at a local non-zero minimum of the function g(x) = f(x), where denotes the Euclidean norm on the real line. Accordingly, a useful Newton routine will include two subroutines for step-size control: one for back-stepping and another for getting unstuck from local minima of g(x). With a slight abuse of the notation, Miranda and Fackler (, pp. 41) propose a simple unsticking subroutine where, at each back-step iteration, we check whether f(x k+1 ) > f(x k+1 ) and if not, then x k+1 is still adopted as the updated guess. Okay, so what if we know that f and its derivative are well-defined and well-behaved everywhere; can we sit back and relax? Unfortunately the answer is no. If f is not a 4

monotone function, then we also have additional concerns to worry about. Indeed, it is possible to construct a non-monotone C 1 function on the entire real line having only one zero, but where there is a continuum of initial guesses for which Newton s method will never converge, as in Figure (can you tell what the interval is?). It is interesting to note that this pathological example would not even be helped by adding in a back-stepping routine as described above (why not?). Even when dealing with a nicely behaved function for which back-stepping ensures convergence almost everywhere, non-monotone functions give rise to the possibility of multiple roots. For simple functions like polynomials, we can easily bound the number of roots, but for many functions of economic interest (e.g.; the first derivative of a loglikelihood function in maximum likelihood estimation) it is not always easy to determine the number of zeros beforehand. If there are multiple roots and one of them corresponds to a global maximum (as with solutions to FOCs), then one cannot be sure of the final solution until all roots have been discovered. Newton s Method in Higher Dimensions Now that we have a good understanding of the virtues and limitations of Newton s method in one dimension, we are ready to think about it in multiple dimensions, keeping in mind that similar concerns apply here too. I will just discuss it in -D, as the extension to higher dimensions is conceptually identical. Suppose now that we have a vector-valued function f(x, y) = ( ) f1 (x, y), f (x, y) and we would like to know which (x, y) pair will give us f(x, y) = ( ). Similarly as before, for initial guess (x, y ), Newton s method again finds the root

Figure 3: f 1 (x,y) and Its Tangent Hyperplane at the Initial Guess f (x,y) and Its Tangent Hyperplane at the Initial Guess 1 1 1 1 1 X axis 1 1 Y axis 1 1 X axis 1 1 Y axis 1 8 6 Newton Updating in 3 D zeros of f 4 zero locus for f 1 initial guess Y axis 4 zero locus for f intersection of zero hyperplane and f 1 tangent intersection of zero hyperplane and f tangent 6 updated guess 8 8 6 4 4 6 8 X axis by using linear approximations to f 1 and f in the following manner: f(x, y) f(x, y ) + J(x, y ) [(x, y) (x, y )], where J(x, y ) denotes the Jacobian matrix evaluated at the initial guess. Geometrically, the linear approximations to f 1 and f are now tangent planes. Each of these tangent planes intersects with the zero-plane along a line, and the intersections of these two lines provides an updated guess for the zero of f. Figure 3 provides a graphic illustration of this process. Mathematically, the guess is updated by setting the RHS of the above equation equal to (, ) and solving for (x, y). This gives us the following recursion: (x t+1, y t+1 ) = (x t, y t ) [J(x t, y t )] 1 f(x t, y t ). Again, our stopping rule judges convergence by the Euclidean norm of f(x k+1, y k+1 ). If Newton s method was sensitive to starting points before, it is doubly so now, as we must supply an initial guess along two dimensions. Thus, adaptive step-size control 6

may become even more important. Back-stepping takes similar form here and at each iteration we check whether f(x k+1, y k+1 ) < f(x k, y k ). If not, then the adjustment from (x k, y k ) to (x k+1, y k+1 ) is cut in half and the revised update becomes (x k+1, y k+1 ) = (x k, y k ) [J(x k, y k )] 1 f(x k, y k ) 1. Similarly as before, one should also include an additional subroutine to avoid getting stuck at local minima of g((x, y) = f(x, y). 3 Applications of Newton s Method in Economics At this point, you may be wondering why an economist would ever wish to find a root of a high-dimensional vector-valued function anyway. As it turns out, this idea appears in many aspects of economics, and it generally takes two different forms: 1) solving systems of non-linear equations, and ) optimization. There are many economic models where the equilibrium arises as the solution to a system of non-linear equations. This is common in general equilibrium models where various market-clearing conditions and individual optimality conditions come together to determine prices and allocations. Optimization is very common in econometrics, where the researcher is often faced with the task of computing a parameter estimate as the optimum of some nonlinear criterion function. Prominent examples are maximum likelihood, nonlinear least squares and GMM. Exercise Consider an economy with two price-taking firms. Firm 1 has a production technology given by f(k 1, n 1 ) = k 1/3 1 n /3 1 + k 1 and Firm has a production technology given by g(k, n ) = k /3 n 1/3 + n. Suppose that the total supply of capital is and the total supply of labor is 3. The 7

equilibrium allocation of labor and capital must equalize the marginal productivities of the inputs. Therefore, we have four equations that pin down allocations: MPK 1 = MPK : MPL 1 = MPL : 1 3 3 ( k1 n 1 ( k1 n 1 Capital market clearing: k 1 + k = Labor market clearing: n 1 + n = 3. ) /3 + = ( k 3 n ) 1/3 = 1 ( ) /3 k + 1 3 n ) 1/3 Use Newton s method to compute the solution to the system of equations that defines ( ) 1/3 ( ) 1/3 k the equilibrium. HINT: to make things easier, define x 1 = 1 n 1 and k x = n and solve the first two equations by Newton s method. This will then result in a simple set of 4 linear equations in 4 unknowns. Also, multiply both sides of the first re-written equation by x 1 x to get rid of the negative exponents; this will improve numerical stability (can you see why?). A solution is contained in Part III solutions.m. I first code Newton s method by hand, but without adaptive step-size control. Luckily though, the code seems to converge for most initial guesses. I then code the solution using Miranda and Fackler s newton function, which uses uses a safeguarded back-stepping subroutine. See the references section for a URL where Miranda and Fackler s CompEcon Toolbox can be downloaded for free. Exercise 3 Write a MATLAB program to generate a random sample from the Weibull distribution. Pick some parameter values and then construct a log-likelihood function to estimate those parameters from the sample. Optimize the log-likelihood function using Newton s method and compute standard errors for the parameter estimates. HINT: the maximum likelihood estimator is defined as the root of the first-order condition of the log-likelihood function. The FOC is sometimes called the score vector, and it is a two-dimensional vector-valued function, where each element of the vector is a realvalued function of two variables. The first derivative of the score vector is a matrix called the Hessian, and it is needed for Newton s method (see above). Aside from 8

computational speed, another advantage to Newton s method in the context of maximum likelihood is that the inverse of the Hessian (evaluated at the optimized parameter values) provides an estimator for the variance-covariance matrix for parameter estimates. 4 References: Miranda, Mario J. and Paul L. Fackler. Applied Computational Economics and Finance. MIT Press,. Miranda, Mario J. and Paul L. Fackler. CompEcon Toolbox for MATLAB to accompany Applied Computational Economics and Finance. Downloaded from http://www4.ncsu.edu/ pfackler/compecon/ on 3/8/8. 9