calculating the outliers in R

前端 未结 5 1645
慢半拍i
慢半拍i 2020-12-05 01:21

I have a data frame like this:

x

Team 01/01/2012  01/02/2012  01/03/2012  01/01/2012 01/04/2012 SD Mean
A     100         50           40        NA           


        
5条回答
  •  心在旅途
    2020-12-05 02:02

    Get your IQR (Interquartile range) and lower/upper quartile using:

    lowerq = quantile(data)[2]
    upperq = quantile(data)[4]
    iqr = upperq - lowerq #Or use IQR(data)
    

    Compute the bounds for a mild outlier:

    mild.threshold.upper = (iqr * 1.5) + upperq
    mild.threshold.lower = lowerq - (iqr * 1.5)
    

    Any data point outside (> mild.threshold.upper or < mild.threshold.lower) these values is a mild outlier

    To detect extreme outliers do the same, but multiply by 3 instead:

    extreme.threshold.upper = (iqr * 3) + upperq
    extreme.threshold.lower = lowerq - (iqr * 3)
    

    Any data point outside (> extreme.threshold.upper or < extreme.threshold.lower) these values is an extreme outlier

    Hope this helps

    edit: was accessing 50%, not 75%

提交回复
热议问题