# Interpretation of Canova and Hansen test for seasonal unit-root with R uroot package

I want to fit a SARIMA model and have daily sales data with a weekly seasonal pattern (frequency = 7) with this auto correlation function (ACF):

Clearly, there are seasonal effects as the spikes of the ACF indicate. As explained in (Shumway, Stoffer (2011): Time Series Analysis and its applications. Example 3.46, Figure 3.23.) the ACF of my time series also indicates seasonal non-stationarity and therefore a unit root in the seasonal component.

After differencing at lag $k=7$ ($y_t = y_t - y_{t-7}$) the ACF looks like this:

Since I wanted to automate this process I wanted to test for a unit root with the R package uroot using the Canova and Hansen test. This test assumes no unit root in $H_0$

However, when I execute:

z <- ts(data[,1], frequency=7)
res <- ch.test(z, type = "dummy", sid = 7)
res


I get the result:

           Canova and Hansen test for seasonal stability

data:  z

statistic pvalue
[1,]    0.1584 0.4785
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Test type: seasonal dummies
NW covariance matrix lag order: 12
First order lag: no
Other regressors: no
P-values: interpolation in original tables


Am I right assuming that the test gives me a $\text{p-value}=0.4785$ and therefore I cannot reject $H_0$ on a 95% confidence level and therefore have to assume there is no unit root in the seasonal component? And if yes, how does this fit the ACF indicating non-stationarity in the seasonal component? Is there a difference between unit root in the seasonal component and non-stationary seasonal component?

Am I missing/confusing something here?

Exemplary plot of the first 30 days:

All data:

[   0, 5530, 4327, 4486, 4997,    0, 7176, 5580, 5471, 4892, 4881,
4952,    0, 4717, 3900, 4008, 4044, 4127, 5182,    0, 5394, 5720,
5578, 5195, 5586, 5598,    0, 4055, 3725, 4601, 4709, 5633, 5970,
0, 7032, 6049, 6140, 5499, 5681, 5370,    0, 4409, 4015, 4252,
4241, 4809, 6154,    0, 6407, 5386, 5660, 5261, 5000, 5237,    0,
4038, 3794, 4558, 4676, 4611, 5350,    0, 7675, 6300, 5973, 5637,
5853, 5578,    0, 4949, 3853, 4341, 5108, 4925, 5003,    0, 7072,
6563, 5598, 5179, 5506, 5603,    0, 6729, 6686, 6660, 7285,    0,
7132,    0,    0, 5484, 4625, 4293, 4390, 5075,    0, 6046, 5514,
4903, 4366, 5263, 4773,    0, 3941, 3357, 3649, 2952, 4303, 4350,
0, 5672, 4492, 4309, 3939, 4841, 5726,    0, 5821, 5925,    0,
6486, 6027, 5912,    0, 4568, 4624, 5230,    0, 5409, 5064,    0,
6106, 5083, 4790, 4448, 4856, 4413,    0,    0, 4789, 3559, 4030,
4232, 4408,    0, 5519, 4995, 5784,    0, 7893, 5693,    0, 5422,
5220, 5012, 4881, 4315, 4262,    0, 4291, 3784, 3563, 3661, 4150,
4766,    0, 5337, 4633, 4180, 5011, 5173, 4341,    0, 3549, 4536,
3827, 3593, 4407, 5804,    0, 5614, 5868, 5875, 5701, 4986, 4090,
0, 4475, 4047, 3963, 4053, 4134, 4015,    0, 6377, 5643, 4946,
4904, 4275, 4421,    0, 4149, 3937, 3849, 3502, 4221, 3352,    0,
6290, 5773, 5572, 4994, 4494, 4461,    0, 4086, 3582, 4143, 3680,
3257, 3768,    0, 5326, 5299, 4724, 4575, 4552, 4078,    0, 3954,
3492, 3096, 3703, 3493, 4752,    0, 5482, 5156, 4583, 4804, 5469,
5317,    0, 4195, 3928, 3343, 3883, 3836, 4663,    0, 5893, 5403,
5103, 5079, 5187, 4663,    0, 4249, 3685, 3946, 3717, 3516, 3909,
0, 4770, 4274, 4212, 4481, 4669, 4175,    0, 4088, 4178, 4001,
0, 5447, 5352,    0, 6004, 5452, 4957, 5286, 5896, 4954,    0,
3773, 3355, 3383, 3223, 3566, 3667,    0, 5055, 4068, 4612, 4044,
4573, 4347,    0, 3557, 3737, 4119, 4035, 5471, 5233,    0, 5861,
5348, 5572, 5009, 5242, 4681,    0, 4014, 4017, 3310, 3795, 4016,
5071,    0, 5927, 5143, 4936, 4623, 5058, 5297,    0, 4600, 4201,
4561, 4614, 5623, 6373,    0, 6943, 6293, 5688, 5691, 6112, 5799,
0, 4462, 4228, 4301, 4074, 4703, 6119,    0, 8277, 7356, 7821,
6788, 8414, 8043,    0, 9528, 3204,    0,    0, 6110, 5659,    0,
7193, 2362,    0, 4969, 4190, 5173,    0, 6194, 5539, 4931, 4396,
4486, 4454,    0, 3994, 3621, 3776, 3632, 3803, 5128,    0, 6148,
5151, 4562, 4597, 5098, 4546,    0, 3601, 3581, 3789, 4549, 4906,
5292,    0, 5839, 5540, 5031, 4823, 5596, 4726,    0, 3591, 3461,
3662, 3638, 4647, 5258,    0, 5393, 4602, 4935, 4563, 4727, 4820,
0, 3826, 3499, 4108, 3826, 5031, 5307,    0, 6198, 5397, 4916,
4585, 5340, 4400,    0, 3573, 3588, 3805, 3224, 3883, 5042,    0,
5563, 5200, 4036, 4023, 4510, 5241,    0, 3850, 3136, 3225, 3847,
3987, 4583,    0, 6008, 5407, 4834, 4556, 4738, 4599,    0, 3751,
3990, 3919, 3948, 3733, 4435,    0, 6803, 6196, 6381, 6160,    0,
5871,    0,    0, 4133, 3482, 3376, 3710, 3989,    0, 5488, 5923,
5870,    0, 6790, 5498,    0, 5325, 5055, 5075, 5222, 5237, 5996,
0, 3957, 3535, 3710, 3589, 3863, 3785,    0, 5637, 4909, 4298,
3801, 4968, 4574,    0, 3912, 3971, 4616,    0, 5407, 4985,    0,
6071, 5614, 5229, 5278, 4957, 4923,    0,    0, 4607, 4207, 3702,
3901, 4757,    0, 4788, 5770, 5256,    0, 6362, 3982,    0, 3755,
3351, 3727, 2749, 4019, 5162,    0, 5738, 5138, 5161, 4756, 4025,
5176,    0, 4223, 4081, 3547, 3741, 4020, 4409,    0, 5083, 5298,
5424, 4685, 4609, 4084,    0, 4507, 3933, 3806, 3557, 3858, 4266,
0, 5372, 5252, 5487, 5106, 5038, 4731,    0, 5655, 5433, 5337,
4154, 4451, 4174,    0, 3886, 3185, 4069, 3906, 3746, 4425,    0,
5623, 5190, 4280, 4327, 3971, 3582,    0, 3414, 3396, 3148, 3920,
3869, 4094,    0, 5464, 5008, 4978, 4346, 4706, 3959,    0, 3676,
3377, 3275, 3392, 3906, 4270,    0, 4611, 4381, 4383, 3740, 4128,
3911,    0, 3982, 3407, 3405, 2462, 3518, 3914,    0, 5280, 4919,
4712, 5400,    0, 5355,    0, 5402, 5439, 4944, 4654, 4396, 4743,
0, 4033, 3681, 3775, 3430, 3720, 4169,    0, 4652, 4678, 4868,
4466, 4196, 4596,    0, 4260, 3364, 3761, 4042, 4161, 6532,    0,
5857, 5253, 4838, 4785, 5220, 4720,    0, 5474, 4479, 4677, 3869,
5334, 4967,    0, 3582, 3890, 3894, 4963, 4594, 5849,    0, 6527,
5815, 5328, 6144, 7195, 7066,    0, 7380, 6467, 6454, 7016, 6207,
6185,    0, 4884, 4345, 4915, 5060, 5269, 7263,    0, 8069, 7739,
7523, 7785, 7558, 8367,    0, 9331, 7959, 3659,    0,    0, 6057,
0, 6463, 6466, 2605,    0, 5509, 5023,    0, 6239, 4574, 4796,
3716, 3998, 4599,    0, 5346, 4924, 4541, 4295, 4161, 5255,    0,
3721, 3680, 3299, 3492, 3586, 4840,    0, 4781, 4806, 4310, 5171,
5577, 5363,    0, 6038, 4901, 4672, 4394, 5022, 4663,    0, 3965,
3136, 3735, 3900, 4726, 5015,    0, 4303, 4833, 4180, 4460, 4651,
4475,    0, 3598, 4054, 3875, 4042, 4708, 5289,    0, 5942, 5451,
5568, 4419, 5397, 4592,    0, 3701, 3805, 4170, 3141, 3725, 5225,
0, 5695, 4806, 3858, 4748, 4057, 3909,    0, 3565, 3547, 3531,
3932, 4005, 5208,    0, 6714, 6206, 6816, 6574,    0, 6709,    0,
0, 4163, 4194, 3467, 3549, 4173,    0, 5377, 4648, 4110, 4116,
4718, 4594,    0, 3722, 3037, 3319, 3076, 3198, 4318,    0, 5575,
5199, 5775, 6228,    0, 5850,    0, 5591, 4564, 4960, 4529, 4683,
4945,    0, 3551, 3547, 3998,    0, 4178, 4431,    0, 5280, 5235,
4735, 3755, 4459, 4276,    0,    0, 4211, 4083, 4111, 4656, 5592,
0, 5774, 5450, 5809,    0, 5384, 4183,    0, 4071, 4102, 3591,
3627, 3695, 4256,    0, 5518, 4852, 4000, 4645, 4202, 4097,    0,
3846, 3762, 3346, 3533, 3317, 4019,    0, 5197, 5735, 5223, 5558,
4665, 4797,    0, 4359, 3650, 3797, 3897, 3808, 3530,    0, 5054,
5042, 4767, 4427, 4852, 4406,    0, 4395, 3558, 3464, 3769, 3706,
4364,    0, 6102, 5011, 4782, 5020, 5263]


EDIT: I edited the question a couple of times in order to feedback the comments below.

EDIT: Differencing like suggested above seems the wrong way to go (see comments). Furthermore the statement there is a unit root could not be backed further (see comments). I will look into the OCSB test before writing an answer just to be sure.

• I only have a newer edition of Shumway & Stoffer, so I have not checked the reference, but why do you think there should be a seasonal unit root? The ACF spikes are not that tall, suggesting no seasonal unit root. On the other hand, the ACF 7 or 14 or 21 days ago are similar, perhaps suggesting a seasonal unit root. Did you have a similar intepretation? Jun 10, 2017 at 15:43
• Now that you added the graph of the original series, it does not look as if it would have a unit root (seasonal or nonseasonal). Then seasonal dummies or seasonal ARMA components could work. But perhaps the picture covers a period that is too short to judge. Jun 10, 2017 at 18:01
• Overdifferencing (differencing when it is not justified) is not innocuous. I wonder what the estimated SAR coefficient is is you pick the SAR order P=1. And I wonder what forecast::auto.arima in R would suggest. Jun 10, 2017 at 18:09
• Your interpretation of the output is correct. The null of stable seasonality is not rejected at the 5% significance level. You can also run the HEGY test for the null of unit roots and see if the conclusion agrees with the CH test; e.g, hegy.test(z, deterministic=c(1,0,1), lag.method="BIC", maxlag=7). Jun 10, 2017 at 21:31
• The plot monthplot(z) shows relatively stable seasonal paths around a horizontal line. This may be compatible with a deterministic seasonal pattern (notice again the zeros). Jun 10, 2017 at 21:31

Just because the ACF shows seasonal spikes with relatively slow decay it can not automatically be concluded that there is a unit-root in the seasonal componend.

Actually (Ghysels, Osborn (2001): The Econometic Analysis of Seasonal Time Series, p.29) states:

"[...] for the sample sizes often observed in practice, it may be difficult to discriminate between deterministic seasonality and a seasonal unit root process."

Furthermore on page 42 they write:

"It is now well known that a series generated by a unit root process can wander widely and smoothly over time without any inherent tendency to return to its underlying mean value [...]. In the seasonal context, there are S unit root processes, none of which has an inherent tendency to return to a deterministic pattern. As a result, the values for the seasons can wander widely and smoothly in relation to each other [...]"

Therefore it is useful to visualize the time series of the different seasons $S$ and see if they look non-stationary. In our case we have daily data and model each day as a season. So we get seasons $S=7$. Plotting gives:

None of the single seasonal time series looks particularly non-stationary.

Therefore the Canova and Hansen test statistics is perfectly fine. The same result is obtained when using the forecast::nsdiffs() function or the OCSBtest() function from the R forecast package source code on github.