Explain the quantile() function in R

前端 未结 3 468
一生所求
一生所求 2020-12-22 20:51

I\'ve been mystified by the R quantile function all day.

I have an intuitive notion of how quantiles work, and an M.S. in stats, but boy oh boy, the documentation

3条回答
  •  借酒劲吻你
    2020-12-22 21:35

    There are various ways of computing quantiles when you give it a vector, and don't have a known CDF.

    Consider the question of what to do when your observations don't fall on quantiles exactly.

    The "types" are just determining how to do that. So, the methods say, "use a linear interpolation between the k-th order statistic and p(k)".

    So, what's p(k)? One guy says, "well, I like to use k/n". Another guy says, "I like to use (k-1)/(n-1)" etc. Each of these methods have different properties that are better suited for one problem or another.

    The \alpha's and \beta's are just ways to parameterize the functions p. In one case, they're 1 and 1. In another case, they're 3/8 and -1/4. I don't think the p's are ever a constant in the documentation. They just don't always show the dependency explicitly.

    See what happens with the different types when you put in vectors like 1:5 and 1:6.

    (also note that even if your observations fall exactly on the quantiles, certain types will still use linear interpolation).

提交回复
热议问题