[R] different types in quantile{stats}

Anna Kreshuk anna.krechtchouk at cern.ch
Fri Oct 28 12:50:43 CEST 2005


Dear R-users,

I've been comparing different types used in quantile() function and I 
found a thing I don't understand.
When n*p[i] is less than 1, most types return the smallest vector 
element, while type 7 interpolates between the smallest and the second 
smallest element. Other types, that generally also use linear 
interpolation, don't do it.
Example:
 > inp
 [1] -0.762498  0.785960  1.588090  1.059290  0.022041  0.423641  0.992247
 [8] -0.240316 -0.231395  0.762765 -1.474740
 > quantile(inp, p, type=6)
     0.1%      0.5%        1%        2%        5%       10%       50%
-1.474740 -1.474740 -1.474740 -1.474740 -1.474740 -1.332292  0.423641
 > quantile(inp, p, type=7)
     0.1%      0.5%        1%        2%        5%       10%       50%
-1.467618 -1.439128 -1.403516 -1.332292 -1.118619 -0.762498  0.423641
 > quantile(inp, p, type=8)
     0.1%      0.5%        1%        2%        5%       10%       50%
-1.474740 -1.474740 -1.474740 -1.474740 -1.474740 -1.142360  0.423641

Is there an explanation to it? I couldn't find anything in the function 
description.

Thanks in advance,
Anna




More information about the R-help mailing list