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!