003箱线图,欢迎交流指正!
关于箱线图的上边缘、下边缘和异常值问题的探讨,
先说说wiki上的解释,箱线图的箱子上下边缘及中线的定义分别是Q1、Q3及中位数,但是线型的上下边缘则有几种不同的画法:
1.上下边缘分别是数据的最小值和最大值(这样就不存在outlier了);
2.上边缘的取值等于在区间[Q3,Q3+1.5*IQR]内找到的最大值,下边缘的取值等于在[Q1-1.5*IQR,Q1]内找到的最小值(IQR = Q3 − Q1,四分位差,在上下边缘之外的均为outlier,这样很好的体现了数据分布的情况);
3.上下边缘等于均值+/-1倍标准差;
4.上下边缘分别是9%百分位点和91%百分位点的值;
5.2%和98%分为点的值。
http://en.wikipedia.org/wiki/Boxplot
那么R画出的箱线图是哪一种呢?
其实wiki在解释第二种箱线图的时候就引用了R手册的相关内容,那我们再来看一看R手册里对boxplot的说法:
R:BOXPLOT
## Default S3 method:
boxplot(x, ..., range = 1.5, width = NULL, varwidth = FALSE,
notch = FALSE, outline = TRUE, names, plot = TRUE,
border = par("fg"), col = NULL, log = "",
pars = list(boxwex = 0.8, staplewex = 0.5, outwex = 0.5),
horizontal = FALSE, add = FALSE, at = NULL)
可以看到,range这个参数的默认值是1.5,也就是1.5倍的IQR,关于range参数的Arugments原文是:
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.
http://stat.ethz.ch/R-manual/R-d ... s/html/boxplot.html
依稀记得以前统计老师讲过,但是记不清了,所以又查了一下。希望有所帮助!