Bob - Try looking at http://www.stata.com/meeting/3nasug/abstracts.html
Al Feiveson
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Bob Hammond
Sent: Tuesday, March 03, 2009 4:24 PM
To: [email protected]
Subject: st: Maximize a function that contains an integral
All,
I want to find the maximum of a function that contains an integral without an analytical solution. The difficulty is that the argument of the maximization is the lower bound of the integral. Consider the following trivial example: find the x that maximizes f(x), where f(x) is the integral of z (with respect to z) from a lower bound of x to an upper bound of 0. Computing the integral by hand shows that x* = 0 (because f(x) = -0.5x^2) but I would like to know how to code this without invoking the analytical solution.
Note that I cannot simply differentiate f(x) with respect to x and use a root finder (e.g., mm_root) to find the optimum because my f'(x) also contains an integral.
I've used Stata's integ command to great effect in similar applications but do not know how to embed it into my problem of maximizing f(x). It occurred to me that I could use ml instead of Mata but I'm not sure how that would be done since the argument of the optimization problem is the lower bound of the integration.
The most promising approach that I've found seems to be "Quadrature on sparse grids":
http://sparse-grids.de/#Stata
which contains a Mata function nwspgr() in a zip file. I've spent some time with this function and it's very accurate but I cannot figure out how to manipulate the integration bounds such that the lower bound is a variable that I can feed in from an optimizer such as Mata's optimize.
I will contact the authors of nwspgr() but I wanted to check a few things before doing so:
1. Is there an existing Mata equivalent to integ (which easily allows manipulation of the integration bounds)?
2. Relative to using Mata and (possibly) nwspgr(), would it be simpler to use integ and ml? If so, I would appreciate any tips.
Thanks,
Bob
--
------------------------------------------------------------------------
Bob Hammond
Department of Economics
North Carolina State University
Office: (919) 513-2871
Fax: (919) 515-7873
http://www4.ncsu.edu/~rghammon/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/