quantile(stats)
quantile()所属R语言包:stats
Sample Quantiles
采样位数
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The generic function quantile produces sample quantiles corresponding to the given probabilities. The smallest observation corresponds to a probability of 0 and the largest to a probability of 1.
通用函数quantile生产样品位数对应给定的概率。最小的观察对应的概率为0,最大的概率为1。
用法----------Usage----------
quantile(x, ...)
## Default S3 method:[默认方法]
quantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE,
names = TRUE, type = 7, ...)
参数----------Arguments----------
参数:x
numeric vector whose sample quantiles are wanted, or an object of a class for which a method has been defined (see also "details"). NA and NaN values are not allowed in numeric vectors unless na.rm is TRUE.
数字的向量,其位数想要的样本,或一个方法(见“详情”)已定义的类的对象。 NA和NaN值不会允许在数字向量,除非na.rm是TRUE。
参数:probs
numeric vector of probabilities with values in [0,1]. (Values up to 2e-14 outside that range are accepted and moved to the nearby endpoint.)
数字矢量值[0,1]的概率。 (2e-14范围之外的接受和转移到附近的端点值。)
参数:na.rm
logical; if true, any NA and NaN's are removed from x before the quantiles are computed.
逻辑;如果属实,任何NA和NaN的x前的位数计算中删除。
参数:names
logical; if true, the result has a names attribute. Set to FALSE for speedup with many probs.
逻辑,如果属实,结果有一个names属性。设置FALSE为加速许多probs。
参数:type
an integer between 1 and 9 selecting one of the nine quantile algorithms detailed below to be used.
选择要使用下文详述的九位数的算法之一的1和9之间的整数。
参数:...
further arguments passed to or from other methods.
通过进一步的论据或其他方法。
Details
详情----------Details----------
A vector of length length(probs) is returned; if names = TRUE, it has a names attribute.
一个向量的长度length(probs)返回;如果names = TRUE,它有一个names属性。
NA and NaN values in probs are propagated to the result.
NA和NaN值probs传播的结果。
The default method works with classed objects sufficiently like numeric vectors that sort and (not needed by types 1 and 3) addition of elements and multiplication by a number work correctly. Note that as this is in a namespace, the copy of sort in base will be used, not some S4 generic of that name. Also note that that is no check on the "correctly", and so e.g. quantile can be applied to complex vectors which (apart from ties) will be ordered on their real parts.
默认的方法与足够的像数值向量类对象sort“(1型和3)除了元素和数字工作乘法正确。请注意,因为这是在一个命名空间,副本sortbase将被使用,而不是一些该名称的中S4中通用。还要注意的是,没有“正确”的支票,所以如quantile可应用于复杂的向量(除了关系)将责令其真正部分。
There is a method for the date-time classes (see "POSIXt"). Types 1 and 3 can be used for class "Date" and for ordered factors.
有一个日期时间类的方法(见"POSIXt")。可用于1型和3类"Date"“责令因素。
类型----------Types----------
quantile returns estimates of underlying distribution quantiles based on one or two order statistics from the supplied elements in x at probabilities in probs. One of the nine quantile algorithms discussed in Hyndman and Fan (1996), selected by type, is employed.
quantilexprobs的概率元素提供一个或两个顺序统计的基础底层分布分位数的回报估计。九位数海德门和风扇(1996)中讨论的算法,type选择之一,聘用。
All sample quantiles are defined as weighted averages of consecutive order statistics. Sample quantiles of type i are defined by:
所有样品位数被定义为连续顺序统计的加权平均。样品位数的类型i定义:
where 1 ≤ i ≤ 9, (j-m)/n ≤ p < (j-m+1)/n, x[j] is the jth order statistic, n is the sample size, the value of γ is a function of j = floor(np + m) and g = np + m - j, and m is a constant determined by the sample quantile type.
其中1 ≤ i ≤ 9,(j-m)/n ≤ p < (j-m+1)/n,x[j]是j阶统计,n是样本大小,γ的价值是一个函数j = floor(np + m)和g = np + m - j,m样品位数类型确定的常数。
<STRONG>Discontinuous sample quantile types 1, 2, and 3</STRONG>
间断样品<STRONG>位数类型1,2和3 </ STRONG>
For types 1, 2 and 3, Q[i](p) is a discontinuous function of p, with m = 0 when i = 1 and i = 2, and m = -1/2 when i = 3.
对于第1类,2和3,Q[i](p)是p的连续函数,m = 0当i = 1和i = 2,m = -1/2时i = 3。
Type 1 Inverse of empirical distribution function.
键入1经验分布函数的逆。
Type 2 Similar to type 1 but with averaging at discontinuities.
键入2类似,但平均在间断键入1。
Type 3 SAS definition: nearest even order statistic. γ = 0 if g = 0 and j is even,
第3类SAS的定义:最近甚至为了统计。 γ = 0如果g = 0和j甚至
<STRONG>Continuous sample quantile types 4 through 9</STRONG>
<STRONG>连续采样位数类型4到9 </ STRONG>
For types 4 through 9, Q[i](p) is a continuous function of p, with gamma = g and m given below. The sample quantiles can be obtained equivalently by linear interpolation between the points (p[k],x[k]) where x[k] is the kth order statistic. Specific expressions for p[k] are given below.
对于类型4到9,Q[i](p)是p的连续函数,gamma = g和m下面给出。采样位数可以通过线性插值得到点之间的等效(p[k],x[k])其中x[k]是k阶统计。 p[k]具体表现如下。
Type 4 m = 0. p[k] = k / n. That is, linear interpolation of the empirical cdf.
类型4m = 0。 p[k] = k / n。也就是说,线性插值的经验CDF。
Type 5 m = 1/2. p[k] = (k - 0.5) / n. That is a piecewise linear function where the knots are the values midway through the steps of the empirical cdf. This is popular amongst hydrologists.
5型m = 1/2。 p[k] = (k - 0.5) / n。这是一个分段线性函数疙瘩是通过经验CDF步骤值中途。这是流行的,其中包括水文。
Type 6 m = p. p[k] = k / (n + 1). Thus p[k] = E[F(x[k])]. This is used by Minitab and by SPSS.
第6类m = p。 p[k] = k / (n + 1)。因此p[k] = E[F(x[k])]。这是用Minitab和利用SPSS。
Type 7 m = 1-p. p[k] = (k - 1) / (n - 1). In this case, p[k] = mode[F(x[k])]. This is used by S.
7型m = 1-p。 p[k] = (k - 1) / (n - 1)。在这种情况下,p[k] = mode[F(x[k])]。这是由S.
Type 8 m = (p+1)/3. p[k] = (k - 1/3) / (n + 1/3). Then p[k] =~ median[F(x[k])]. The resulting quantile estimates are approximately median-unbiased regardless of the distribution of x.
8型m = (p+1)/3。 p[k] = (k - 1/3) / (n + 1/3)。然后p[k] =~ median[F(x[k])]。产生的分量估计约中位数持平,不管分布x。
Type 9 m = p/4 + 3/8. p[k] = (k - 3/8) / (n + 1/4). The resulting quantile estimates are approximately unbiased for the expected order statistics if x is normally distributed.
9m = p/4 + 3/8型。 p[k] = (k - 3/8) / (n + 1/4)。由此产生的分量估计大约为预期的顺序统计的公正,x如果正态分布。
Further details are provided in Hyndman and Fan (1996) who recommended type 8. The default method is type 7, as used by S and by R < 2.0.0.
海德门和建议8型的风扇(1996)中提供进一步的细节。默认的方法是7型,S和由R <2.0.0。
作者(S)----------Author(s)----------
of the version used in <font face="Courier New,Courier" color="#666666"><b>R</b></font> >= 2.0.0, Ivan Frohne and Rob J Hyndman.
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
packages, American Statistician, 50, 361–365.
参见----------See Also----------
ecdf for empirical distributions of which quantile is an inverse; boxplot.stats and fivenum for computing other versions of quartiles, etc.
ecdfquantile经验分布是逆boxplot.stats和fivenum计算四分其他版本等。
举例----------Examples----------
quantile(x <- rnorm(1001)) # Extremes & Quartiles by default[默认情况下,极端及四分]
quantile(x, probs = c(0.1, 0.5, 1, 2, 5, 10, 50, NA)/100)
### Compare different types[#比较不同类型的]
p <- c(0.1, 0.5, 1, 2, 5, 10, 50)/100
res <- matrix(as.numeric(NA), 9, 7)
for(type in 1:9) res[type, ] <- y <- quantile(x, p, type = type)
dimnames(res) <- list(1:9, names(y))
round(res, 3)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|