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/