[Rd] Variables ordering problem in mle() (PR#9313)

sebastien.villemot at ens.fr sebastien.villemot at ens.fr
Tue Oct 24 11:55:17 CEST 2006


Full_Name: Sébastien Villemot
Version: 2.4.0
OS: Debian testing
Submission from: (NULL) (62.212.121.128)


Hi,

In the mle() function of the stats4 package, there is a bug in the ordering of
the variables given in the 'start' argument.

By just changing the order of the variables listed in the 'start' list (the
initialization values), it is possible to obtain different estimation results
(actually different local minima).

The bug is easy to reproduce, with the following example:

> library(stats4)
> g <- function(x, y) -cos(x) + abs(y)
> mle(g, start = list(x = 0, y = 7))

Call:
mle(minuslogl = g, start = list(x = 0, y = 7))

Coefficients:
           x            y 
0.000000e+00 1.409463e-18 

> mle(g, start = list(y = 7, x = 0))

Call:
mle(minuslogl = g, start = list(y = 7, x = 0))

Coefficients:
       x        y 
6.283185 0.000000 


The problem comes from the reordering of the 'start' list at the following line
of the body of 'mle':
  start <- start[order(oo)]
which is not accompanied by a reordering of the 'nm' list used in the 'f' local
function at:
    names(l) <- nm

Greets,

S.V.


> sessionInfo()
R version 2.4.0 (2006-10-03)
i486-pc-linux-gnu

locale:
LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "stats4"    "methods"   "stats"     "graphics"  "grDevices" "utils"
[7] "datasets"  "base"




More information about the R-devel mailing list