From jorismeys at gmail.com  Wed May 31 15:40:17 2017
From: jorismeys at gmail.com (Joris Meys)
Date: Wed, 31 May 2017 15:40:17 +0200
Subject: [Rd] stats::line() does not produce correct Tukey line when n
 mod 6 is 2 or 3
In-Reply-To: <c9af2c00-3653-29f8-7c6a-5a08d6de498e@insa-toulouse.fr>
References: <CAN7_cLjefc605D1ATS__MOV4gN7fKDBo5Nx_CNB_B9cDbAxc6w@mail.gmail.com>
 <ffc3e473-622d-796f-a06a-6e1f92f8ab5f@gmail.com>
 <CAN7_cLjmQFtZf9z-qJKdWRCaRY2uxfP8k5=QJsptz3U+TtP8oA@mail.gmail.com>
 <CAN7_cLjbz6S8u79jtx52XgfD1LcpO8CePYUhrunYqrzXHMMN8A@mail.gmail.com>
 <024A7E7D-45F8-4C95-A9BD-DBEB1D085BFA@gmail.com>
 <94b65a5b-da9e-ec5c-e428-7c5dbf175ec1@insa-toulouse.fr>
 <8c167bbb-130d-3798-a9e8-24c4377db313@insa-toulouse.fr>
 <d10ebb8c-0c49-5b0e-5b3c-b06073bfe447@insa-toulouse.fr>
 <22829.8246.695545.320438@stat.math.ethz.ch>
 <396781eb-1712-aa54-96f2-a6c4df0284f4@insa-toulouse.fr>
 <22829.41724.818300.640880@stat.math.ethz.ch>
 <c9af2c00-3653-29f8-7c6a-5a08d6de498e@insa-toulouse.fr>
Message-ID: <CAO1zAVb8faubH7FrBfsx8c04xsZce2p2Ei9NaBELrfn2Q8JMEA@mail.gmail.com>

OTOH,

> sapply(1:9, function(i){
+   sum(dfr$time <= quantile(dfr$time, 1./3., type = i))
+ })
[1] 8 8 6 6 6 6 8 6 6

Only the default (type = 7) and the first two types give the result lines()
gives now. I think there is plenty of reasons to give why any of the other
6 types might be better suited in Tukey's method.

So to my mind, chaning the definition of line() to give sensible output
that is in accordance with the theory, does not imply any inconsistency
with the quantile definition in R. At least not with 6 out of the 9
different ones ;-)

Cheers
Joris

On Wed, May 31, 2017 at 3:06 PM, Serguei Sokol <sokol at insa-toulouse.fr>
wrote:

> Le 30/05/2017 ? 18:51, Martin Maechler a ?crit :
>
>> Serguei Sokol <sokol at insa-toulouse.fr>
>>>>>>>      on Tue, 30 May 2017 16:01:17 +0200 writes:
>>>>>>>
>>>>>>      > Le 30/05/2017 ? 09:33, Martin Maechler a ?crit : ...
>>      >> However, even after the patch, The example from the SO
>>      >> post differs from the result of Richie Cotton's
>>      >> function...
>>      > The explanation is quite simple. In SO function, the first
>>      > 1/3 quantile of used example counts 6 points (of 19 in
>>      > total), while line()'s definition of quantile leads to 8
>>      > points. The same numbers (6 and 8) are on the other end of
>>      > sample.
>>
>> so the number of obs. for the three thirds for line() are
>>     {8, 3, 8}  in line()  [also, after your patch, right?]
>>
>> whereas in MMline() they are as they should be, namely
>>
>>     {6, 7, 6}
>>
>> But the  {8, 3, 8}  split is not at all what all "the literature",
>> including Tukey himself says that "should" be done.
>> (Other literature on the topic suggests that the optimal sizes
>>   of the split in three groups depends on the distribution of x ..)
>>
>> OTOH, MMline() does exactly what "the literature" and also  the
>> reference on the  ?line  help pages says.
>>
> Well, what I have seen so far in "literature" was mention of 1/3 quantiles
> (but, yes I could overlook smth as I did not spend too much time on it)
> So the sample distribution in three groups boils down to a particular
> quantile
> definition to use. It turns out that the line()'s version (you are right,
> _after_ the patch
> but my patch left this definition untouched) is consistent with the R's
> one.
> If you do in R sum(dfr$time <= quantile(dfr$time, 1./3.)) you get 8, not 6
> (and the same on the 2/3 end).
> To my mind, consistency with the rest of R, namely with the quantile
> definition,
> is an argument good enough to let the line()'s definition as is.
>
> Serguei.
>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Mathematical Modelling, Statistics and Bio-Informatics

tel :  +32 (0)9 264 61 79
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



[Rd] stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
Joris Meys