*
* @ELFCalc( options ) start end
* # list of series with moment conditions
*
* Computes the empirical likelihood for a set of moment conditions, that is, it
* finds the maximum of sum log w(i) subject to
*
* (a) sum w(i)=1
* (b) sum w(i)f(i)=0
*
* where f are the moment conditions input as a set of series
*
* This operates by minimizing the Lagrangean with respect to the Lagrange
* multipliers on the (b) conditions. The Lagrange multiplier on the adding up
* constraint is pegged at 1, with the w's corrected for this by scaling by their
* sum over the sample. The w's are concentrated out by solving their FONC's
* (w(i)**-1 - 1+lambda*f(i))=0, i.e. w(i)=1.0/(1+lambda*f(i)).
*
* Options:
* ITERS=maximum number of iterations [40]
* SUBITERS=maximum number of subiterations [10]
* CVCRIT=convergence criterion on Lagrange multipliers [1.e-6]
* TRACE/[NOTRACE]
* W=series of weights
*
* Returns %FUNCVAL as the empirical log likelihood
*
* Revision Schedule
* 09/2005 Written by Tom Doan, Estima
*
procedure ELFCalc start end
*
option integer iters 40
option integer subiters 10
option real cvcrit 1.e-6
option switch trace 0
option series *w
*
local vect[integer] moments
local equation temp
local vector lambda lambdax g d
local series wx
local integer n it subits
local real f0 scale func lmvalue sumw
local integer startl endl basenobs
*
* Get the list of moment conditions. Figure out the range based upon them.
*
enter(varying) moments
compute n=%rows(moments)
inquire(reglist) startl<>func wx>>sumw
*
* Compute the concentrated Lagrangean
*
compute lmvalue=func-%nobs*log(sumw)+sumw
*
* Take the first valid set of values which improves (reduces)
* the function value.
*
if %valid(lmvalue).and.lmvalue