From murdoch at stats.uwo.ca  Wed Oct  7 13:03:55 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 07 Oct 2009 07:03:55 -0400
Subject: [Rd] inconsistency in return value of peaks() {splus2R}
	(PR#13988)
In-Reply-To: <20091007101510.53ED4282BEA9@mail.pubhealth.ku.dk>
References: <20091007101510.53ED4282BEA9@mail.pubhealth.ku.dk>
Message-ID: <4ACC759B.8080700@stats.uwo.ca>

vijgh at phil.uu.nl wrote:
> Full_Name: Benny van der Vijgh
> Version: 2.7.2
> OS: Windows Vista
> Submission from: (NULL) (194.171.252.108)
>
>
> The return value of peaks() in package splus2R is not consistent. 
>   

This is not an R bug.  Please contact the author of that package.

Duncan Murdoch
> This is because of the call to max.col() without additional parameters which
> peaks() makes.
> max.col() has a parameter 'ties.method' which specifies how ties are handled,
> with "random" by default. 
> This means that when peaks() is called on a vector with two (or more)
> neighbouring elements in a tie for the local maximum, these end up in the same
> row in the embedded matrix after which max.col() at random chooses which will be
> considered the maximum, thereby yielding inconsistent results, for example:
>
>   
>> a <- c(3,5,5,3)
>> peaks(a)
>>     
> [1] FALSE FALSE FALSE FALSE
>   
>> peaks(a)
>>     
> [1] FALSE  TRUE FALSE FALSE
>
> this can be easily fixed by setting the parameter 'ties.method' for max.col() to
> "first" or "last", which is a matter of application and taste I think, perhaps
> it can even be considered to make this parameter also a parameter of peaks() and
> pass it to max.col() in the execution.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] inconsistency in return value of peaks() {splus2R} (PR#13988)
Duncan Murdoch