Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the outlier rule in a boxplot

Tags:

r

boxplot

I have constructed some box-plots in R and have several outliers. I know that the default criteria to set outlier limits are:

  • Q3 + 1.5*IQR
  • Q1 - 1.5* IQR

However, I would like outliers classified as values that fall outside of the boundaries:

  • Q3 + 3*IQR
  • Q1 - 3* IQR

Is it possible to set this in R?

like image 305
ilaria Avatar asked Feb 14 '11 16:02

ilaria


People also ask

How do you set outliers in a box plot?

When reviewing a box plot, an outlier is defined as a data point that is located outside the whiskers of the box plot. For example, outside 1.5 times the interquartile range above the upper quartile and below the lower quartile (Q1 - 1.5 * IQR or Q3 + 1.5 * IQR).

How does an outlier affect a box plot?

The outliers affect the mean, median, and other percentiles. Because extreme points are highlighted in a box plot, you can easily identify the data points for investigation. You may find that the outliers are errors in your data or you may find that they are unusual for some other reason.

How do you remove outliers from a boxplot?

We can remove outliers in R by setting the outlier. shape argument to NA. In addition, the coord_cartesian() function will be used to reject all outliers that exceed or below a given quartile. The y-axis of ggplot2 is not automatically adjusted.

Do outliers skew a boxplot?

If there are numerous outliers to one side or the other of the box, or the median line does not evenly divide the box, then the population distribution from which the data were sampled may be skewed.


1 Answers

From ?boxplot

range: 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.

So set range=3

like image 119
Ben Bolker Avatar answered Oct 01 '22 06:10

Ben Bolker