On 10-09-07 02:48 PM, Hey Sky wrote:
> thanks. Ben
>
> after read your email, I realized the initial value of w[5]=0 is a
> stupid mistake. and I have changed it. but I am sorry I cannot
> reproduce the result, convergence, as you get. the error message is
> <non-finite finite difference value [12]>. any suggestion about
> it?

    When I 'fix' the objective function as you specified in your
second message, I get into trouble too.

>
> and could you plz recommend some R books on optimization, such as
> tips for setup gradient and others, or common mistakes?  thanks
>
> Nan
>

  I'm afraid I don't know of a great reference, although pp. 340-341
of <http://www.math.mcmaster.ca/~bolker/emdbook/book.pdf> do give some
basic trouble-shooting suggestions (nothing about gradients, though,
but the example in ?optim does use gradients).  I would say that my
best _general_ advice is to  understand what all the parameters of
your model mean: what are reasonable starting values and reasonable
ranges?  Use control(parscale) to tell R the approximate expected
order of magnitude of each parameter. You may be able to keep the
model from getting into trouble by using method="L-BFGS-B" and
bounding the parameters within a reasonable range.  For more general
troubleshooting: try different optimization methods (in particular,
Nelder-Mead doesn't need to compute finite differences); trap
non-finite (NA, NaN, Inf, -Inf) that occur in the function and report
them and/or stop the function (see ?browser) and/or replace them with
large finite values; use control(trace=TRUE) or add cat() statements
to your function to see where the optimizer is trying to go.

  good luck,
    Ben Bolker



	[[alternative HTML version deleted]]

