我一直在尝试使用 Twitter 的AnomalyDetection包来识别可疑的低数据,但我无法使用选项“direction = 'neg'”。当我运行以下示例(取自此处)时,我只得到一个具有 0 个观察值的 data.frame,并且该图的结果为 NULL:
devtools::install_github("twitter/AnomalyDetection") # install twitter's AnomalyDetection
library(AnomalyDetection)
library(fpp) # for 'ausair' data
library(lubridate)
myTS <- ausair # initialise data
myPeriod <- "year" # set the period
ymth <- paste(start(myTS), collapse="/")
startDate <- as.Date(paste(ymth, "1", sep="/"), format="%Y/%m/%d") # start date
eymth <- paste(end(myTS), collapse="/")
endDate <- as.Date(paste(eymth, "1", sep="/"), format="%Y/%m/%d") # end date
Dates <- seq.Date(startDate, endDate, by=myPeriod) # create the dates
Dates <- ymd(Dates) # convert to POSIXct
Dates <- as.POSIXct(Dates)
myData <- data.frame(Dates, myTS) # cast as a data.frame
AnomalyDetectionTs(myData, max_anoms = 0.2, direction='pos', plot=TRUE) # this works!
AnomalyDetectionTs(myData, max_anoms = 0.2, direction='neg', plot=TRUE) # this doesn't
有什么方法可以使用“direction = 'neg'”选项吗?