dput(df)
structure(list(Process = c("PROC050D", "PROC051D", "PROC100D",
"PROC103D", "PROC104D", "PROC106D", "PROC106D", "PROC110D", "PROC111D",
"PROC112D", "PROC113D", "PROC114D", "PROC130D", "PROC131D", "PROC132D",
"PROC154D", "PROC155D", "PROC156D", "PROC157D", "PROC158D", "PROC159D",
"PROC160D", "PROC161D", "PROC162D", "PROC163D", "PROC164D", "PROC165D",
"PROC166D", "PROC170D", "PROC171D", "PROC173D", "PROC174D", "PROC177D",
"PROC180D", "PROC181D", "PROC182D", "PROC185D", "PROC186D", "PROC187D",
"PROC190D", "PROC191D", "PROC192D", "PROC196D", "PROC197D", "PROC201D",
"PROC202D", "PROC203D", "PROC204D", "PROC205D", "PROC206D"),
Date = structure(c(15393, 15393, 15393, 15393, 15393, 15393,
15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393,
15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393,
15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393,
15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393,
15393, 15393, 15393, 15393, 15393, 15393, 15393, 15393), class = "Date"),
Duration = c(30L, 78L, 20L, 15L, 129L, 56L, 156L, 10L, 1656L,
1530L, 52L, 9L, 10L, 38L, 48L, 9L, 26L, 90L, 15L, 23L, 13L,
9L, 34L, 12L, 11L, 16L, 24L, 11L, 236L, 104L, 9L, 139L, 11L,
10L, 22L, 11L, 55L, 35L, 12L, 635L, 44L, 337L, 44L, 9L, 231L,
32L, 19L, 170L, 22L, 19L)), .Names = c("Process", "Date",
"Duration"), row.names = c(NA, 50L), class = "data.frame")
我試圖使用IQR方法從我的數據中捕獲異常值。但是當我使用這些數據時,我也會捕獲可能正常的數據。我喜歡從我的數據點中刪除季節性,然後應用異常規則。從日常時間序列數據中刪除季節性
Process列上有成千上萬個不同的進程。我只需要捕獲過程中不正常的持續時間。任何想法如何從我的數據集中刪除季節性?下面的代碼計算離羣值,但由於季節因素,離羣值可能是正常的。在計算離羣值之前,我喜歡從我的數據框中刪除季節。
library(data.table)
df<-df[, seventyFifth := quantile(Duration, .75), by = Process]
df<-df[, twentyFifth := quantile(Duration, .25), by = Process]
df<-df[, IQR := (seventyFifth-twentyFifth), by = Process]
df$diff<-df$Duration-df$seventyFifth
df<-df[, outlier := diff > 3 * IQR, by = Process]
@GSee,no。我更新了這篇文章。我想刪除或按摩數據,以便季節性不會顯示在我的異常值計算中。我需要從我的數據集中捕捉異常值,不包括季節性數據點。 – user1471980