tsoutliers中的错误:由optim提供的非有限值

时间:2015-04-14 19:08:35

标签: r

我的目标是从某些时间序列中删除异常值,然后预测调整后的系列。所有这些都应该使用tsoutliers包中的tso()函数自动发生。但是,我收到的错误似乎与自动异常检测产生的xreg有关。有人可以解释错误,并建议在使用tso()函数时如何避免它们。在两个示例中,一个数据点似乎导致错误。

library(tsoutliers)
a <- c(0.0006803534,0.0008086988,0.0010701362,0.0028385699,0.0009526675,0.0011191115,0.0008059368,0.0008332677,
       0.0012494373, 0.0005474622, 0.0012861884, 0.0013055677, 0.0026272806, 0.0009219052, 0.0012265391, 0.0011404776,
       0.0012051921, 0.0011466459, 0.0009422736, 0.0011882251, 0.0016061762, 0.0017002298, 0.0010543345, 0.0014305019,
       0.0009765448, 0.0016551414, 0.0015071106, 0.0009334908, 0.0011783813, 0.0025809926, 0.0024930899, 0.0021169154,
       0.0014262570, 0.0017019384, 0.0014512346, 0.0012913704, 0.0020135812, 0.0025037096, 0.0030477309, 0.0014514058,
       0.0016321700, 0.0008587965, 0.0014433053, 0.0009057649, 0.0007649348, 0.0010708278, 0.0022047009, 0.0019205611,
       0.0007907089, 0.0013871365, 0.0008116141, 0.0013734145, 0.0012905443, 0.0008450942, 0.0011113448, 0.0020288530,
       0.0016559151, 0.0010888568, 0.0010158067, 0.0010757180, 0.0022200539)
x <- tso(y = ts(a[1:61])) #no suitable ARIMA model found
x <- tso(y = ts(a[1:60])) #success 
print(x)

b <- c(0.0010396288, 0.0010933381, 0.0008588906, 0.0009726299, 0.0012475050, 0.0014702853, 0.0016084776, 0.0014296589,
       0.0022134069, 0.0012096325, 0.0016529216, 0.0016144349, 0.0021092875, 0.0024984858, 0.0168729766)

x <- tso(y = ts(b[1:15])) #non-finite value supplied by optim
x <- tso(y = ts(b[1:14])) #success 
print(x)

1 个答案:

答案 0 :(得分:0)

似然函数的值在ARIMA(0,0,0)模型中变为非有限。由于无法区分AO,LS和TC,因此上次观察中的异常值可能很难处理。在这种情况下,似乎添加临时更改TC会导致一些麻烦。我建议你只包括附加异常值和电平转换(AO,LS)。

x <- tso(y = ts(b[1:15]), type=c("AO","LS"))
# ARIMA(0,0,0) with zero mean     
# Coefficients:
#          LS1    AO15
#       0.0015  0.0154
# s.e.  0.0003  0.0005
# sigma^2 estimated as 2.097e-07:  log likelihood=94.05
# AIC=-182.09   AICc=-179.91   BIC=-179.97
# Outliers:
#   type ind time  coefhat  tstat
# 1   LS   1    1 0.001501  5.254
# 2   AO  15   15 0.015372 28.478

第一次观察中的水平偏移似乎不可靠,因此您可能会坚持使用附加异常值。

x <- tso(y = ts(b[1:15]), type="AO")
# ARIMA(1,1,0)                    
# Coefficients:
#           ar1    AO15
#       -0.4659  0.0146
# s.e.   0.2295  0.0005
# sigma^2 estimated as 1.348e-07:  log likelihood=90.75
# AIC=-175.5   AICc=-173.1   BIC=-173.58
# 
# Outliers:
#   type ind time coefhat tstat
# 1   AO  15   15 0.01456 31.11

请注意,最后一种情况下所选模型与包含除最后一项tso(y = ts(b[1:14]))之外的所有观察的系列相同。