Statalist


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

st: RE: mata code that calculates numerical partial derivates


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   <[email protected]>
Subject   st: RE: mata code that calculates numerical partial derivates
Date   Thu, 14 Aug 2008 09:41:51 -0500

Kai - 

Perhaps you can find a way to use -testnl- in Stata. This command
provides a matrix of partial derivatives: "r(G)"

Al Feiveson

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of KAI LIU
Sent: Tuesday, August 12, 2008 3:39 PM
To: [email protected]
Cc: Peter Gottschalk
Subject: st: mata code that calculates numerical partial derivates

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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index