Reputation: 63
My objective is to remove outliers from some time series, then forecast the adjusted series. All this should happen automatically using the tso() function in the tsoutliers package. However, I am receiving errors that appear to be related to the xreg produced by the automatic outlier detection. Can someone please explain the errors and advise as to how to avoid them when using the tso() function. In both examples one data point appears to cause the error.
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)
Upvotes: 1
Views: 1606
Reputation: 1049
The value of the likelihood function turns to be non-finite in the ARIMA(0,0,0) model. Outliers in the last observations can be tricky to deal with since AO, LS and TC cannot be distinguished. In this case, it seems that adding temporary changes, TC, cause some trouble. I would recommend you including only additive outliers and level shifts (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
A level shift in the first observations does not seem reliable, so you may stick to additive outliers.
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
Notice that the chosen model in the last case is the same as for the series containing all the observations except the last one, tso(y = ts(b[1:14]))
.
Upvotes: 0