A New Wavelet Tool to Quantify Non-Periodicity of Non-Stationary Economic Time Series

We introduce a new wavelet tool, the windowed scale index, to study the degree of non-periodicity of time series. The windowed scale index is based on some recently defined tools, such as the windowed scalogram and the scale index. This novel measure is appropriate for non-stationary time series whose characteristics change over time and, therefore, it can be applied to a wide variety of disciplines. Furthermore, we revise the concept of the scale index and pose a theoretical problem: it is known that if the scale index of a function is not zero then it is non-periodic, but if the scale index of a function is zero, then it is not proved that it has to be periodic. This problem is solved for the particular case of the Haar wavelet, reinforcing the interpretation of the windowed scale index as a useful tool to quantify non-periodicity. In addition, the applicability of this wavelet-based measure is illustrated through several examples, including an economic application which compares the non-periodicity of two major commodities in the world economy, such as crude oil and gold. Finally, we discuss the relationship between non-periodicity and unpredictability, comparing the windowed scale index with the sample entropy.


Introduction
A large part of the analysis of a time series or signal consists of the determination of its main features and whether those features remain constant over time, so that this series can be considered stationary. A very important type of stationary time series are the periodic signals. In fact, it is obvious that the more periodic a signal is, the more easy and reliable the forecasts of this signal will be. However, in practice, a time series will be rarely periodic because, for example, it may be affected by a random noise, it may be a quasi-periodic signal arising from a dynamical system, or even a chaotic signal. The analysis of the irregularity of a signal is a topic that has been considered in the literature in many occasions. For instance, some examples of tools used for measuring the degree of complexity of a time series are the sample entropy [1], the approximate entropy [2], and the permutation entropy [3], which has been recently used in analysing nonlinear dynamical time-series [4].
The scale index is a wavelet tool designed to measure the degree of non-periodicity of a time series through its wavelet scalogram, allowing to quantify how much chaotic a signal is. This tool was introduced in [5] and has been used in a wide variety of recent works applied in many different scientific disciplines, such as the study of speech signals [6], pseudo random number generators [7][8][9][10][11][12], images encryption [9,13], meteorology [14], biomedicine [15], robotics [16], engineering [17], mechanical fault identification [18], etc. The scale index is based on a result, proved in [5], according to which the continuous wavelet transform of a periodic function, which is associated with a compactly supported wavelet, vanishes when the scale is twice the period (for all times). From this result, the scale index vanishes for all periodic signals and depends continuously on the signal itself. Therefore, when a signal is close to a periodic one, its scale index will take a value close to zero.
Nevertheless, the scale index simply provides a global or average measure of non-periodicity for the entire time series, and hence it does not consider the time location. This feature could be a serious handicap for the study of non-stationary signals whose behaviour varies substantially over time and, consequently, their non-periodicity may not be constant. For these cases, we introduce the windowed scale index, which is a new wavelet tool that inherits the properties of the scale index for measuring the non-periodicity of a time series centered at a given point with a given time radius, preserving in this way the time location. Moreover, using the time radius as a parameter makes this tool much more versatile. In addition, we would like to emphasize that the windowed scale index is not just a simple rolling-window application for the scale index proposed in [5], but is is based on the windowed scalogram measured developed in [19], which constitutes a non-trivial extension of the wavelet scalogram.
This paper is organized as follows. In Section 2 we introduce the wavelet mathematical background, refresh the concept of the scale index and present a new theoretical result (see Proposition 1) that reinforces the interpretation of the scale index (windowed or not) as a non-periodicity measure. In Section 3 we define the windowed scale index and, in Section 4, we give examples and an application in economics. Moreover, we discuss the relationship between non-periodicity and unpredictability, comparing the windowed scale index with the sample entropy, a well-known complexity measure. Finally, in Section 5 we provide some concluding remarks.

Basic Concepts of Wavelets
A wavelet is a function ψ ∈ L 2 (R) with zero average (i.e., R ψ = 0), normalized ( ψ = 1) and "centered" in the neighborhood of t = 0 (see [20]). Scaling ψ by s > 0 and translating it by u ∈ R, we can create a family of time-frequency atoms (also called daughter wavelets), ψ u,s , as follows Given a time series f ∈ L 2 (R), the continuous wavelet transform (CWT) of f at time u and scale s with respect to the wavelet ψ is defined as where * denotes the complex conjugate. The CWT allows us to obtain the frequency components (or details) of f corresponding to scale s and time location u, thus providing a time-frequency decomposition of f . The scalogram of a time series f at a given scale s > 0 is given by The scalogram of f at s is the L 2 -norm of W f (u, s) (with respect to the time variable u) and captures the "energy" of the CWT of the time series f at this particular scale. Note that we use the definition of scalogram given in [5,19], that is not the one commonly acknowledged: usually it is the squared magnitude of the CWT. This definition of scalogram allows for the identification of the most representative scales of a time series, i.e., the scales that contribute most to its total energy. Moreover, given a function f ∈ L 2 (R) it can be decomposed into a sum of CWTs computed at base 2 power scales under some conditions on the wavelet (see [20]). So, with respect to the representation of the scalogram and taking into account (4), it is convenient to use a binary logarithmic re-scalation in the abscissa axis, making base 2 power scales equidistant (see [19]).

The Scale Index
In this section, we define the scale index, a wavelet tool for measuring non-periodicity through the scalogram, which was previously introduced in [5]. However, first we need some previous results.
The next theorem ensures that if a function f has details at every scale (i.e., the scalogram of f does not vanish at any scale), then it is non-periodic. For a detailed proof see [5].
Note that if f is a T-periodic function in L 2 ([0, T]), and ψ is a compactly supported wavelet, then W f (u, s) is well-defined for u ∈ R and s > 0, although f is not in L 2 (R).
In Theorem 1, f is defined over the entire R, but, in practice, time series have a finite time domain and produce "border effects" when the wavelet exceeds the domain limits. So, given a T-periodic time series with finite time domain, these border effects cause the scalogram not to vanish at scale 2T. Therefore, we are going to define a special type of scalogram for precisely avoiding the undesired border effects.
where J(s) = [c(s), d(s)] ⊆ I is the maximal subinterval in I for which the support of ψ u,s is included in I for all u ∈ J(s). Obviously, the length of I must be big enough for J(s) not to be empty or too small, i.e., b − a sl, where l is the length of the support of ψ.
Since the length of J(s) depends on the scale s, the values of the inner scalogram at different scales cannot be compared. To avoid this problem, we can normalize the inner scalogram: From Theorem 1 and Definition 1 we obtain the following corollary, that can be also found in [5].

Remark 1.
The concept of inner scalogram can be extended to wavelets that do not have compact support like Morlet wavelets, taking a compact "effective support" outside of which the magnitude of the wavelet can be considered negligible. However, in this case, some theoretical results like Corollary 1 may not hold exactly. According to [21], the effective support is defined by the e-folding time for the autocorrelation of wavelet power spectrum at each scale s that, for Morlet wavelets, is equal to √ 2s.
These results constitute a valuable tool for detecting periodic and non-periodic signals as a signal with details at every scale must be non-periodic. Moreover, since the scalogram of a T-periodic signal vanishes at all 2kT scales (for all k ∈ N), it is sufficient to analyse only scales greater than a fundamental scale s 0 . Thus, a signal which has details at arbitrarily large scales will be non-periodic.
On the other hand, we can ask if a function f with W f (u, 2T) = 0 for all u ∈ R is really a T-periodic function. In general, it is not proved and it remains as an open question. Nevertheless, this result can be proved in the particular case of Haar wavelets assuming that f is bounded: Proposition 1. Let ψ be the Haar wavelet and let f : R → R be a continuous and bounded function. Given Proof. Without loss of generality we may assume that T = 1. Let us define for all u ∈ R. Then, using the Haar wavelet for all u ∈ R and hence g is 1-periodic.
We are going to prove that g is in fact a constant function by reductio ad absurdum. Supposing g is not constant, we can find u 1 , u 2 ∈ [0, 1[ with c 1 := g (u 1 ) = c 2 := g (u 2 ). If M is an upper bound for | f |, then we take N ∈ N such that N |c 2 − c 1 | > 2M. Thus, since g is 1-periodic. Analogously, So, from (5) and (6), we have On the other hand, supposing u 1 < u 2 , we have Since (7) contradicts (8), g must be a constant function and then, for all u ∈ R, concluding that f is a 1-periodic function.
Taking into account these results, we are going to define the scale index, that was previously introduced in [5]. However, we present a slightly different definition.

Definition 2.
The scale index of a time series f in the scale interval [s 0 , s 1 ] is given by the quotient where s max ∈ [s 0 , s 1 ] is the smallest scale such that S(s) ≤ S(s max ) for all s ∈ [s 0 , s 1 ], and s min ∈ [s max , 2s 1 ] is the smallest scale such that S(s min ) ≤ S(s) for all s ∈ [s max , 2s 1 ]. Note that for compactly supported signals, the use of the normalized inner scalogram is recommended in order to fulfil Corollary 1 and to avoid border effects.
From its definition, i scale ∈ [0, 1] and it can be interpreted as a measure of the degree of non-periodicity of a signal in the scale interval [s 0 , s 1 ]: the scale index will be numerically close to 0 for periodic and quasi-periodic signals, and close to 1 for highly non-periodic chaotic signals.
The difference between Definition 2 and the definition given in [5] is that in Definition 2 the scale s min is sought in [s max , 2s 1 ] instead of [s max , s 1 ]. This change is motivated by Theorem 1 and Corollary 1, because given a T-periodic signal (being T the least period) its most representative scale is usually near T, and the scalogram vanishes at scale 2T. So, we need to compute the scalogram up to the scale 2s 1 in order to detect periodicities in [s 0 , s 1 ]. As a consequence of this fact, if there are scales in [s 1 , 2s 1 ] at which the scalogram takes a greater value than at s max , then s 1 should be increased if we want to take into account these important scales in our analysis. Or, from another point of view, taking the definition of the scale index given in [5], if the scale s max is in [s 1 /2, s 1 ], then we should take a bigger s 1 , at least up to 2s max , but only if we have no objection to include larger scales in our study of non-periodicity.
For example, Figure 1 plots the scalogram and the scale index of a given signal, taking s 0 = 4 and varying s 1 from 4 to 64. It can be seen that i scale = 1 for s 1 ∈ [4, 5.5] ∪ [13.3, 17] approximately, but there are scales in [s 1 , 2s 1 ] at which the scalogram takes a greater value than at s max . So, as it is indicated above, if we want to make a wider scale study of non-periodicity, then s 1 should be increased in these cases. Nevertheless, if we are interested in measuring non-periodicity only in a determined scale interval [s 0 , s 1 ] with s 1 ∈ [4, 5.5] ∪ [13.3, 17], then we can conclude that the signal is highly non-periodic in [s 0 , s 1 ], and the reason in this case is that there are significant scales outside the range of study.
At this point, it is clear that the choice of the scale interval [s 0 , s 1 ] is an important issue in the non-periodicity analysis. Since the non-periodic character of a signal is given by its behaviour at large scales, there is no need for s 0 to be very small. In general, we can choose s 0 such that s max = s 0 + where is positive and small. On the other hand, s 1 must be greater than all the relevant scales that we want to study. Moreover, if s min 2s 1 , then the scalogram decreases at large scales and it is recommended to increase s 1 in order to distinguish between a non-periodic signal and a periodic signal with a very large period. In general, it is recommended to make an study varying s 1 as in Figure 1c in order to visualize the evolution of the scale index.

Remark 2.
It is known that the wavelet power spectra and, consequently, the scalogram of a signal are biased in favor of large scales (see [22]). This feature has to be taken into account by some wavelet tools that quantify the "energy density" based on the scalogram, such as the wavelet squared coherency (see [21,23]) or the windowed scalogram difference (see [19]). In these tools, the scalogram is multiplied by the factor 1 √ s for normalizing the weight of each scale (see Figure 2), or, from another point of view, the mother and daughter wavelets are normalized using the L 1 -norm instead of the L 2 -norm. However, in the case of the scale index, this correction would not be necessary because the scalogram of a white noise signal is more or less constant at all scales giving a scale index close to 1 for any s 1 , and this is the property that we want to preserve. If, on the other hand, we apply the correction for converting the scalogram into an "energy density" measure, the scale index of a white noise signal would tend to zero as we increase s 1 (see Figure 3) and this is not desirable.   √ s . It tends to zero for large scales and so, the scale index computed from this modified scalogram would also tend to zero as we increase s 1 .

The Windowed Scale Index
The scale index given by (9) provides an estimate of the degree of non-periodicity of an entire time series. However, non-stationary signals may pass through different stages in which their behaviour varies considerably and therefore their non-periodicity may not be constant over time. For these cases, we introduce the next definitions.
The windowed scalogram was previously introduced in [19] and it is just the scalogram given by (3) where, analogously to Definition 2, s max is the smallest scale such that W S τ (t, s) ≤ W S τ (t, s max ) for all s ∈ [s 0 , s 1 ], and s min is the smallest scale such that W S τ (t, s min ) ≤ W S τ (t, s) for all s ∈ [s max , 2s 1 ].
Although in the computation of the scale index it is recommended the use of normalized inner scalograms in order to avoid border effects, this recommendation is less important in the case of the windowed scale index. This is because for long series and relatively small time radii there would be no border effects in most of the windowed scalograms.
As the original scale index, the windowed scale index is also in the interval [0, 1] and it inherits the properties of the scale index that make it a tool for measuring the degree of non-periodicity of a signal around a given time. Precisely, this time dependence makes it a suitable tool for the study of non-stationary signals.
With respect to the choice of the time radius τ, it depends on the nature of the time series f and the objective of the study. In general, it must be big enough so that the windowed scalograms conserve desired (not noisy) information about f , but a too large τ produces inaccuracy in the location of events for non-stationary time series. Usually, if [a, b] is the support of f , then τ = (b − a) /20 is a good choice.

Examples and Applications
In this section we illustrate the application of the windowed scale index to different scenarios of non-stationary time series such as chaotic time series, signals affected by non-stationary random noises, and economic and financial time series which present both chaos and noise.
Computations are performed using a self-developed R package [24] called wavScalogram [25], which can be freely downloaded from CRAN.

The Bonhoeffer-van der Pol Oscillator
As it was done in [5], the applicability of the windowed scale index is illustrated by studying some time series generated by the Bonhoeffer-van der Pol oscillator (BvP), which is given by the following non-autonomous planar system being a = 0.7, b = 0.8, c = 0.1, and I(t) = A cos (2πt) an external periodic force. This oscillator is employed for modelling cardiac pulse (see [26]), and hence it is very useful to examine the non-periodicity of a signal without loosing the time location.
Taking the amplitude of the external force A as a parameter, we can construct time series by means of the x coordinate of the solution of (12) with initial conditions (0, 0). Specifically, we have created two time series for A = 0.74 and A = 0.76, with t from 20 to 400 using a time step of ∆t = 0.05, which are called "series 1" and "series 2", respectively. Moreover, we have constructed another time series, designated by "series 3", using A = 0.74 for t ∈ [20, 400] and A = 0.76 for t ∈ ]400, 780]. The normalized inner scalograms of these series are displayed in Figure 4, using Daubechies eight-wavelet function and scales running from 0.05 to 12.8.  For the computation of the windowed scale indices of these series (see Figure 5), we choose a time radius τ = 50 (i.e., 1000 data points), s 0 = 0.05, s 1 = 6.4 and we utilize windowed normalized inner scalograms. This means that we have not taken into account CWTs where the corresponding wavelet overlaps the extremes of the time domain ([20, 400] for series 1 and 2, and [20,780] for series 3), and the scalograms are normalized as it is shown in Definition 1. As a curiosity, the global scale index of series 3 is approximately 0.4494, which is greater than the scale index of series 1 (0.0768 approx.) and series 2 (0.4116 approx.). Figure 6 depicts the different stages for obtaining the windowed scale indices of series 3 for a wide set of values of s 1 , ranging from 0.4 to 6.4. In this way, we can see the importance of the choice of s 1 . Note that Figure 5 only plots the windowed scale indices for s 1 = 6.4.
As can be seen in Figure 5, the windowed scale index clearly shows the evolution of the scale index over time, which is an important improvement, and is more appropriate for studying non-stationary signals than the global scale index. Specifically, Figure 5c illustrates the usefulness of the windowed scale index in detecting the jump in the non-periodicity due to the change in the amplitude of the external force, while the global scale index described in [5] only gives an overall value for the whole time span.

A Signal with Increasing Noise
The windowed scale index is not only useful to study chaotic signals, as the one seen in the above example, but it also enables analysing other non-stationary signals such as those affected by non-stationary random noises. For example, we may consider a signal of the form which corresponds to a 1-periodic signal plus a Gaussian noise term t with increasing variance. Figure 7 depicts the average of the windowed scale indices of 1000 series of the form described by (13) taking s 0 = 0.02 and different s 1 values, using Morlet wavelets and time radius τ = 5. Since there is a 1-periodic term, s 1 must be greater or equal than 1 in order to detect this periodicity. However, choosing a too large s 1 has drawbacks: the larger s 1 is, the lower the noise sensitivity will be, as shown in Figure 7. This figure also illustrates how the windowed scale index succeeds in describing the nature of signals with non-stationary noises, as it gets larger over time as the noise of the signal increases, according to what would be expected.

An Economic Application: Crude Oil and Gold Prices
An interesting application of the windowed scale index in the field of economics consists of quantifying the degree of non-periodicity of the price of two major commodities such as crude oil and gold at different points in time and for certain ranges of scale. This analysis allows one to determine to what extent these time series have a periodical or repetitive behaviour.
Crude oil and gold are the most actively traded mineral commodities in the world and play a critical role in human civilization. As mentioned by [27], oil is by far the most strategic commodity and the most sizable source of energy for the modern economy as it constitutes a vital input in the production process of many goods and services. The importance of crude oil is so great that changes in oil price affect strongly global economic growth, inflation and asset values. Meanwhile, gold is the leader in precious metal markets and is demanded for jewelry purposes and for many other industries such as dental, electronics and chemicals. Furthermore, gold has had a unique historic function as a means of exchange and a store of value for millennia and, more recently, as an alternative investment that hedges against inflation, a falling U.S. dollar or other forms of uncertainty. Due to its singular nature, gold is widely considered to be an effective safe haven asset against losses in financial markets, especially in times of financial and economic instability [28][29][30].
The dataset used in this application consists of daily closing prices of futures contracts for gold and crude oil. Specifically, for oil the prices from nearby contracts of crude oil futures traded on the New York Mercantile Exchange (NYMEX) are utilized. For gold, the nearby contract prices of gold futures traded on the COMEX division of the NYMEX, which is the most liquid gold contract in the world, are employed. Changes in prices of oil and gold futures contracts are used in order to better capture the possible repetitive or periodical nature of these two series. The sample period spans from 24 June 1988 until 20 June 2017, with a total of 7564 daily observations. All data are collected from Thomson Reuters DataStream. Figure 8 displays the windowed scalograms and windowed scale indices of changes in the price of crude oil and gold futures contracts. The windowed scalograms use a time radius τ = 300 days and the windowed scale indices are calculated from these windowed scalograms taking s 0 = 8 days and a wide range of scales s 1 , from 32 to 512 days. We have not used inner scalograms in this case. Therefore, the corresponding cones of influence outside which there are border effects have been plotted. It is shown that the windowed scale indices for oil futures contracts take very high values in the time period between 2007 and 2010 for scale intervals with s 1 between 150 and 300 days, which are representative of the medium term. This finding may be closely related to an important shift in the behaviour of oil price from 2007. In particular, as can be seen in the windowed scalograms for crude oil futures contracts in plot (a) of Figure 8, the scales between 256 days (approximately one year) and 512 days (two years) become the scales that contribute most to the energy of the oil price series during the period 2007-2010, and by taking s 1 less than 300, these important scales are not taken into account. Hence, these high values of the windowed scale indices for oil futures can be interpreted as an evident symptom of unpredictability (see Section 4.4) in oil price at the medium term during the period around the financial crisis that started in mid-2007 in the U.S. subprime mortgage market and spread throughout the world from September 2008 following the collapse of the U.S. investment bank Lehman Brothers. During this period, crude oil price experienced drastic rises and falls mostly driven by positive and negative shifts in global aggregate demand. For example, as noted by [31], the rapid increase in the spot price per barrel of West Texas Intermediate (WTI) crude oil from USD 58 in January 2007 to USD 140 in June 2008 may be associated with a strong global economic activity. In turn, the decline in oil price to USD 41.68 in January 2009 may be attributed to the global financial crisis and the subsequent great recession. However, the WTI oil price rebounded to USD 133.93 in April 2011, even though global economic activity remained moderate. Therefore, the abnormally volatile development of crude oil price over the last years may have largely contributed to the high degree of unpredictability of oil price at the medium term around the recent global financial crisis, which is captured by the windowed scale indices.
In contrast, the windowed scale indices for gold futures contracts do not take generally high values despite the fact that during the global financial crisis period, there were also significant changes in the energies contributed by most of the scales, as depicted in plot (c) of Figure 8. This result indicates a more predictable behaviour of the price of gold for all time scales over the last few decades in comparison with oil prices. One possible explanation for this finding is related to the fact that gold price has followed a secular upward trend, which has been only interrupted sporadically and for very short periods of time. In this regard, unlike conventional financial assets such as stocks or bonds, gold price tends to increase notably even during periods of increased economic uncertainty, such as the global financial crisis that started in 2008 or the COVID-19 pandemic since March 2020. Therefore, the safe haven nature of gold, particularly in times of market turbulence, seem to play a key role in its more predictable (periodic) behaviour compared to that of crude oil over the past few decades.
Apart from the case of these two major commodities, there may be many other potentially meaningful applications of the windowed scale index in economics and finance. For example, it could be very interesting to assess the degree of unpredictability of the cryptocurrency market, paying special attention to the main cryptocurrencies, including bitcoin, ripple and ethereum. The analysis of the regularity of price fluctuations in currency markets appears as another promising application of the new wavelet-based tool in order to identify the particular exchange rates which exhibit a more irregular behaviour. In the same vein, the windowed scale index could be also used to measure the level of unpredictability or randomness of some conventional financial markets such as stock or bond markets. Given the huge total market capitalization of these traditional markets, this knowledge will have important practical implications for investors and policy makers.

Non-Periodicity and Unpredictability
So far, we have showed how the windowed scale index can be used to assess the degree of non-periodicity of a time series over time and thus it has been proven useful for determining shifts in the periodicity regime. Since periodicity and predictability represent closely related concepts, it seems reasonable to compare the windowed scale index with a standard measure of the level of unpredictability of a time series.
The sample entropy (SampEn) [2] is a measure of the signal's complexity and ultimately of its unpredictability, in the sense that the higher the SampEn is, the more unpredictable the signal will be. In essence, the SampEn is a modification of the approximate entropy (AppEn) [1], which was designed to measure the unpredictability of time series, but it overcomes some of the limitations of the AppEn, such as the signal length dependence. Both measures are based on the Kolmogorov-Sinai statistic [32] and have been mainly used in the analysis of biomedical data (e.g., EEG signals). Similarly, the scale index (global or windowed) may also be seen as a measure of a time series unpredictability in so far as the degree of non-periodicity intuitively gives us an insight into how the future values of a signal may be predicted from the past ones.
In order to compare the SampEn with the windowed scale index, the sample entropies are computed on a rolling window of the same radius as the one employed for the windowed scale indices estimation. The computations are performed using the R statistical software and the SampEn functions provided by the package pracma [33]. For the artificial signals generated by the Bonhoeffer-van der Pol chaotic dynamical system, Figure 9 depicts the sample entropies for a rolling window of radius τ = 50 observations and the global SampEn calculated for the whole signal. Although the overall value of the SampEn is slightly higher for time series 2, which corresponds to a more chaotic signal than time series 1, the difference is so small that it can be considered negligible. By contrast, when comparing Figure 9 with Figure 5, it can be seen that the windowed scale index is able to clearly distinguish between different degrees of chaos or non-periodicities. Likewise, the sample entropies are estimated for the crude oil and gold futures contracts in Figure 10, plots (a) and (b), using a rolling window of radius τ = 300 days. The global SampEn for the oil futures contracts series yields overall higher values than for the gold futures contracts (dashed lines), but the differences are again very small. On the other hand, the sample entropies estimated on a rolling window (solid line) take, for certain time intervals, larger values for the crude oil futures than for the gold futures contracts, and vice versa. In order to compare with the windowed scale index, in Figure 10, plots (c) and (d), we also show the sections at s 1 = 256 days (a scale representative of the medium term) of the windowed scale indices plots of Figure 8, in which a time radius of τ = 300 days was also employed. Moreover, the corresponding global scale index is represented by a dashed line. It can be seen that the windowed scale indices of crude oil futures contracts increase considerably during the global financial crisis, unlike what happens with the gold futures contracts. Besides, the global scale index of the gold futures contracts is slightly greater than the global scale index of the crude oil futures contracts, showing that in this case, the windowed scale index provides more reliable and detailed information than the global scale index.
Therefore, according to this example, the windowed scale index has demonstrated to be a valuable tool for the analysis of the level of unpredictability since it is able to detect changes in the time series that go unnoticed for other tools such as the SampEn. In essence, the windowed scale index presents two major advantages over the SampEn and the AppEn. The first one is about the interpretability. Specifically, the windowed scale index takes values between 0 and 1 and this boundedness allows us to clearly state how non-periodic a time series is. Meanwhile, the SampEn and AppEn are not bounded, so it is harder to say whether a given entropy value is high or low and, consequently, whether a given time series is highly unpredictable or not. A second advantage of the windowed scale index over the entropy parameters is its sensitivity. In particular, the windowed scale index presents a higher sensitivity to distinguish between different levels of non-periodicity. For instance, while the windowed scale index is able to clearly identify that time series 1 in the BvP oscillator example is much less non-periodic than time series 2, the SampEn values are almost identical.

Conclusions
The scale index proposed by [5] has proved to be a helpful wavelet tool to assess the degree of non-periodicity of a time series. This usefulness is based on the result according to which the wavelet transform of a periodic time series vanishes when the scale is twice the period. From a theoretical point of view, it is very interesting to study whether the converse is true or not. In this paper, it is shown that, at least for the Haar wavelet, the vanishing of the wavelet transform at a certain scale (for all times) guarantees the periodic character of the time series.
The windowed scale index introduced in this paper has its origin in the scale index and is particularly adequate to measure the degree of non-periodicity of non-stationary signals, whose characteristics may vary over time. Moreover, the use of the windowed scale index as a measure of unpredictability has advantages in terms of interpretability and sensitivity over some standard unpredictability measures such as the SampEn or the AppEn. Furthermore, in order to facilitate the use of this and other related wavelet-based tools, we have developed an R package named wavScalogram [25], which provides researchers unfamiliar with wavelet analysis a user-friendly framework for identifying the non-periodicity characteristics of time series. This paper also includes an economic application of this novel wavelet tool in which the level of unpredictability of two crucial commodities for the world economy, such as crude oil and gold, is quantified. The results reveal that oil futures contracts exhibit a higher degree of non-periodicity than gold futures contracts, particularly in the medium term during the period around the global financial crisis. One possible explanation for the greater unpredictability of oil is related to the abrupt fluctuations in crude oil prices caused by positive and negative changes in global aggregate demand since 2007. However, the more predictable behaviour of the price of gold regardless of the specific time interval and scale can be attributed to its secular upward trend, which can be seen as a consequence of the traditional consideration of gold as a safe haven asset, especially during episodes of financial turmoil.
Given the steady growth in the number of research articles and fields of knowledge that have applied the scale index over the last few years, we strongly believe that the windowed scale index has a great potential to be widely used in future work. On the one hand, this tool can be particularly useful in numerous scientific disciplines, such as physics, seismology, climatology, medicine or engineering, to shed more light on the non-periodicity features of non-stationary signals or time series. For example, the windowed scale index can play a critical role in the field of pseudo random number generators (PRNG), not only to assess the degree of non-periodicity of the PRNG, but also to check for stationarity, which could be a relevant indicator of the goodness of the algorithm. On the other hand, the windowed scale index also has a high applicability in the area of economics and finance. For instance, the proper identification of the level of unpredictability of several major financial markets, such as the exchange rate, stock or cryptocurrency markets, can have valuable economic implications for investors, portfolio managers and policy makers. In addition, the wavelet tools proposed in this paper can be of interest for anyone working with long enough time series, such as those typically handled by national and international statistical institutions.