# time series decomposition - remove seasonality

I have some time series data and I apply the decompose function in R to obtain the following output.

I remove the seasonality by running the following: orig - decomp$seasonal My question is, what data should I take away from this plot? Say I have a multivariate time series problem. Say I am trying to predict Passenger demand at airport X, but I also use as input the time series passenger demand from airport Y and Z. So in order to predict X I feed in Y and Z time series also. Each airports demand has a seasonal pattern which I need to correct for. I should decompose the seasonality from all X, Y, Z airports and then in order to predict X I should give as inputs the removed seasonality from Y and Z? or should I give the model all of the decomposed components - seasonality, trend and random... Second after removing the seasonality in the plot the random part still (to me) seems to have some "information" or seasonality… That is, it doesn't look completely "random". What can I do here? Data <- structure(c(47.9917001781891, 47.9261938741777, 47.8606875701671, 47.7951812661564, 47.7296749621457, 47.664168658135, 47.5986623541244, 47.5331560501137, 47.467649746103, 47.4021434420923, 47.3366371380817, 47.271130834071, 47.2056245300603, 47.1401182260496, 47.0746119220389, 47.0091056180283, 46.9435993140176, 46.8780930100069, 48, 21, 159, 179, 75, 29, 34, 38, 46, 101, 116, 9, 7, 71, 115, 123, 86, 10, 27, 73, 42, 21, 56, 30, 38, 24, 35, 65, 100, 14, 51, 21, 15, 43, 19, 19, 8, 24, 44, 34, 12, 23, 33, 27, 74, 36, 30, 16, 20, 38, 31, 43, 28, 45, 21, 97, 77, 68, 69, 62, 47, 27, 52, 71, 22, 17, 10, 16, 29, 39, 9, 7, 8, 15, 7, 11, 22, 26, 14, 24, 21, 13, 14, 18, 23, 41, 32, 27, 18, 14, 42, 53, 32, 15, 38, 34, 49, 52, 30, 21, 15, 22, 7, 9, 14, 13, 13, 22, 19, 11, 9, 11, 26, 9, 17, 14, 8, 12, 28, 22, 22, 35, 47, 35, 13, 10, 8, 8, 20, 18, 18, 15, 24, 23, 27, 11, 29, 21, 14, 12, 12, 20, 17, 11, 20, 19, 31, 21, 36, 35, 34, 10, 10, 34, 35, 52, 46, 30, 16, 14, 21, 18, 41, 35, 43, 11, 31, 24, 52, 31, 61, 39, 55, 29, 18, 23, 12, 35, 45, 51, 46, 54, 25, 15, 21, 25, 10, 8, 19, 47, 24, 26, 35, 41, 15, 33, 18, 15, 18, 43, 40, 40, 22, 22.7180322515486, 21.3603199781131, 20.0026077046776, 18.6448954312422, 17.2871831578067, 15.9294708843712, 14.5717586109357, 12, 19, 24, 53, 41, 17, 20, 16, 64, 63, 20, 24, 15, 24, 58, 19, 24, 37, 61, 57, 33, 8, 8, 38, 74, 56, 62, 55, 63, 94, 23, 29, 17, 39, 37, 61, 61, 42, 11, 15, 30, 34, 55, 61, 55, 87, 70, 35, 12, 67, 90, 36, 53, 29, 14, 53, 18, 40, 57, 64, 47, 18, 95, 115, 141, 144, 138, 102, 56, 89.4059169426189, 106, 188, 206, 110, 14, 8, 18, 110, 152, 147, 149, 105, 25, 12, 7, 17, 58, 158, 87, 28, 15, 120, 25, 57, 93, 15, 9, 25, 133, 129, 114, 90, 60, 101, 103, 59, 23, 42, 39, 72, 60.1559708435794, 53.4295208592592, 46.703070874939, 29, 108, 109, 111, 155, 192, 109, 47, 101, 182, 142, 37, 57, 79, 47, 35, 28, 55, 81, 174, 188, 175, 145, 66, 36, 81, 100, 28, 62, 27, 32, 33, 32, 37, 19, 176, 218, 205, 153, 119, 124, 194, 167, 123, 41, 41, 42, 123, 124, 134, 72, 27, 21, 40, 73, 82, 192, 165, 166, 122, 135, 177, 189, 150, 154, 171, 68, 37, 20, 27, 26, 16, 48, 33, 16, 19, 12, 108, 117, 112, 80, 21, 21, 30, 32, 54, 44, 61, 50, 48, 23, 31, 66, 66, 22, 17, 28, 12, 14, 48, 65, 47, 89, 31, 17, 36, 40, 44, 24, 6, 11, 12, 13, 71, 99, 69, 45, 49, 61, 56, 103, 102, 34, 20, 24, 35, 72, 56, 26, 12, 10, 21, 13, 15, 9, 9, 14, 12, 20, 19, 29, 24, 20, 13, 13, 19, 21, 35, 41, 15, 13, 31, 50, 28, 31, 39, 23, 23, 16, 29, 23, 31, 26, 43, 16, 18, 22, 46, 47, 27, 20, 20, 8, 17, 25, 21, 21, 22, 21, 15, 18, 20, 21, 28, 17, 30, 17, 23, 28, 42, 28, 21, 8, 39, 29, 26, 18, 22, 34, 42, 34, 19, 33, 21, 27, 18, 32, 18, 12, 22, 15, 20, 20, 19.1838237454693, 18.5300050966337, 17.876186447798, 17.2223677989624, 16, 18, 34, 19, 5, 17, 11, 17, 13.8418813149188, 11.6783309466219, 9, 10, 13, 27, 28, 20, 18, 10, 9, 17, 10, 31, 24, 29, 13, 7, 18, 26, 26, 38, 25, 13, 14, 36, 59, 28, 44, 27, 16, 10, 9, 18, 21, 31, 8, 16, 13, 44, 30, 18, 38, 12, 14, 11, 54, 56, 83, 119, 62, 37, 12, 75, 85, 42, 85, 33, 24, 8, 61, 64, 107, 103, 46, 12, 50, 70, 86, 88, 65, 77, 17, 25, 83, 108, 121, 82, 49, 28, 61, 96, 150, 111, 166, 132, 94, 67, 91, 126, 81, 31, 95, 83, 26, 38, 19, 45, 40, 62, 59, 85, 79, 76, 39, 39, 36, 15, 22, 117, 115, 58, 94, 129, 64, 14, 31, 58, 71, 104, 47, 22, 44, 51, 50, 49, 103, 153, 114, 128, 168, 175, 196, 143, 31, 146, 90, 112, 53, 125, 226, 165, 73, 32, 35, 15, 13, 32, 10, 11, 31, 111, 211, 371, 278, 239, 77, 134, 189, 191, 172, 142, 156, 176, 112, 13, 157, 210, 240, 138, 134, 124, 182, 121, 131.029548800929, 127, 192, 138, 103, 35, 64, 159, 189, 125, 108, 116, 108, 141, 172, 219, 61, 22, 44, 121, 118, 86, 56.5910617580181, 24, 15, 35, 74, 42, 53, 63, 86, 42, 37, 65, 44, 74, 61, 90, 58, 33, 76, 132, 114, 144, 153, 96, 57, 86, 121, 71, 43, 17, 11, 27, 37, 51, 73, 56, 26, 52, 79, 118, 112, 97, 22, 16, 6, 14, 25, 33, 100, 62, 48, 76, 54, 54, 38, 36, 83, 60, 29, 28, 22, 24, 14, 7, 13, 55, 49, 17, 9, 25, 11, 7, 6, 17, 53, 8, 12, 9, 9, 7, 9, 10, 13, 14, 23, 7, 10, 15, 17, 41, 58, 20, 13, 10, 27, 19, 82, 72, 59, 35, 19, 12, 9, 46, 20, 17, 8, 14, 12, 14, 40, 55, 26, 6, 17.8830069661194, 28, 16, 36, 43, 38, 16, 5, 22, 14, 17, 15, 11, 12, 7, 7, 9, 30, 21, 15, 19, 12, 37, 23, 22, 15, 29, 45, 35, 61, 86, 81, 29, 12, 5, 6, 42, 35, 11, 8, 19, 16, 9, 24, 13, 19, 21, 47, 7, 11, 40, 58, 50, 36, 46, 9, 9, 45, 18, 21, 17, 14, 7, 20, 37, 39, 30, 24, 21, 10, 7, 29, 13, 68, 83, 109, 37, 8, 19, 18, 5, 29, 54, 69, 49, 89, 40, 30, 43, 17, 5, 32, 21, 38, 31, 21, 16, 10, 9, 16, 24, 39, 68, 79, 27, 12, 33, 75, 42, 23, 41, 89, 77, 102, 102, 22, 28, 42, 62, 50, 7, 11, 28, 46, 57, 24, 40, 79, 92, 115, 103, 127, 56, 76, 71, 105, 59, 16, 22, 22, 12, 47, 103, 106, 76, 24, 25, 42, 122, 141, 96, 47, 35, 24, 22, 107, 79, 51, 12, 26, 40, 38, 25, 44, 49, 92, 35, 11, 15, 52, 73, 69, 84, 61, 41, 45, 118, 108, 113, 120, 134, 123, 103, 32, 26, 26, 45, 34, 64, 134, 151, 42, 12, 93, 64, 73, 102, 198, 172, 185, 146, 22, 6, 6, 31, 76, 100, 31, 27, 46, 72, 133, 67, 116, 177, 235, 109, 48, 57, 77, 146, 120, 202, 178, 163, 73, 76, 68, 109, 43, 23, 8, 21, 12, 9, 17, 8, 8, 6, 13, 20, 8, 15, 56, 64, 54, 54, 177, 170, 195, 84, 9, 43, 163, 84, 9, 20, 23, 16, 21, 9, 10, 95, 175, 134, 114, 56, 48, 30, 28, 21, 11, 23, 32, 52, 52, 31, 25, 33, 44, 11, 22, 45, 26, 27, 30, 9, 5, 7, 10, 9, 12, 37, 19, 21, 5, 49, 23, 58, 85, 24, 4, 12, 9, 9, 6, 6, 4, 10, 8, 7, 45, 20, 23, 9, 15, 7, 6, 10, 14, 28, 44, 23, 37, 71, 61, 45, 19, 22, 10, 16, 23, 37, 20, 24, 14, 10, 29, 23, 16, 25, 17, 15, 25, 31, 18, 45, 21, 14, 17, 16, 30, 27, 13, 22, 11, 6, 8, 26, 15, 28, 23, 22, 34, 9, 19, 6, 6, 21, 22, 9, 8, 25, 22, 23, 16, 9, 10.3000885358035, 10.5680273254464, 10.8359661150893, 9, 25, 34, 24, 22.3425541619896, 21, 10, 8, 17, 17, 27, 13, 27, 19, 32, 18, 18, 18, 13, 28, 24, 12, 47, 23, 22, 26, 31, 19, 17, 19, 32, 15, 12, 4, 18, 10, 12, 12, 19, 14, 6, 13, 18, 26, 31, 40, 7, 4, 28, 54, 27, 52, 20, 9, 38, 43, 36, 4, 13, 29, 32, 43, 17, 23, 36, 21, 28, 20, 38, 42, 25, 24, 50, 45, 24, 6, 10, 10, 13, 12, 14, 24, 19, 34, 51, 28, 15, 14, 11, 10, 44, 29, 33, 46, 54, 56, 36, 41, 55, 29, 37, 64, 41, 43, 85, 72, 58, 119, 72, 11, 5, 17, 23, 78, 64, 17, 47, 31, 62, 101, 72, 59, 35, 17, 15, 56, 49, 45, 77, 79, 33, 20, 81, 54, 30, 54, 64, 49, 81, 68, 35, 65, 130, 70, 55, 35, 11, 10, 90, 28, 28, 17, 31, 89, 85, 29, 52, 34, 28, 32, 54, 61, 48, 33, 36, 71, 58, 131, 67, 34, 75, 136, 95, 46, 138, 170, 192, 209, 119, 147, 136, 131, 181, 127, 182, 216, 168, 159, 161, 140, 98, 33, 62, 128, 135, 102, 25, 5, 22, 18, 9, 82, 82, 48, 11, 29, 20, 6, 10, 30, 63, 169, 163, 218, 122, 81, 19, 13, 59, 19, 45, 19, 15, 15, 48, 34, 118, 83, 42, 84, 12, 14, 11, 14, 11, 6, 49, 64, 14, 8, 24, 11, 8, 26, 8, 22, 41, 32, 18, 21, 43, 88, 74, 101, 71, 9, 30, 55, 18, 16, 10, 32, 10, 6, 6, 7, 9, 32, 73, 67, 76, 25, 71, 52, 34, 46, 60, 48, 32, 111, 54, 64, 37, 26, 5, 6, 35, 8, 12, 49, 25, 23, 17, 60, 39, 37, 10, 7, 12, 52, 47, 87, 43, 63, 49, 25, 39, 34, 36, 24, 14, 11, 15, 2, 9, 12, 23, 17, 6, 5, 3, 9, 16, 17, 9, 11, 7, 23, 54, 40, 55, 32, 19, 12, 5, 18, 12, 26, 10, 15, 15, 5, 7, 10, 13, 11, 8, 7, 7, 9, 12, 11, 21, 15, 10, 6, 16, 17, 10, 22, 35, 10, 16, 12, 25, 17, 22, 28, 8, 7, 14, 22, 15, 10, 12, 5, 11, 20, 13, 11, 17, 31, 17, 4, 19, 11, 15, 18, 20, 22, 7, 6, 13, 14, 17, 21, 8, 6, 32, 33, 49, 54, 31, 5, 3, 23, 26, 16, 19, 29, 16, 9, 16, 11, 10, 24, 6, 3, 4, 18, 23, 9, 18, 29, 13, 4, 24, 12, 6, 13, 7, 12, 21, 18, 10, 23, 14, 12, 22, 20, 24, 21, 30, 31, 25, 11, 8, 38, 28, 30, 16, 28, 26, 15, 17, 31, 20, 17, 24, 27, 12, 50, 26, 19, 27, 25, 40, 15, 23, 31, 45, 43, 57, 19, 17, 56, 86, 39, 50, 42, 32, 15, 50, 25, 31, 24, 38, 28, 8, 10, 20, 27, 46, 84, 84, 63, 158, 129, 86, 111, 174, 96, 117, 121, 124.914045638056, 127, 152, 117, 88, 41, 27, 10, 12, 48, 19, 12, 23, 35, 39, 19, 75, 17, 10, 6, 29, 81, 119, 116, 106, 85, 48, 120, 96, 64, 53, 45, 48, 67, 59, 77, 84, 46, 84, 63, 67, 84, 160, 168, 241, 170, 44, 30, 46.1503142732202, 56.8550224709276, 67.5597306686349, 78.2644388663423, 88.9691470640496, 99.673855261757, 110.378563459464, 121.083271657172, 131.787979854879, 148, 111, 166, 93, 9, 51, 160, 191, 160, 221, 201, 177, 207, 161, 197, 199, 193, 151, 180, 162, 128, 105, 50, 14, 43, 36, 59, 96, 47, 35, 153, 101, 62, 211, 155, 136, 67, 10, 6, 5, 15, 17, 18, 23, 41, 73, 37, 45, 47, 51, 83, 65, 8, 8, 19, 24, 35, 81, 57, 18, 33, 13, 11, 11, 23, 45, 47, 10, 34, 56, 63, 46, 113, 98, 50, 102, 113, 101, 86, 51, 24, 16, 53, 30, 35, 14, 22, 20, 21, 49, 26, 19, 28, 71, 54, 25, 46, 57, 35, 22, 35, 18, 18, 20, 29, 17, 28, 23, 22, 12, 23, 31, 27, 21, 21, 32, 12, 33, 23, 13, 39, 46, 9, 10, 17, 34, 13, 38, 9, 19, 13, 34, 7, 27, 49, 11, 41, 39, 50, 42, 53, 41, 9, 12, 32, 20, 17, 16, 16, 18, 10, 9, 15, 17, 21, 31, 23, 12, 8, 21, 26, 18, 8, 21, 23, 8, 20, 13, 21, 21, 10, 11, 5, 13, 16, 18, 31, 19, 32, 10, 22, 15, 14, 27, 33, 16, 16, 35, 24, 22, 28, 15, 9, 23, 38, 48, 29, 30, 42, 10, 11, 32, 31, 19, 27, 14, 6, 7, 22, 29, 19, 19, 12, 10, 7, 11, 17, 12, 20, 16, 10, 26, 22, 25, 30, 46, 47, 13, 19, 19, 31, 25, 9, 7, 6, 6, 12, 12, 26, 43, 25, 5, 4, 5, 32, 19, 44, 61, 12, 8, 32, 43, 16, 17, 14, 12, 8, 23, 24, 33, 29, 46, 40, 5, 7, 11, 7, 15, 50, 41, 33, 40, 39, 25, 52, 60, 73, 45, 25, 31, 17, 47, 12, 35, 20, 14, 9, 53, 73, 109, 49, 15, 32, 82, 79, 95, 133, 64, 47, 75, 50, 82, 117, 161, 129, 68, 42, 20, 10, 63, 142, 55, 16, 23, 30, 81, 113, 168, 145, 96, 111, 189, 205, 175, 151, 87, 106, 168, 159, 216, 197, 108, 23, 13, 60, 120, 11, 173, 108, 77, 110, 196, 235, 215, 201, 229, 152, 103, 106, 76, 152, 130, 85, 35, 107, 86, 161, 195, 215, 200, 164, 96, 161, 177, 177, 158, 121, 97, 101, 70, 43, 32, 55), .Tsp = c(1, 6.9972602739726, 365), class = "ts")  • what is the frequency of data, daily, hourly or something else? Nov 8, 2019 at 15:29 • I have daily data for about 7 years. Starts Jan 01 of year x and ends Dec 31 of that year. Nov 8, 2019 at 16:17 ## 1 Answer You need to be using appropriate decomposition methods for daily data. Since it can have multiple seasonality. As an example, following seasonality can be observed in daily data: 1. Day of the week. 2. Day of the month. 3. Month of the year. 4. Holidays/special events. All of the above should be accounted. Using decompose in R does not capture above. tbats in forecast package can do multi seasonal time series. Below is the seasonal decomposition using tbats with two seasonal period. > Data.msts <- msts(Data,seasonal.periods = c(7,365)) #multi seasonal time series > fit <- tbats(Data.msts) > plot(fit) > plot(fit$errors)


Error plot, shows no pattern at least visually and also using acf on errors acf(fit\$errors).

This is just an example. you can use other techniques such as unobserved components model that can handle multi seasonality and also add external regressors such as holidays.

• Thanks! I didn't know of the TBATS before. Regarding this model. I want to use a combination of these time series models as inputs to a multivariate time series model. Before I was just feeding in the observed data but I know this is wrong since (as you see in the data here) it has seasonality. What would I use now as my "time series" data? Nov 8, 2019 at 17:34
• Do you have an example on how I can add external regressors such as holidays? Nov 9, 2019 at 18:13