Spurious seasonality detection: a non-parametric test proposal

This paper offers a general and comprehensive definition of the day-of-the-week effect. Using symbolic dynamics, we develop a unique test based on ordinal patterns in order to detect it. This test uncovers the fact that the so-called"day-of-the-week"effect is partly an artifact of the hidden correlation structure of the data. We present simulations based on artificial time series as well. Whereas time series generated with long memory are prone to exhibit daily seasonality, pure white noise signals exhibit no pattern preference. Since ours is a non parametric test, it requires no assumptions about the distribution of returns so that it could be a practical alternative to conventional econometric tests. We made also an exhaustive application of the here proposed technique to 83 stock indices around the world. Finally, the paper highlights the relevance of symbolic analysis in economic time series studies.


Introduction
The static capital asset pricing model (CAPM), developed independently by Sharpe (1964), Lintner (1965) and Mossin (1966), has been widely used for a number of financial matters. In its standard form, the CAPM states that the expected risk to security i can be separated into two components: the risk free rate and the risk premium. The latter, in turn, can be explained as the product between the market premium and a modulating coefficient β: These departures are called "anomalies" 1 . Among them, there is one especially puzzling feature: the day-of-the-week effect. This anomaly refers to the heterogeneous behavior of returns along the week. Testing the the day-of-the-week effect requires the joint consideration of an equilibrium model, such as Equation (1), and of the efficient market hypothesis (EMH). Empirical research on markets' daily seasonality can be traced back to Fields (1931Fields ( , 1934. These papers have the merit of investigating the issue before a market equilibrium model was formally developed. Cross (1973) detects differences in expected S&P 500 on Fridays and Mondays. Gibbons and Hess (1981) finds lower S&P 500 returns on Mondays relative to other days. The effect is subdivided by French (1980) into a Monday effect (abnormal negative return on this day) and a Friday effect (abnormal positive result on this day). Rogalski (1984) analyzes the effect during trading and non-trading hours for the American market. This effect has been widely surveyed and, for brevity, we refer to Keim and Ziemba (2000) and Ziemba (2012) for further discussion on empirical works about this effect. Keloharju et al. (2016) find return seasonalities in commodities and stock indices arround the world.
The standard approach for detecting the day-of-the week effect is based on the following regression equation (or some variations thereof): where r t is the return on day t and D i , i = {1 . . . , 4} are dichotomous dummy variables for each day of the week from Tuesday through Friday. The coefficient α 0 represents the mean return on Monday, while α i , i = {1 . . . , 4}, is the excess return on day i, and t is an error term. This traditional approach is based on different hypothesis testing on α i values (for an overview see, for instance, Bariviera and de Andrés Sánchez (2005) and references therein). Working based on Equation (2) forces several (sometimes unjustified) assumptions about parameters. For example, Zhang et al. (2017) applies a rolling sample test with a GARCH model in 28 stock indices. Precisely, our original approach, based on ordinal patterns, bypasses this shortcome. The aim of this paper is to provide a more general definition of the day-of-the-week effect and to develop an alternative test to assess the existence of seasonal effects in daily returns. This paper contributes to the literature in several ways. First, it generalizes the definition of the day-of-the-week effect. Second, it develops an alternative non-parametric test to detect it. Third, it shows that the results of the tests are not obtained by chance, since time causality is taken into consideration. Fourth, most of the day-of-the-week findings in the literature are related with the underlying return-generating process, and not with the causes indicated previously in the literature. Consequently, from a theoretical point of view, this paper introduces a new non-parametric test that is able to detect the intrinsic characteristics of the time series, and uncovers spurious seasonality detection causes. We would like to point out that the methodology we use here is unique in that it is nonlinear, ordinal, requires no model, and provides statistical results in terms of a probability density function. Ours is a statistical methodology that, to the extent of our knowledge, no one using time series analysis has used before.
The remaining of the paper is organized as follows. Section 2 presents the notion of ordinal patterns. Section 3 redefines the day-of-the-week effect and proposes a non-parametric test. Section 4 displays results of the test on theoretical simulations of different stochastic processes. Section 5 performs an empirical application to the New York Stock Exchange. Finally, some conclusions are drawn in Section 6.

Ordinal Pattern Analysis
Estimations based on Equation (2) require the assumption of an underlying stochastic process for returns. For these processes, symbolic analysis becomes a suitable alternative to study the dynamics of a time series. Bandt and Pompe (2002) developed a method for estimating the probability distribution function (PDF) based on counting ordinal patterns. The comparison of neighboring values of a time series requires no model assumption. The advantage of this method is that can be applied to any time series, and takes into account time causality Bandt and Pompe (1993). If returns fulfill the efficient markethypothesis (EMH), there should be no privileged pattern. If there were to be a privileged pattern, it would be exploited by arbitrageurs and any possibility of abnormal return should be rapidly wiped out. Thus, if the time series is random, pattern frequency should be the same, provided N D! If patterns are not equally present in the sample, three anomalous situations might be the cause: (1) Forbidden pattern: a pattern that does not appear within the sample.
Rare pattern: a pattern that seldom appears.
Preferred pattern: a pattern that emerges more often than expected by the uniform distribution.
In any of these cases, we are in presence of a time series with daily seasonal behavior. Consequently, the day-of-the week effect needs to be redefined. In this line, Zanin (2008) applies the concept of forbidden patterns in order to assess market efficiency, and shows that different financial instruments could achieve different informational efficiency. According to Amigó et al. (2006), forbidden patterns can be used as a means of distinguishing chaotic and random trajectories and constitute a satisfactory alternative to more conventional techniques.
Ordinal patterns have been previously used by Zunino et al. (2010Zunino et al. ( , 2011Zunino et al. ( , 2012 in order to compute quantifiers like permutation entropy and permutation complexity, which, in turn, allow one to quantify the degree of informational efficiency of different markets. Rosso et al. (2012) demonstrates that forbidden patterns are a deterministic feature of nonlinear systems. Bariviera (2011), and Bariviera et al. (2012) show that the correlation structure and informational efficiency are not constant through time and could be affected by several factors such as liquidity or economic shocks.
Given a time series of daily returns 2 beginning on Monday, R(t) = {r t ; t = 1, · · · , N}. With a pattern length D = 5, following the Bandt and Pompe (2002) method, N/5 partitions of the time series could be generated. Each partition is a five-dimensional vector (r t , r t+1 , r t+2 , r t+3 , r t+4 ), which represents a whole trading week. Each return is associated with a day of the week. For simplicity, we have day = {i; i = 0, . . . , 4; i ∈ N} standing for Monday through Friday. The method sets the elements of each vector in increasing order. Doing so, each vector of returns is converted into a symbol. For example, if in a given week r Mo < r Fr < r Tu < r Th < r We , where r Xx represents return on day Xx, the pattern is (0, 4, 1, 3, 2). There are 5! = 120 possible permutations. Each permutation produces a different pattern (P) and the associated frequencies can be easily computed. Each pattern has a frequency of appearance in the time series. Carpi et al. (2010) asserts that in correlated stochastic processes, pattern-frequency observations do not depend only on the time series' length but also on the underlying correlation structure. Amigó et al. (2007Amigó et al. ( , 2008 show that in uncorrelated stochastic processes, every ordinal pattern has an equal probability of appearance. Given that the ordinal pattern's associated PDF is invariant with respect to nonlinear monotonous transformations, the method of Bandt and Pompe (2002) results suitable for experimental data (see e.g., Parlitz et al. 2012;Saco et al. 2010). A graphical meaning of the ordinal pattern can be seen in Parlitz et al. (2012).

Day-of-the-Week Effect: A Redefinition of the Problem
As recalled in Section 1, the conventional definition of the day-of-the-week effect refers to the abnormal negative or abnormal positive returns on Monday and Friday, respectively. Since not all the markets are open on the same days, comparisons among countries could be difficult. For example, the Israeli market is open from Sunday through Thursday (Lauterbach and Ungar (1992)) and the first day of the week in the Kuwait Stock Exchange is Saturday (Al-Loughani and Chappell 2001). Additionally, markets are not open simultaneously, due to the different time zones (Koh and Wong 2000). Consequently, spill-over effects can influence returns and could distort results if such influence is not incorporated into the model.
In order to overcome these difficulties, we develop here a more general definition of the day-of-the-week effect that exploits the potential of the symbolic analysis of time series. Instead of estimating the return on each day by means of Equation (2), we will look at the relative position of the return on each day within its week. If there is no seasonal effect, the order in which the days appear in each position (from the worst until the best return of the week), should be random. Otherwise, a seasonal pattern would be detected.
First, we need to give an specific definition of our seasonal effect. It must be emphasized that, according to our proposal, we are not interested in detecting abnormal negative or positive returns on a given day. Instead, we are looking for the features of the return on a given day within its week, from the worst return of the week to the best return, independently of its sign. Thus, a new definition of the day-of-the-week effect is required.
Definition 1. The day-of-the-week effect occurs whenever a pattern appears much more or less frequently than expected by the uniform distribution.
From this definition a natural null hypotheses arises:
Since we are interested in studying the day-of-the week effect, testing this hypothesis is insufficient for our purposes.
We should count the number of times in which a given day exhibits the worst return of the week, the next to worst return, and so on, until the best return of the week is detected. In other words, we should count the number of times a given day i occupies the first, second, third, fourth, or fifth position in a pattern and place the absolute frequencies in a matrix as follows: Definition 2. Let A = a ij be a 5 × 5 matrix. Element a ij is the absolute frequency of return on day i at the position j.
Displaying results in this way, we count how many times a given day is in position 0 (the worst return of the week), position 1, position 2, position 3, and position 4 (the best return of the week). As a consequence, we advance two additional hypotheses: This hypothesis says that a given position in the week j could be occupied by any day of the week. All these null hypotheses could be tested using Pearson's chi-squared test. This test is useful to verify if there is a significant difference between an expected frequency distribution and an observed frequency distribution. Following Fernández Loureiro (2011) the test statistic is: where f o,ij is the observed frequency of day i at position j, and f e is the expected frequency ∑ 120 k=1 (P k )/5. Q is distributed asymptotically as a χ 2 with 4 degrees of freedom.
We advance two additional hypotheses focused on the so-called "Monday effect".
These hypotheses are tested using the binomial test, which for large samples can be approximated by the normal distribution. The test statistic is: where p o is the observed frequency, q o = 1 − p o , p e is the expected frequency, and N is the number of "weeks", i.e., the number of 5-day patterns in the sample. Our definition assumes that the day-of-the-week effect could be produced by the dependence among days of the same week. However, by splitting time series into weeks, we implicitly assume the independence among weeks. Even though this later assumption may be questionable, we do it this way in order to emphasize the order of the returns within the week. We could relax this assumption by moving data daily, instead of weekly. In this way, we could compare if, e.g., Friday in week t influences Monday in week t + 1 However, it could result in a more confused analysis, and we thus leave this for further research.

Simulation of Fractional Brownian Motion
In this section we apply the above-outlined technique to simulated time series. We used the MATLAB c wfbm function in order to simulate fractional Brownian motion for H = {0.1, . . . , 0.9}, where H is the Hurst exponent. Then, we take first differences in the time series in order to obtain the corresponding fractional Gaussian noise (fGn). The Hurst exponent H characterizes the scaling behavior of the range of cumulative departures of a time series from its mean. The study of long-range dependence can be traced back to a seminal paper by Hurst (1951), whose original methodology was applied to detect long memory in hydrologic time series. This method was also explored by Mandelbrot and Wallis (1968) and later introduced in the study of economic time series by Mandelbrot (1972). If the series of first differences is a white noise, then its H = 0.5. Alternatively, Hurst exponents greater than 0.5 reflect persistent processes and less than 0.5 define antipersistent processes.
We perform 1000 simulations consisting of 10,000 data-points for each value of H. Accordingly, we obtain 2000 "weeks", which will be classified into one of the 5! = 120 possible patterns. If the underlying stochastic process is purely random and uncorrelated, the frequency of patterns should be uniform. On the contrary, if some correlation is present, some patterns could be preferred over others. All the tests are performed at a 5% significance level.
In Table 2 we test the equality of patterns (Hypothesis 1). When H = 0.5 (ordinary Gaussian noise), we cannot reject, on average, the null hypothesis of equal appearance of patterns. Out of the 1000 simulations, only in 50 cases is the null hypothesis rejected. When we move away from H = 0.5, in both directions, rejection increases almost symmetrically. This clearly shows that some kind of correlation affects the distribution of ordinal patterns.
As commented in the previous section, this analysis is not sufficient. Therefore, we proceed to test Hypothesis 2 and present the pertinent results in Table 3. We test the hypothesis (for every H value) for each of the samples and for the average of the samples. We find that for H = 0.5 we cannot reject the null hypothesis. In fact, rejection occurs in only 51-59 times out of 1000 samples. In other words, when the generating stochastic process is a white noise, any day is equally prone to occupying any of the positions in the pattern. This is the same as saying that any day could exhibit the best or the worst return of the week, or any intermediate value among them. When we move away from the value 0.5, rejections increase. However, the effect is stronger for H > 0.5 than for H < 0.5. This could mean that a positive long -range correlation (i.e., a persistent time series) is more likely to exhibit a day-of-the-week behavior than anti-persistent time series. Additionally, Monday, Wednesday, and Friday are the days most affected by the value-change of H.  Regarding Hypothesis 3, results are displayed in Table 4. In the case of the uncorrelated process (H = 0.5), one encounters that how good or bad the return is within a trading week is independent of the day of the week. This hypothesis is only rejected only 59 times out of the 1000 simulations. When we move away, and then correlations become stronger, and patterns exhibit some degree of preference, increasing the number of rejections. As in the case of Hypothesis 3, rejections are more frequent in the case of persistent time series. Hypothesis 4 tests whether the presence of patterns with Monday as the largest return is in agreement with the uniform distribution. There are 24 patterns with Monday as the last element. Consequently, the expected frequency is 0.2. Table 5 displays the results of the simulations. In the case of a pure Gaussian noise, we cannot reject the null hypothesis, as in only 117 out of the 1000 trials we reject it. However, increasing the Hurst exponent produces an increment in the number of rejections. Additionally, we observe that larger Hurst values are associated with greater observed frequency of patterns with Monday as largest return. However, we cannot reject the null hypothesis until H = 0.8 or higher. Hypothesis 5 tests the presence of a weekly seasonality with Monday as the smallest return of the week and Friday as the largest. There are six patterns with this structure. In analogy with the preceding finding, for an uncorrelated noise, this pattern is neither a preferred nor a rare one. Nevertheless, the increase of the Hurst exponent produces a quick increase in the number of rejections: 309 out of 1000 when H = 0.7. More impressive is how preferred this pattern is in most of the simulations.
For H = 0.6, in 698 simulations, the observed frequency of these six patterns was above expectations, and for H = 0.7, p o > p e in 873 simulations (see Table 6). Symbolic analysis is powerful for detecting nontrivial hidden correlations in data. As shown by Carpi et al. (2010); Rosso et al. (2012), a correlated structure as produced by fractional Gaussian noise processes generates an uneven presence of patterns. Provided a sufficiently long time series, no pattern is forbidden. However, a strongly correlated structure produces the emergence of preferred and rare patterns.
Our artificial time series are larger than the usual data sets used in economics. Consequently, the presence of preferred patterns such as the ones evaluated in Hypothesis 5 casts doubts on the validity of previous findings of day-of-the-week. In particular, we claim that, in view of our results, the day-of-the-week effect is mainly produced by a complex correlation structure of the pertinent data.

Empirical Application
We used daily data of the NYSE Composite Price Index from 3 January 1966 to 8 December 2017, with a total of 13,550 observations. All data used in this paper was retrieved from Datastream. We split the sample into four non-overlapping periods of equal length (3050 data points), and a final period of 1350 datapoints, in order to verify the temporal evolution of the seasonal effect. We compute daily log returns in order to apply our test.
Regarding Hypothesis 1 (see Table 7), we find, in the whole sample, no forbidden patterns. Under these circumstances, we should discard chaotic behavior in the time series . The least frequent pattern, with an absolute frequency equal to 7, is 42013 (i.e., r Fr < r We < r Mo < r Tu < r Th ). The most frequent patterns, with an absolute frequency equal to 34, are 03421 and 04312 (i.e., r Mo < r Th < r Fr < r We < r Tu and r Mo < r Fr < r Th < r Tu < r We , respectively). As stated in Section 2, if data was generated at random, i.e., if no seasonal effect exists, patterns should uniformly appear, configurating the histogram of a uniform distribution. However, as seen in Figure 1, ours is a far from uniform distribution. Table 8 exhibits frequencies and tests for Hypotheses 2 and 3. Following the horizontal lines of the table, we test whether a given day indifferently occupies any position in the returns of the week. Along the vertical sense of the table, we test whether a given position within a week is indifferently occupied by any day.
Regarding the whole period, we observe that we cannot accept the null hypothesis of equal distribution of returns across the week. In fact, if we observe Table 8, Monday acquires the lowest return of the week more frequently than any other week-day.

Figure 1.
Histogram of pattern frequency for the whole period. Table 9. Absolute frequency of each day in each position with shuffled data for the whole period. Columns 2 to 6 reflect the frequency a given day in terms of the worst return of its week, the next to worst return, etc. until the best return of its week. Q is the χ 2 statistic defined in Equation (6). If we analyze the evolution of the daily seasonal behavior through time, it is clear that the day-of-the-week effect disappears in daily returns of the NYSE Composite index. Results are reflected in Tables 10-14. Considering the last subperiod, only Tuesday's effect remains. Tuesday is the most frequent day in the worst position and Friday tends to occupy the best return within each week. However, we cannot reject that the worst return of the week can be occupied by any other week-day. According to this analysis we observe, in agreement with the literature, a disappearing weekly effect in daily returns in the US market. This disappearing effect is related to the hidden underlying dynamics of data, rather than markets participant behavior, as was classically envisaged in the literature. We would like to emphasize that our test unveils the hidden correlation structure of daily returns. As in the case of the artificial generated series, the pattern behavior in real time series is strongly affected by the long memory of data.

Worst Return Best Return
An important difference between real and simulated data is that, whereas in the controlled experiment the Hurst exponent is, by definition, constant across all the time series, in the case of real data, the Hurst exponent tends to vary across time (see e.g., Bariviera et al. 2012;Tabak 2004a, 2004b). This situation makes a direct comparison between both results difficult. Moreover, we can observe that the power of the test is more sensitive for H > 0.5 in detecting the Monday effect (see Table 6 ). In fact, for H = 0.9, the test rejects 856 out of the 1000 simulated series. Another factor that influences results is the time series length. As recalled by Rosso et al. (2012), short time series could result in the incorrect detection of forbidden patterns. Table 10. Absolute frequency of each day in each position. Subperiod 1: 3 January 1966-9 September 1977. Columns 2 to 6 reflect the frequency a given day in terms of the worst return of its week, the next to worst return, etc. until the best return of its week. Q is the χ 2 statistic defined in Equation (6)     In the Supplementary Material file we present the simulation and test of hypotheses for shorter time series. Additionally, we perform an exhaustive analysis of 83 stock indices with different Hurst levels. We can observe that greater Hurst levels are associated with more significant presence of preferred patterns.
It is clear that theoretical and empirical analyses exhibit some differences. We have to acknowledge that real stock markets dynamics do not follow a pure fGn . In fact, long-range dependence is not only seen in financial time series, but also in volatility, as shown recently by Bariviera (2017). Precisely, more advanced models such as the fractional normal tempered stable process presented by Kim (2012Kim ( , 2015, allow for long-range dependence in both volatility and noise, and asymmetric dependence structure for the joint distribution. There are many economic variables that influence behaviors known as "stylized facts" of financial time series: volatility clustering, fat tails, asymmetric dependence, etc. For example, Kim (2016) found that long-range dependence increased more in volatile markets during the Lehman Brothers collapse.
We try to emphasize in this paper that, even using a simple model such as a fGn, some part of the seasonal effect is simply due to the correlation structure of data, and not only due to economic reasons. This finding could be used as a starting point in further research in order to apply prewhitening to time series prior to its analysis in order to obtain more reliable results.

Conclusions
We propose a more general definition of the day-of-the-week effect. We use symbolic time series analysis in order to develop a test to detect it. According to Definition 1, this effect takes place when a pattern is much more or much less frequent than expected from the uniform distribution. The nature of the seasonal effect is reflected in a frequency matrix (Definition 2), and a χ 2 test is performed. The new definition allows for a more general and comprehensive study on return seasonality. We would like to highlight that the methodology we use here is unique in that it is nonlinear, ordinal, and requires no a priori model. Additionally, it provides statistical results in terms of a probability density function. To the extent of our knowledge, time series analysis has not been used in a similar methodology before.
Both theoretical and empirical applications show that this method could be useful to discriminate between rare and preferred patterns of a time series. We show that the so-called day-of-the-week effect is influenced not only by traders' behavior or economic variables. It could be also be induced by the stochastic generating process of data. The findings in this paper could be taken into account in future research, aiming at the separation between the economics causes and the long-range correlation causes of this financial phenomenon.