Effacer les filtres
Effacer les filtres

Question about rmoutliers () function

19 vues (au cours des 30 derniers jours)
BN
BN le 15 Avr 2020
Commenté : Adam Danz le 15 Avr 2020
Hello,
I wanted to remove outliers from my data when outliers defined as values greater than quartile 3+1.5IQR (the interquartile range) or smaller than quartile 1-1.5IQR.
Although the 'quartiles' method in rmoutliers function defined outliers as elements more than 1.5 interquartile ranges above the upper quartile or below the lower quartile, However, it can be edited using a threshold.
B = rmoutliers(A, 'quartiles', threshold);
For the threshold, in the documentation, it was said that: the detection factor replaces the number of interquartile ranges, which is 1.5 by default.
Now my question is how I can define outliers as values greater than quartile 3+1.5IQR (the interquartile range) or smaller than quartile 1-1.5IQR using this method and its threshold?
Thank you in advance

Réponse acceptée

Adam Danz
Adam Danz le 15 Avr 2020
Modifié(e) : Adam Danz le 15 Avr 2020
Outliers using the quartile method are usually identified as values greater than Q3+1.5*IQR or less than Q1-1.5*IQR where IQR is the interquartile range, Q1 and Q3 are the 25th and 75th percentiles.
What's the logic behind adding 3 to the upper range and adding 1 plus flipping the sign of the lower range? I don't think this is what you want to do.
Nevertheless, you can compute the outliers directly without using rmoutliers by using these simple steps.
1) Compute the interquartile range.
iqrng = iqr(data);
2) Compute Q1 and Q3
Q1Q3 = prctile(data, [25,75]);
3) Create logical array identifying outliers
isOut = data > Q1Q3(2) + 3+1.5*iqrng | data < Q1Q3(1) - 1-1.5*iqrng
% * ^^^ * ^^^^^ ???????
*I highly doubt this is how you want to define the outliers. I can't imagine how it would be useful.
To remove the outliers,
data(isOut) = [];
% or
data(isOut) = NaN;
  2 commentaires
BN
BN le 15 Avr 2020
Dear Adam Danz,
Thank you so much, It was really helpful. So if I want to define outliers as values greater than Q3+1.5*IQR or less than Q1-1.5*IQR is it enough to just use this?
B = rmoutliers(A, 'quartiles')
Thanks again
Adam Danz
Adam Danz le 15 Avr 2020
To answer that, check out the "method" section of the rmoutliers document. It describes what the quartiles method is doing. This link should take you directly there. Q1 and Q3 are merely the 25th and 75th percentiles.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by