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

From |
KAI LIU <kliu@jhu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: take numerical derivatives in Mata |

Date |
Mon, 11 Aug 2008 18:57:31 -0400 |

Dear statalist users, I am seeking help on commands that could take numerical derivative of an arbitrary function v=f(p) in MATA. For example, I have an optimization routine for function v(p_1, p_2): void eval0(todo, p, v, g, H) { m = exp(-p[1]^2 - p[2]^2 - p[1]*p[2] + p[1] - p[2]) w= p[1]^2 v=(w-m)^2 } S = optimize_init() optimize_init_evaluator(S, &eval0()) optimize_init_params(S, (0,0)) p = optimize(S) The "optimize_result_gradient(S)" command would give gradient vector for function v. But is there any way to take derivatives with respect to function m() or w(), say at the optimized value of p? I tried various ways to execute the stata command "dydx" (which takes derivatives in stata environment) under Mata by using stata("dydx m p[1],generate(x)"), and didn't make it work either. Really appreciate if someone familiar with mata could give me a hand on this. Many thanks in advance. 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/

- Prev by Date:
**st: Saving labels in macros** - Next by Date:
**st: Oops, sorry about that** - Previous by thread:
**st: Saving labels in macros** - Next by thread:
**st: Oops, sorry about that** - Index(es):

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