AnomalyDetection icon indicating copy to clipboard operation
AnomalyDetection copied to clipboard

Removing leading NA's and subtracting the median

Open asstergi opened this issue 10 years ago • 2 comments

Hi guys,

I came across the package which looks great. I have the following 2 questions on the code in 'detect_anoms.R':

  1. In line 51, any leading NA's are replaced by 1. Shouldn't it be 0 (zero)?

  2. In line 37, the median is subtracted from the data. In lines 72-80, the median is subtracted again. Is this correct?

I don't know the details of 'S-H-ESD' algorithm, so excuse me if I'm wrong!

Thanks!

asstergi avatar Jan 15 '15 15:01 asstergi

Thanks for checking out the package.

Line 37: We use a modification to STL which removes the median and the STL seasonal component from the original data. This is how we derive the residual used in the ESD section.

Lines 72-80: This is how we calculate Grubbs' test statistic. We replaced mean and standard deviation with median and median absolute deviation.

Line 51 was done a while back, so we'll go back and look at it again.

owenvallis avatar Jan 16 '15 23:01 owenvallis

@asstergi The 1s were being inserted in order to avoid plotting errors when we log transformed the y axis. However, @ahardjasa submitted a patch that now allows us to support the log transform with 0s in the data.

I updated the code to reflect this, and will submit a patch soon.

Cheers,

owenvallis avatar Jan 25 '15 23:01 owenvallis