[R] Not nice behaviour of nlminb (windows 32 bit, version 2.11.1)

Ravi Varadhan rvaradhan at jhmi.edu
Fri Jul 9 23:05:47 CEST 2010


An absolute criterion should NEVER be used.  For the situation where f(x*) =
0, instead of the PORT criterion (6) we should use the following:

|f(x_{n+1}) - f(x_n)| < (rel.tol * |f(x_n)| + abs.tol)


Ravi.

-----Original Message-----
From: Ravi Varadhan [mailto:rvaradhan at jhmi.edu] 
Sent: Friday, July 09, 2010 4:45 PM
To: 'Ravi Varadhan'; 'Duncan Murdoch'; 'Matthew Killeya'
Cc: r-help at r-project.org; bates at stat.wisc.edu
Subject: RE: [R] Not nice behaviour of nlminb (windows 32 bit, version
2.11.1)

Setting abs.tol = 0 works!  This turns-off the absolute function convergence
criterion.


> nlminb( objective=function(x) x, start=1, lower=-2, upper=2,
control=list(abs.tol=0))
$par
[1] -2

$objective
[1] -2

$convergence
[1] 0

$message
[1] "both X-convergence and relative convergence (5)"

$iterations
[1] 3

$evaluations
function gradient 
       3        3 


This is clearly a bug.


Ravi.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Ravi Varadhan
Sent: Friday, July 09, 2010 4:42 PM
To: 'Duncan Murdoch'; 'Matthew Killeya'
Cc: r-help at r-project.org; bates at stat.wisc.edu
Subject: Re: [R] Not nice behaviour of nlminb (windows 32 bit, version
2.11.1)

Duncan, `nlminb' is not intended for non-negative functions only.  There is
indeed something strange happening in the algorithm!

start <- 1.0 # converges to wrong minimum

startp <- 1.0 + .Machine$double.eps  # correct

startm <- 1.0 - .Machine$double.eps  # correct

> nlminb( objective=obj, start=start, lower=-2, upper=2)
$par
[1] 0

$objective
[1] 0

$convergence
[1] 0

$message
[1] "absolute function convergence (6)"

$iterations
[1] 1

$evaluations
function gradient 
       2        2 

> 
> nlminb( objective=obj, start=startp, lower=-2, upper=2)
$par
[1] -2

$objective
[1] -2

$convergence
[1] 0

$message
[1] "both X-convergence and relative convergence (5)"

$iterations
[1] 3

$evaluations
function gradient 
       3        3 

> 
> nlminb( objective=obj, start=startm, lower=-2, upper=2)
$par
[1] -2

$objective
[1] -2

$convergence
[1] 0

$message
[1] "both X-convergence and relative convergence (5)"

$iterations
[1] 3

$evaluations
function gradient 
       3        3 


>From the convergence message the `absolute function convergence' seems to
be
the culprit, although I do not understand why that stopping criterion is
becoming effective, when the algorithm is started at x=1, but not at any
other values.  The documentation in IPORT makes it clear that this criterion
is effective only for functions where f(x*) = 0, where x* is a local
minimum.  In this example, x=0 is not a local minimum for f(x), so that
criterion should not apply.

 
Ravi.


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Duncan Murdoch
Sent: Friday, July 09, 2010 3:45 PM
To: Matthew Killeya
Cc: r-help at r-project.org; bates at stat.wisc.edu
Subject: Re: [R] Not nice behaviour of nlminb (windows 32 bit, version
2.11.1)

On 09/07/2010 10:37 AM, Matthew Killeya wrote:
>  nlminb( obj = function(x) x, start=1, lower=-Inf, upper=Inf )
>   

If you read the PORT documentation carefully, you'll see that their 
convergence criteria are aimed at minimizing positive functions.  (They 
never state this explicitly, as far as I can see.)  So one stopping 
criterion is that |f(x)| < abs.tol, and that's what it found for you.  I 
don't know if there's a way to turn this off.

Doug or Deepayan, do you know if nlminb can be made to work on functions 
that go negative?

Duncan Murdoch

> $par
> [1] 0
>
> $objective
> [1] 0
>
> $convergence
> [1] 0
>
> $message
> [1] "absolute function convergence (6)"
>
> $iterations
> [1] 1
>
> $evaluations
> function gradient
>        2        2
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list