1
$\begingroup$

I am using the R implementation of robust PCA here for anomaly detection.

I have a vector of time series data, and a vector of dates. The algorithm works fine when the length of the vector is a multiple of the frequency of the seasonality - as stated in the documentation:

If X is a vector it will be cast to a matrix of dimension 
 frequency by length(X)/frequency

However, my seasonality is very long (yearly), while my data is collected daily. If I set the frequency to 365, I get the following error (as my vector's length is not divisible by 365):

    ggplot_AnomalyDetection.rpca(AnomalyDetection.rpca(df$cnt, 
       frequency=365, dates=df$dt)) + 
       ggplot2::theme_grey(base_size = 25)
    Error in data.frame(X.transform = (as.vector(i$rpca$X)) * 
     i$sd + i$mean,  : 
      arguments imply differing number of rows: 3650, 3384
    In addition: Warning message:
    In matrix((j - j.global.mean)/j.global.sd, nrow = frequency) 
  :
    data length [3384] is not a sub-multiple or multiple of the 
 number of rows [365]

Do I have to trim values from my vector so that it's divisible by 365 (and wait a whole year to get enough data to run the algorithm for the past year) or can I fill in dummy values?

$\endgroup$

1 Answer 1

0
$\begingroup$

Indeed the periodicity requirement in calling this function is a bit restrictive. The following link mentions that you can specify a periodicity of 1 in such a case as a work around.

That way your data would be divisible by the frequency and the function should work.

With regards to whether this is statistically sound/ideal, I wouldn't comment on that.

https://github.com/Netflix/Surus/issues/7

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.