[Rd] bug in L-BFGS-B? (PR#8099)

From: <berwin_at_maths.uwa.edu.au>
Date: Sat 27 Aug 2005 - 14:10:28 GMT

--WWm7B+u2U4

Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit

G'day all,

I believe that this is related to PR#1717 (filed under not-reproducible) which was reported for a version of R that is a quite a bit older than the ones used in for this report. But I noticed this behaviour under R 2.1.1 and R 2.2.0 on my linux box and under R 2.0.1 and R 2.1.1 on my Windows box.

I recently ran the examples for fitdistr in the MASS library and on my linux machine I get the following results:

> library(MASS)
> set.seed(123)
> x <- rgamma(100, shape = 5, rate = 0.1)
> fitdistr(x, "gamma")

     shape rate
  6.45947303 0.13593172
 (0.89052006) (0.01948648)
> fitdistr(x, dgamma, list(shape = 1, rate = 0.1), lower = 0.01)

      shape rate
  2.156761461 0.010000000
 (0.277607887) (0.001433778)

I find the second result quite extraordinary. O.k., the likelihood that is maximised is quite flat along a certain direction, but I don't think that it is so flat that it should fool the underlying optimisation routine into believing that it has converged.

Moreover:

> fitdistr(x, dgamma, list(shape = 1, rate = 0.1), lower = 0.001)

     shape rate
  6.48686551 0.13651012
 (0.89438949) (0.01956818)

As far as I can tell, the problem is with L-BFGS-B hitting the lower bound and stopping, the same problem as reported in #1717.

I tried the same comments on my Windows box and the result is as attached below (together with the system information that bug.report produces on that machine). Looking at the output given on the Windows machine, I am actually amazed that my Linux box didn't give me any of those warning messages --- the R input/output given above is cut and paste. I am not aware of any fiddling with ptions regarding warning messages by any configurations files anywhere on my linux system; and I ran the same commands using `R --vanilla' on the linux box and did not get any warning messages.

Cheers,

        Berwin

--WWm7B+u2U4

Content-Type: text/plain
Content-Description: Manifestation of bug on a Windows machine
Content-Disposition: inline;
	filename="Bug.txt"

Content-Transfer-Encoding: 7bit

> set.seed(123)
> x <- rgamma(100, shape = 5, rate = 0.1)
> fitdistr(x, "gamma")

     shape rate
  6.48592894 0.13649147
 (0.89425721) (0.01956555)
Warning messages:

1: NaNs produced in: dgamma(x, shape, scale, log) 
2: NaNs produced in: dgamma(x, shape, scale, log) 
3: NaNs produced in: dgamma(x, shape, scale, log) 

> fitdistr(x, dgamma, list(shape = 1, rate = 0.1), lower = 0.01)
shape rate

  2.156761461 0.010000000
 (0.277607888) (0.001433778)
Warning message:
bounds can only be used with method L-BFGS-B in: optim(start, mylogfn, x = x, hessian = TRUE, ...)
> fitdistr(x, dgamma, list(shape = 1, rate = 0.1), lower = 0.001)

     shape rate
  6.48686551 0.13651012
 (0.89438949) (0.01956818)
Warning message:
bounds can only be used with method L-BFGS-B in: optim(start, mylogfn, x = x, hessian = TRUE, ...)

--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status =
 major = 2
 minor = 1.1
 year = 2005
 month = 06
 day = 20
 language = R

Windows XP Professional (build 2600) Service Pack 2.0

Locale:
LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252

Search Path:
 .GlobalEnv, package:MASS, package:methods, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, Autoloads, package:base

--WWm7B+u2U4

Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit


--please do not edit the information below--

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = Under development (unstable)
 major = 2
 minor = 2.0
 year = 2005
 month = 08
 day = 26
 svn rev = 35424
 language = R

Locale:
C

Search Path:
 .GlobalEnv, package:methods, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, Autoloads, package:base

--WWm7B+u2U4--



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun Aug 28 00:13:55 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:19 GMT