Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Simple evaluation of lf evaluators in mata...

From (Jeff Pitblado, StataCorp LP)
Subject   Re: st: Simple evaluation of lf evaluators in mata...
Date   Tue, 15 Jan 2013 13:39:31 -0600

Matthew Baker <> want to make direct calls to an
'lf' evaluator that was used with -moptimize()-:

> I am encountering the following problem with trying to evaluate
> objective functions written up under different sorts of evaluators in
> mata. The problem is, one can easily evaluate functions written for d0
> evaluators through direct application of the function, but this
> doesn't appear to be the case. That is, if I've constructed a model
> statement M to go with a d0 evaluator and a function d0eval(), I can
> do:
> d0eval(0,M,params,val=.,g=.,H=.)
> and val contains the value of the function evaluated at the
> parameters. If I try this with a type lf evaluator lfeval(), and do:
> lfeval(0,M,params)
> the function is stuck at a previously determined value. My question:
> is there a way to get a quick function evaluation in the lfeval()
> situation, as in the d0eval() situation? Perhaps the following coded
> example will illustrate the problem:
> (example omitted)
> Any advice? I suspect that the optimization is overwriting some aspect
> of the structure underlying the problem and just uses that once
> overwritten.

This kind of thing is just not possible with the 'lf' evaluator, but it is
possible with 'lf0' evaluators.  Here is a modified version of Matthew's
example using an 'lf0' evaluator:

***** BEGIN:
/* Now, a type lf0 evaluator */
function lregeval_lf0(M,todo,b,crit,s,H)
        real colvector p1, p2
        real colvector y1

moptimize_init_eq_indepvars(Q,1,"price weight displacement")
***** END:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index