Skip to content
Prev 360259 / 398503 Next

Interquartile Range

Hi,

Jumping into this thread mainly on the point of the mode of the distribution, while also supporting Bert's comments below on theory.

If the vector 'x' that is being passed to this function is an integer vector, then a tabulation of the integers can yield a 'mode', presuming of course that there is only one unique mode. You may have to decide how you want to handle a multi-modal discrete distribution.

If the vector 'x' is continuous (e.g. contains floating point values), then a tabulation is going to be problematic for a variety of reasons.

In that case, prior discussions on this point, have yielded the following estimation of the mode of a continuous distribution by using:

Mode <- function(x) {
  D <- density(x)
  D$x[which.max(D$y)]
}

where the second line of the function gets you the value of 'x' at the maximum of the density estimate. Of course, there is still the possibility of a multi-modal distribution and the nuances of which kernel is used, etc., etc.

Food for thought.

Regards,

Marc Schwartz