Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
vesile kutlu <kutlu.vesile@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: could not calculate numerical derivatives |

Date |
Tue, 20 Nov 2012 14:47:48 +0100 |

Austin, thank you for your suggestion. I think mm_root is for finding one root (univariate) of a function. In my case, I need a bivariate root finder because I have two arguments in my objective function. I tried something different with the “optimize” command. I used the d1 evaluator and entered the first order conditions manually. I do not get the error “could not find numerical derivatives” anymore. However, I have another problem. The solution is identical to the initial values. If I enter (1,1) for initial values, the program returns (1,1) as a solution. Is there anyone who knows why this is the case? Thank you. : void mysolver(todo, p, v, g, H) v = (0.7-exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*75))))^2+(0.4-exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*80))))^2 if (todo==1) { g[1] = -2*exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*75)))*(0.7-exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*75))))*((1/p[2])*(exp(p[2]*48)-exp(p[2]*7 5)))-2*exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*80)))*(0.4-exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*80))))*((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*80)) g[2] = -2*exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*75)))*(0.7-exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*75))))*((p[1]/(p[2]^2))*(-exp(p[2]*48)+ex p(p[2]*75)))-2*exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*80)))*(0.4-exp((p[1]/p[2])*(exp(p[2]*48)-exp(p[2]*80))))*((p[1]/(p[2]^2))*(-exp(p[2]*48)+ exp(p[2]*80))) } } note: argument H unused S = optimize_init() optimize_init_evaluator(S, &mysolver()) optimize_init_evaluatortype(S, "d1") optimize_init_params(S, (0.5,0.5)) optimize_init_which(S, "min") p=optimize(S) Iteration 0: f(p) = .65 Iteration 1: f(p) = .65 p 1 2 +-----------+ 1 | .5 .5 | +-----------+ Vesile Phd Candidate, Utrecht University On Tue, Nov 20, 2012 at 11:55 AM, Austin Nichols <austinnichols@gmail.com> wrote: > vesile kutlu <kutlu.vesile@gmail.com>: > User-written mm_root(); see > http://www.stata.com/statalist/archive/2009-01/msg01140.html > > On Tue, Nov 20, 2012 at 5:34 AM, vesile kutlu <kutlu.vesile@gmail.com> wrote: >> Hi all, >> I am trying to solve the function “v” numerically in Mata but I get >> the error ” could not calculate numerical derivatives -- discontinuous >> region with missing values encountered”. I ask Mata to minimize this >> function with respect to a and b. I provide the initial values of >> these parameters. Is there something wrong with my code? I would >> appreciate if you could tell me why I got this error? Is there maybe >> another way to solve this problem? Thank you. >> Vesile >> void mysolver(todo, p, v, S, H) >> { >> a=p[1] >> b=p[2] >> v=(0.7-exp((a/b)*(exp(b*48)-exp(b*75))))^2+(0.4-exp((a/b)*(exp(b*48)-exp(b*80))))^2 >> } >> S=optimize_init() >> optimize_init_evaluator(S, &mysolver()) >> optimize_init_evaluatortype(S, "v0") >> optimize_init_params(S, (1,1)) >> optimize_init_which(S, "min") >> p=optimize(S) >> p >> end > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: could not calculate numerical derivatives***From:*vesile kutlu <kutlu.vesile@gmail.com>

**Re: st: could not calculate numerical derivatives***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: example about choice experiment datasheet** - Next by Date:
**st: could not calculate numerical derivatives** - Previous by thread:
**Re: st: could not calculate numerical derivatives** - Next by thread:
**st: could not calculate numerical derivatives** - Index(es):