title: Multivariate Outlier Detection using R with probability
body: <p>I have been searching everywhere for the best method to identify the multivariate outliers using R but I don't think I have found any believable approach yet. </p>
  
  <p>We can take the iris data as an example as my data also contains multiple fields </p>
  
  <pre><code>data(iris)
  df &lt;- iris[, 1:4] #only taking the four numeric fields
  </code></pre>
  
  <p>Firstly, I am using <strong>Mahalanobis distance</strong> from the library MVN</p>
  
  <pre><code>library(MVN)
  result &lt;- mvOutlier(df, qqplot = TRUE, method = "quan") #non-adjusted
  result &lt;- mvOutlier(df, qqplot = TRUE, method = "adj.quan") #adjusted Mahalonobis distance
  </code></pre>
  
  <p>Both resulted in a large number of outliers (50 out of 150 for non-adjusted and 49/150 for adjusted), which I think needs more refinement. I unfortunately can't seem to find a variable in the mvOutlier method to set the threshold (says increasing the probability of a point being an outlier, so that we have a smaller number)</p>
  
  <p>Secondly, I used <strong>outliers library</strong>. This is to find <em>univariate</em> outliers. So that, my plan is to find the outliers on each dimension of the data and those points being outliers on all the dimensions are regarded as outliers of the dataset. </p>
  
  <pre><code>library(outliers)
  result &lt;- scores(df, type="t", prob=0.95) #t test, probability is 0.95
  result &lt;- subset(result, result$Sepal.Length == T &amp; result$Sepal.Width == T &amp; result$Petal.Length == T &amp; result$Petal.Width == T)
  </code></pre>
  
  <p>For this we can set the probability, but I don't think it can replace the multivariate outlier detection.</p>
  
  <p>Some other approaches that I tried</p>
  
  <ul>
  <li>library(mvoutlier): this only shows the plot. It is hard to
  automatically find outliers. And I don't know how to add the
  probability into this </li>
  <li>cook's distance (<a href="https://stackoverflow.com/questions/8375311/multivariate-robust-outlier-detection-using-r">link</a>): a man said that he    used cook's
  distance but I don't think there is any strong academic    proof to
  prove that this is ok.</li>
  </ul>