[RsR] question (seeds robustbase::ltsReg)

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Tue Oct 27 19:20:11 CET 2015


I'm answering on the dedicated mailing list,
if others are asking the same question, they my now find it here
via Google :

>>>>> kaveh  <Kaveh.Vakili @ KU Leuven >
>>>>>     on Fri, 23 Oct 2015 18:33:16 +0200 writes:

    > Dear Prof. Maechler,

    > I hope this email finds you well. I have a question about
    > the way seeds are set in robustbase::ltsReg and I hope
    > this is the correct way to ask it.

    > It will be simpler to illustrate it with an example:

    > -----------------------------------------------------------------------------------
    > #I run a fastlts regression, say on the stackloss data:

    > library(robustbase)
    > mycont <- rrcov.control(seed=.Random.seed)
    > lts1 <- ltsReg(stack.loss~.,data=stackloss,control=mycont)


    > #Doing this changes the content of .Random.seed:
    > .Random.seed[6]
    > rm(.Random.seed);a1<-runif(1)
    > #compare with above:
    > .Random.seed[6]

    > mycont <- rrcov.control(seed=.Random.seed)
    > lts2 <- ltsReg(stack.loss~.,data=stackloss,control=mycont)

    > #I am now expecting the fastlts fits to change a bit,
    > since I used two different seeds. Yet, I systematically
    > observe that:

    > lts2$scale-lts1$scale

is 0...

Even more,

  all.equal(lts1, lts2)

actually confirms they are the same solutions.

    > -----------------------------------------------------------------------------------

    > My questions is: am I passing different seeds to lts1 and
    > lts2 or do I not use the 'seed' function correctly?

Yes, you *are* passing different seeds to lts1 and lts2

(and even easier is to *NOT* set any seeds here: Then, ltsReg() uses R's
 internal .Random.seed manipulation, which also gets different random
 numbers every time !!)

In this very small scale simple data set,  stackloss,

many (or most ((or all)) ?) seeds may be sufficient to find the
"minimal" / "optimal" subset of observations (i.e., the true LTS estimate)

==> hence many (or most ((or all)) ?) of the ltsReg() solutions
    coincide for such a small simple data set.

    > Thanks in advance for your time,

You are welcome!

Best regards,
Martin Maechler




More information about the R-SIG-Robust mailing list