#1675 lsquares_estimates_approximate ignores initial

closed
5
2009-07-28
2009-05-23
Leo Butler
No

The following example is self-explanatory.

>> load(lsquares)$
>> M:matrix(
[1900,75.995],
[1910,91.972],
[1920,105.711],
[1930,123.203],
[1940,131.669],
[1950,150.697],
[1960,179.323],
[1970,203.212],
[1980,226.505],
[1990,249.633],
[2000,281.422]
)$

mse:lsquares_mse(M,[x,y],y=a*exp(b*(x-1900)));

------------------------------------------------------------
The problem appears to be that lsquares_estimates_approximate ignores
the initial value passed to it:

lsquares_estimates_approximate(mse,'[a,b],initial=[82,0.01],iprint=[1,3]);
*************************************************
VECTOR X=
1.000000000000000D+00 1.000000000000000D+00
GRADIENT VECTOR G=
1.313813415094471D+86 1.313813414823674D+88

You can see that the initial vector X is [1,1], although [82,0.01] is passed.
The minimisation diverges because of the poor initial condiition.

If you redefine mse so that [1,1] is a reasonable initial value, you
will get an estimate:

mse:subst([a=82*a,b=0.01*b],mse)$
lsquares_estimates_approximate(mse,'[a,b],iprint=[1,3]);

THE MINIMIZATION TERMINATED WITHOUT DETECTING ERRORS.
IFLAG = 0
[[a = 1.005034579667296, b = 1.243184045872825]]

Discussion

  • Leo Butler

    Leo Butler - 2009-05-23

    Robert,
    In the documentation, the initial guess is specified by 'initial ='
    while in lsquares.mac, you use 'initial_guess'. If you change 'initial_guess'
    to 'initial', this fixes the problem

    -- Function: lsquares_estimates_approximate (<MSE>, <a>, initial =
    <L>, tol = <t>)

    lsquares_estimates_approximate (MSE, parameters, [optional_args]) := block

    ([initial_guess : makelist (1, i, 1, length (parameters)),
    iprint : [1, 0],
    tol : 1e-3],

    with_parameters (optional_args,
    lbfgs (MSE, parameters, initial_guess, tol, iprint),
    [%%]));

    Leo

     
  • Leo Butler

    Leo Butler - 2009-05-23
    • assigned_to: nobody --> robert_dodier
     
  • Robert Dodier

    Robert Dodier - 2009-07-28
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2009-07-28

    Fixed by r1.8 share/contrib/lsquares.mac: changes initial_guess to initial. Closing this report as fixed.

     

Log in to post a comment.