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?