Skip to content

robustbase problem [bug?] in adjbox function.

7 messages · Martin Maechler, Kaveh Vakili, Peter Ehlers

#
hello list,

i'm a bit puzzled by the error message i get when i copy past this in R:
data<-c(16,13,17,4,15,24,59,18,33,8,42,19,20,4,11,9,3,7,10,3,3,67,4,4,13,16,6,3,3,6,3,4,35,10,16,11,24,7,47,8,8,2,12,3,8,4,3,6,6,10,2,9,3,15,21,13,8,16,2,5,14,9,21,4,9,11,36,4,8,4,6,4,10,13,11,5,4,16,14,3,22,20,5,2,8,12,14,27,2,13,8,18,18,6,31,3,14,23,13,27,13,6,7,10,12,3,17,30,3,13,13,9,29,4,4,18,7,23,4,20,3,9,4,4,3,3,5,32,11,3,4,5,10,12,7,4,13,10,11,37,6,8,6,3,12,8,10,6,12,7,8,9,5,6,12,5,4,24,7,2,9,2,4,3,8,5,10,5,4,4,7,4,7,7,4,16,4,3,12,4,3,10,27,4,14,7,10,4,9,8,3,5,3,8,5,2,8,38,3,3,3,4);
plot(x=c(1,2),y=rep(1,2),ylim=range(data),xlim=c(0.5,2.5),type="n",main=c("Adjusted
boxplot vs. Classical boxplot"),ylab=c("Loss Data"),xlab=c(""),axes=F)
adjbox(x=datac,pars=list(outpch=16,outcex=2,outcol="light
blue"),add=T,at=1,col="light blue")
boxplot(x=datac,pars=list(outpch=16,outcex=2,outcol="light
green"),add=T,at=2,col="light green")
axis(2,at=seq(0,max(data)+10,by=10),col="orange",labels=F)
axis(1,at=c(1,2),col="orange",labels=c("Adjusted boxplot","Classical
boxplot"))

in my computer adjbox says:

"maximal number of iterations (100 =? 100) reached prematurely
Error in mc.default(x, na.rm = TRUE) : 
  mc(): not 'converged' in 100 iterations"

R2.12 and the latest version of robustbase -in ubuntu 10.10).
#
On 2010-12-07 12:01, kv wrote:
You're not exactly providing a 'minimal' example. (We don't need
to know your colour preferences and plot titles, etc, since
those have no relation to the problem.)

The problem is with mc() which adjbox() calls (as is stated
on the help page for adjbox).

I suspect that there may indeed be a bug in the C code called
by mc(), possibly related to ties. I saw no comments about
ties on the help page for mc().

A workaround for you might be to add a very small disturbance
to your data, e.g. rnorm(length(datac), sd = 1e-10).

Note to the maintainer:
Here's a slightly simpler reproducible example:

set.seed(15)
x <- sort(sample(67, 101, TRUE))
mc(x)
# maximal number of iterations (100 =? 100) reached prematurely
# Error in mc.default(x) : mc(): not 'converged' in 100 iterations

Eliminating any one of the elements of x with index in
c(17:18, 33:45, 48:50) results in convergence.


Peter Ehlers
#
Thanks Peters, what i suspected (i.e. ties). For what it's worth i would add
that the problem happends when length(data)>100 (i.e. the second condition
in the mc.default() function).

Best,
#
Thank you, Peter.
(see inline)
On Wed, Dec 8, 2010 at 14:58, Peter Ehlers <ehlers at ucalgary.ca> wrote:
[.............]
Indeed, there had been problems in the C code of mc.
"Interestingly", only a couple of days ago, we (robustbase developers)
had started an effort to resolve the issue, and indeed, Manuel Koller
(and I to a small extent)
has looked at the code, and found why it fails in some cases
((For the interested: We had the "infamous" situation that
   if(x >= y) {
        <but inside the "true" branch,  x < y (and x = y-eps, for a
very small eps)
   }

as experts know, this *can* happen (and hence does happen in
practice!), e.g., as

The development version of robustbase, available from R forge, e.g., by
       install.packages("robustbase", repos="http://R-Forge.R-project.org")
now has this problem corrected,
and actually we'd be very happy if you could stress test this version.

A release is planned soon, and actually only delayed by a careful
modification of the Qn() finite sample correction ... as the new
version corrects a long-standing typo in the decimal digits of the
consistency factor  in the original codes and publications of the very
first publications and papers.

Thank you for your feedbacks!
Martin Maechler, ETH Zurich (and maintainer of 'robustbase')
#
On 2010-12-08 06:39, kv wrote:
I don't think that the length of 100 is special (other
than in the 'doReflect' default).

Here are a couple of short vectors that cause the
error message:

  x1 <- c(13, 30, 30, 32, 39, 40, 40, 40, 42)
  x2 <- c(11, 31, 39, 39, 42, 46, 49, 49, 50)

  mc(x1, doReflect=FALSE)
  mc(x1, doReflect=TRUE)
  mc(x2, doReflect=FALSE)
  mc(x2, doReflect=TRUE)


Peter Ehlers
#
My apologies to Martin.

I should have known how prompt he would be and I should have
been more on the ball in checking incoming mail.

The new version of robustbase on R-Forge does indeed fix this.
Thanks to the robustbase team.

Peter
On 2010-12-08 07:57, Peter Ehlers wrote: