Question about rmoutliers () function
20 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Adam Danz
2020-4-15
编辑:Adam Danz
2020-4-15
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 个评论
Adam Danz
2020-4-15
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!