# (S)ARIMA — Hints with Time Series

I am a beginner in time series analysis and I would like discuss a couple of numerical examples here implemented in R. I am reading some interesting books, but I also need some expert advice to get started. The time series are

ts1<-structure(c(196, 196, 178, 165, 155, 138, 131, 132, 135, 146,
160, 173, 180, 186, 180, 163, 132, 129, 134, 146, 159, 157, 161,
179, 209, 225, 228, 196, 151, 144, 145, 157, 168, 161, 162, 176,
205, 219, 219, 190, 147, 142, 146, 160, 175, 169, 171, 188, 220,
235, 236, 202, 154, 146, 145, 155, 168, 158, 156, 168, 190, 202,
204, 177, 135, 127, 125, 133, 145, 139, 143, 160, 190, 205, 200,
160, 119, 113, 118, 129, 142, 135, 133, 142, 159, 171, 177, 164,
135, 130, 130, 139, 152, 149, 152, 168, 195, 209, 211, 180, 138,
134, 139, 152, 165, 158, 157, 168, 192, 207, 219, 206, 169, 164,
161, 172, 182, 180, 182, 196, 218, 223, 229, 230, 196, 197, 200,
209, 222, 219, 207, 210, 209, 221, 234, 224, 225, 221, 235, 216,
224, 229, 229, 214, 230, 240, 243, 222, 189, 221, 217, 189, 197,
194, 195, 202, 197, 224, 204, 218, 212, 191, 217, 215, 183, 186,
191, 166, 177, 194, 180, 159, 158, 147, 166, 184, 159, 159, 187,
194, 196, 204, 213, 236, 210, 218, 251, 227, 251, 214, 245, 209,
215, 242, 196, 237, 212, 171, 206, 200, 204, 192, 185, 182, 194,
242, 199, 200, 191, 172, 179, 165, 173, 198, 214, 197, 175, 227,
197, 202, 205, 212, 216, 223, 222, 201, 217, 209, 239, 241, 251,
225, 212, 210, 241, 223, 238, 226, 242, 228, 257, 248, 264, 229,
223, 255, 251, 231, 254, 235, 246, 246, 243, 254, 256, 261, 254,
247, 249, 243, 257, 228, 272), na.action = structure(c(1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L,
69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L,
82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L,
95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L,
128L, 129L, 130L, 131L, 132L, 396L), class = "omit"), .Tsp = c(1994,
2015.83333333333, 12), class = "ts")

ts2<-structure(c(3756, 3867, 3686, 3490, 3446, 3357, 3421, 3447,3321,
3198, 3331, 3360, 3312, 3270, 3251, 3213, 2937, 3152, 3022, 2931,
2697, 2626, 2775, 3030, 3067, 3349, 3225, 3175, 3061, 3089, 3166,
3193, 3035, 2901, 2932, 2981, 3242, 3268, 3084, 2902, 2790, 2695,
2756, 2649, 2627, 2643, 2554, 2638, 2783, 2660, 2618, 2383, 2319,
2415, 2434, 2427, 2164, 2114, 2246, 2224, 2552, 2390, 2213, 2130,
2274, 2140, 2317, 2191, 2086, 2112, 2134, 2153, 2401, 2450, 2273,
2154, 2140, 2201, 2156, 2078, 2110, 2101, 2075, 2043, 2305, 2266,
2227, 2134, 2002, 2008, 1945, 2110, 2045, 2017, 2106, 1913, 2068,
2209, 2025, 2033, 1892, 1934, 1914, 1818, 1808,
1851, 1939),na.action   = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L,
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L,
81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L,
94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L,
128L, 129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L,
139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L,
150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L,
161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L,
172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L,
183L, 184L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L,
194L, 195L, 196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L,
205L, 206L, 207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L,
216L, 217L, 218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L,
227L, 228L, 229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L,
238L, 239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L,
249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L,
260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L,
271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L,
282L, 283L, 284L, 285L, 286L, 287L, 288L, 396L),
class = "omit"),.Tsp   = c(2007,
2015.83333333333, 12), class = "ts")

I would prefer to avoid the use of auto.arima from the (excellent) forecast package, or at least not to use it as a black box. I started looking at the plots of the first differences

plot(diff(ts1))

plot(diff(ts2))

which should remove any trend. I also looked at the decomposition:

plot(decompose(ts1))

plot(decompose(ts2))

I would tend to conclude that in both cases there is a seasonality in the data. However, diff(ts2) appears (to me, by eye) to yield a stationary process with constant variance, whereas diff(ts1) does not seem to have a constant variance. I tried diff(diff(ts1)) and diff(log(ts2)), but I am puzzled by what I see. If I look at

acf(ts1)

acf(ts2)

I see that in both cases the autocorrelation decays slowly and when I resort to

acf(diff(ts1))

acf(diff(ts2))

I see some spikes which I do not know how to interpret. Essentially, I am at a loss about how to link these findings with a SARIMA model. Any suggestion on either/both time series is very appreciated!

• Tip: count at which lags you have significant spikes, compare to frequency of the series, compare to theoretical ACFs and PACFs (at both non-seasonal and seasonal frequencies), then specify ARIMA model(s). Iterate until residuals are white noise, using the residual ACFs to identify additional terms. Going beyond this standard approach (which is Box-Jenkins), employ an outlier and break detection method of your choice. Auto ARIMA function employs a different methodology - i.e. not the subjective Box-Jenkins / interpretation of ACF/PACF. – Graeme Walsh Jan 17 '16 at 22:47
• Unwarranted differencing can induce structure in the differenced series. Identifying level shifts can render a series to be free of trend.Seasonal Pulses rather than SARIMA is often found in series like yours.Error variance changes or parameter changes over time are often needed to render an error process free of structure.Untreated pulses can distort both the correlative structure of the original series and/or the correlative structure of the errors.These need to be considered/tested which is why simplistic AIC/BIC procedures (auto.arima) fail in practice thus the need for "complications" – IrishStat Jan 18 '16 at 3:22