[R] optim: abnormal termination in lnsrch (resend)

Ravi Varadhan RVaradhan at jhmi.edu
Tue Jan 12 19:41:39 CET 2010


Mario,

It seems likely that your function is not smooth in the parameters.  This
may create problems for some optimizers that require smoothness.  However, I
was able to get good convergence with `spg' function in my "BB" package.  

Here is how it works:

> require(BB)
Loading required package: BB
Loading required package: numDeriv

> m <- spg(param, fold.err, xx=h$x, yy=h$y, lower=lo, upper=up)
iter:  0  f-value:  7.597257  pgrad:  0.037 
iter:  10  f-value:  7.551395  pgrad:  0.03674868 
iter:  20  f-value:  7.5513  pgrad:  0.02421642 
iter:  30  f-value:  7.551299  pgrad:  1.865619e-05 
> m
$par
          [,1]        [,2]     [,3]       [,4]
[1,] 0.4132586 0.006864837 0.522723 0.01279469

$value
[1] 7.551299

$gradient
[1] 3.019807e-08

$fn.reduction
[1] 0.04595781

$iter
[1] 34

$feval
[1] 44

$convergence
[1] 0

$message
[1] "Successful convergence"
 
It is also interesting that `spg' converges well from a random, infeasible
starting point.

> set.seed(123)
> m <- spg(runif(4), fold.err, xx=h$x, yy=h$y, lower=lo, upper=up)
iter:  0  f-value:  102.6793  pgrad:  0.05 
iter:  10  f-value:  7.552826  pgrad:  0.01328252 
iter:  20  f-value:  7.551299  pgrad:  0.03674152 
iter:  30  f-value:  7.551299  pgrad:  0.003764237 
>

Hope this helps,
Ravi.

----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 

----------------------------------------------------------------------------
--------

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Mario Valle
Sent: Tuesday, January 12, 2010 12:45 PM
To: R-help at r-project.org
Subject: [R] optim: abnormal termination in lnsrch (resend)

Attached a script that reproduces the problem.
My function is fold.val() and at the end seems the curve contained in
lnsrch.dat is fitted quite well, but optim generates the error.

Thanks again!
		mario
-------------------------

I'm using optim(param, fun, method='L-BFGS-B', lower=lo, upper=up) to
minimize a certain function.
Often the minimization ends with the message:
ERROR: ABNORMAL_TERMINATION_IN_LNSRCH

What is optim() trying to say?
What have I to change in my function to make the minimization succeed?
Do you think using BBoptim() instead of optim() changes anything?

Thanks for your help!
			mario


--
Ing. Mario Valle
Data Analysis and Visualization Group            | 
http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)      | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82



More information about the R-help mailing list