Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: mata code that calculates numerical partial derivates


From   KAI LIU <kliu@jhu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: mata code that calculates numerical partial derivates
Date   Tue, 12 Aug 2008 16:39:24 -0400

I am looking for mata code that will calculate numerical partial 
derivates of any given function, m(p) where p is a kx1 vector..

As a simple example consider the following transparent m(p) function
Mata:
p1=1
p2=3
m=p1^2+p2

I am looking for a routine that will return
mprime=[2,1].

The only numerical gradients routine I can find is the Stata dydx 
command. This command, however, only gives derivatives of bivariate 
relationships. A more general Mata routine must exist since optimize 
uses numerical gradients to optimize f(p). It then returns the gradiants 
for the k optimized p’s, My application requires that I then evaluate 
the gradiants of another function of p (i.e. m(p)). 

Any help would be much appreciated.

Kai
 
*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index