chromanna
chromanna

Reputation: 124

Why does locate.outliers() detect more outliers than tso() in the tsoutliers package?

I am working with the tsoutliers package in R for outlier detection in time series data. Both functions, locate.outliers() and tso(), are used for detecting outliers, but I am observing different results (means table of detected outliers) between the two functions, even though the inputs appear to be the same.

Here is the code I used:

# Using locate.outliers()
m_opt <- Arima(x, order = c(8, 1, 0),
               seasonal = list(order = c(1, 1, 1), period = 7),
               xreg = fourier(x, K = 3)) 
resid <- residuals(m_opt) # residuals
pars <- coefs2poly(m_opt) # collapses the polynomials of an ARIMA model
outliers <- locate.outliers(resid, pars, types = c("TC", "AO", "LS"), cval = 3.77)
print(outliers) # result

# Using tso()
tso_opt <- tso(x, types = c("TC", "AO", "LS"), xreg = fourier(x, K = 3), 
               tsmethod = "arima", 
               args.tsmethod = list(order = c(8, 1, 0),
                                    seasonal = list(order = c(1, 1, 1), period = 7)), 
               cval = 3.77)
print(tso_opt$outliers) # result

The results from locate.outliers() include more detected outliers compared to tso().

I would like to understand:

  1. Why does locate.outliers() detect more outliers than tso() in this scenario?
  2. Are there any internal differences in how these two functions handle residuals, critical values (cval), or outlier types? I've checked and the resulting ARIMA model and cval is the same in the output.
  3. What adjustments (if any) should I make to align the outputs of the two functions?

Upvotes: 0

Views: 39

Answers (0)

Related Questions