vi...@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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to