箱线图异常值去除方法
Method of Outlier Removal for Boxplots
在R中,boxplot()用什么方法去异常值?换句话说,是什么决定了给定值是否异常值?
请注意,此问题不是询问如何删除异常值。
编辑:为什么这个问题被否决了?请提出意见。我遇到的任何文档中都没有异常值去除方法。
tl;dr 离群点是指距中位数 大约 两倍四分位数范围之外的点(在对称情况下)。更准确地说,超出等于 'hinges'(大约第 1 和 3d 四分位数)+/- 1.5 倍四分位数范围的截止点的点。
R 的 boxplot()
函数实际上根本 删除 异常值;数据集中的所有观察结果都显示在图中(除非 outline
参数是 FALSE
)。有关将点绘制为异常值(即,作为晶须之外的单个点)的计算信息隐含地包含在 range
参数的描述中:
range [default 1.5]: this determines how far the plot whiskers extend out from the
box. If ‘range’ is positive, the whiskers extend to the most
extreme data point which is no more than ‘range’ times the
interquartile range from the box. A value of zero causes the
whiskers to extend to the data extremes.
这需要进一步解构:"from the box" 是什么意思?要弄清楚这一点,我们需要查看 ?boxplot.stats
:
的 Details
The two ‘hinges’ are versions of the first and third quartile,
i.e., close to ‘quantile(x, c(1,3)/4)' [... see ?boxplot.stats
for slightly more detail ...]
所有复杂性/"approximately equal to the quartile" 语言的原因是箱线图的开发人员希望确保铰链和胡须始终绘制在代表数据集中实际观察的点上(而四分位数可以位于观测点之间,例如,在具有奇数个观测值的数据集的情况下)。
示例:
set.seed(101)
z <- rnorm(100000)
boxplot(z)
hinges <- qnorm(c(0.25,0.75))
IQR <- diff(qnorm(c(0.25,0.75)))
abline(h=hinges,lty=2,col=4) ## hinges ~ quartiles
abline(h=hinges+c(-1,1)*1.5*IQR,col=2)
## in this case hinges = +/- IQR/2, so whiskers ~ +/- 2*IQR
abline(h=c(-1,1)*IQR*2,lty=2,col="purple")
在R中,boxplot()用什么方法去异常值?换句话说,是什么决定了给定值是否异常值?
请注意,此问题不是询问如何删除异常值。
编辑:为什么这个问题被否决了?请提出意见。我遇到的任何文档中都没有异常值去除方法。
tl;dr 离群点是指距中位数 大约 两倍四分位数范围之外的点(在对称情况下)。更准确地说,超出等于 'hinges'(大约第 1 和 3d 四分位数)+/- 1.5 倍四分位数范围的截止点的点。
R 的 boxplot()
函数实际上根本 删除 异常值;数据集中的所有观察结果都显示在图中(除非 outline
参数是 FALSE
)。有关将点绘制为异常值(即,作为晶须之外的单个点)的计算信息隐含地包含在 range
参数的描述中:
range [default 1.5]: this determines how far the plot whiskers extend out from the box. If ‘range’ is positive, the whiskers extend to the most extreme data point which is no more than ‘range’ times the interquartile range from the box. A value of zero causes the whiskers to extend to the data extremes.
这需要进一步解构:"from the box" 是什么意思?要弄清楚这一点,我们需要查看 ?boxplot.stats
:
The two ‘hinges’ are versions of the first and third quartile, i.e., close to ‘quantile(x, c(1,3)/4)' [... see
?boxplot.stats
for slightly more detail ...]
所有复杂性/"approximately equal to the quartile" 语言的原因是箱线图的开发人员希望确保铰链和胡须始终绘制在代表数据集中实际观察的点上(而四分位数可以位于观测点之间,例如,在具有奇数个观测值的数据集的情况下)。
示例:
set.seed(101)
z <- rnorm(100000)
boxplot(z)
hinges <- qnorm(c(0.25,0.75))
IQR <- diff(qnorm(c(0.25,0.75)))
abline(h=hinges,lty=2,col=4) ## hinges ~ quartiles
abline(h=hinges+c(-1,1)*1.5*IQR,col=2)
## in this case hinges = +/- IQR/2, so whiskers ~ +/- 2*IQR
abline(h=c(-1,1)*IQR*2,lty=2,col="purple")