Question about rmoutliers () function
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
BN
el 15 de Abr. de 2020
Comentada: Adam Danz
el 15 de Abr. de 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
0 comentarios
Respuesta aceptada
Adam Danz
el 15 de Abr. de 2020
Editada: Adam Danz
el 15 de Abr. de 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 comentarios
Adam Danz
el 15 de Abr. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Preprocessing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!