4
$\begingroup$

I am using the excellent tsoutliers R package to detect outliers (additive outliers, temporary changes etc.), but the cval parameter in the tso function is providing me with inconsistent, or at least counter-intuitive results. I was under the impression that a lower value for cval would include more outliers (but possibly also irrelevant ones), but this doesn't always seem the case. For example, using the following data and logic, I get the following output, which is nearly exactly what I was after:

data <- c(121.54, 119.79, 119.18, 118.56, 104, 65.52, 66, 119.18,
123.42, 119.18, 118.56, 99, 61.74, 67.98, 119.18, 123.42, 120.36,
115.14, 98, 62.37, 67.98, 122.72, 121, 116.82, 117.42, 98, 83.538,
103.096, 165.332, 185.6955, 145.848, 129.162, 101, 62.37, 64.68,
115.64, 124.63, 115.64, 118.56, 102, 62.37, 67.32, 115.64, 122.21,
121.54, 114, 103, 62.37, 65.34, 118, 122.21, 119.18, 114, 99, 65.52,
65.34, 118, 122.21, 115.64, 117.42, 73.5, 40.131, 41.184, 79.4376,
95.832, 105.138, 117.42, 100, 63, 66.66, 122.72, 123.42, 116.82, 114,
98, 61.74, 64.68, 116.82, 121, 188.152, 114, 99, 61.74, 66, 122.72,
118.58, 115.64, 112.86, 101, 63.63, 66.66)

# simple tso function
volume <- ts(data, start = c(2016,1,1), frequency = 7)
data.ts.outliers <- tso(volume, types = c("AO", "LS", "TC"), cval = 3.0)
data.ts.outliers
plot(data.ts.outliers)

Expected results, cval = 3.0

However, using cval = 2.9, as well as most other values for cval above or below 3.0, I get the following results, which is missing some key outliers:

Missing outliers, cval = 2.9

As I want to use this package without manual review for each timeseries, Ideally I'd be able to use a slightly lower cval value to ensure I am capturing most outliers, but the inconsistency that I am seeing is not allowing for this. Anything I am missing?

$\endgroup$
0
$\begingroup$

Have you checked out the TSOUTLIERS documentation? If no value is specified for argument cval a default value based on the sample size is used. Let n be the number of observations. If n ≤ 50 then cval is set equal to 3.0; If n ≥ 450 then cval is set equal to 4.0; otherwise cval is set equal to 3 + 0.0025 ∗ (n − 50).

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.