5
$\begingroup$

I have been given a set of data points $(x_i,y_i)$. I have to plot a scatter plot and determine if there are any outliers. But I haven't been taught a method to measure which data point is an outlier and which is not. So how can I do it for example in Sage or R? I found by Google that there is at least two tests to do that, Dixon's and Grubbs's test, so which one should I learn in this problem?

x = c(1,34,6,47,10,49,23,32,12,16,29,49,28,8,57,9,31,10,21,26,31,52,21,8,18,5,18, 
     26,27,26,32,2,59,58,19,14,16,9,23,28,34,70,69,54,39,9,21,54,26) 
y = c(47,76,33,78,62,78,33,64,83,67,61,85,46,53,55,71,59,41,82,56,39,89,31,43,29,55, 
     81,82,82,85,59,74,80,88,29,58,71,60,86,91,72,89,80,84,54,71,75,84,79)
$\endgroup$
7
  • $\begingroup$ post some data and you'll get interesting answers. $\endgroup$
    – user603
    Mar 25, 2013 at 11:27
  • $\begingroup$ possible duplicate of Is there a simple way of detecting outliers? - if the responses there, or here or here (since you describe the data as $x,y$ pairs), don't answer your question, please be more specific. $\endgroup$
    – Macro
    Mar 25, 2013 at 13:45
  • $\begingroup$ This question appears to be a special case of the situation addressed in the question on identifying multivariate outliers, where a large number of possible solutions are proposed. (However, the two questions are not quite duplicates in my mind, because bivariate data may lend themselves to special techniques that do not generalize to higher dimensions.) $\endgroup$
    – whuber
    Mar 25, 2013 at 13:46
  • $\begingroup$ @whuber/@gung: as I tried to show, when there are just two variables, one can do things that wouldn't work in higher dimensions. $\endgroup$
    – user603
    Mar 25, 2013 at 16:17
  • $\begingroup$ Outliers are really only outliers with respect to some model (even if the model is implicit); points that would be highly unusual under one model are just typical points under another; if you specify some bivariate model it will help you identify the points that don't correspond to it (are highly unlikely, given the model). $\endgroup$
    – Glen_b
    Mar 25, 2013 at 22:59

1 Answer 1

4
$\begingroup$

Here is how I would approach this. Your problem is bivariate. I would use a bagplot (1), which is a bivariate generalization of the boxplot (and so more of a visual exploratory tool).

In R the code to do this is:

library(aplpack)
bagplot(cbind(x,y),pch=16,cex=2)

yielding the plot below:

bagplot

You can read this plot as you would read a boxplot: the orange central region is the bivariate median, the dark blue region 'the bag' is the bivariate IQR (it contains the 50% most central points) and the light region 'the fence' contains the points that are further away (but not enough that they would be considered outliers.)

There are no data points outside the fence so no clear outliers as far as the bagplot is concerned.

(1) P. J. Rousseeuw, I. Ruts, J. W. Tukey (1999): The bagplot: a bivariate boxplot, The American Statistician, vol. 53, no. 4, 382–387

$\endgroup$
3
  • $\begingroup$ Looks good but I don't know how to install that 'aplpack' to my computer (sage 5.8, r-base 2.15.1-5ubuntu1). $\endgroup$
    – guest
    Mar 25, 2013 at 13:37
  • $\begingroup$ try method 2 here $\endgroup$
    – user603
    Mar 25, 2013 at 13:53
  • $\begingroup$ One question, how can you label cases in the bagplot? $\endgroup$ Nov 7, 2019 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.