New DTW Windows Type for Forward- and Backward-Lookingness Examination. Application for Inflation Expectation

This study provides an application of dynamic time warping algorithm with a new window constraint to assess consumer expectations’ information content regarding current and future inflation. Our study’s contribution is the novel application of DTW for testing expectations’ forward-lookingness. Additionally, we modify the algorithm to adjust it for a specific question on the information content of our data. The DTW overcomes constraints of the standard tool that examines forward-lookingness: DTW does not impose assumptions on time series properties. In empirical study we cover seven European counties and compare the DTW outcomes with the results of previous studies in these economies using a standard methodology. The research period covers 2001 to mid-2018. Application of DTW provides information on the degree of expectations’ forward-lookingness. The result, after standardization, are similar to the standard parameters of hybrid specification of expectations. Moreover, the rankings of most forward-looking consumers are replicated. Our results confirm the economic intuition, and they do not contradict previous studies.


Introduction
This study investigates consumer inflation expectations' forward-lookingness using a dynamic time warping (DTW) algorithm. Expectations are private agents believes regarding economic situation. Their formation and properties are the centre of 1 3 interest for central banks. They are the driving force of transmission of central bank signals into economic results (Woodford 2003). During the post-crisis era of low inflation, expectations play an even more important role as the standard interest rate transmission remains ineffective. Numerous studies investigate whether the properties of expectations have changed since the Great Recession and their implications for policymakers (Ehrmann 2014;Łyziak and Mackiewicz-Łyziak 2014;Łyziak and Paloviita 2018).
When non-specialists form their expectations about inflation, they may consider past inflation only or forecast inflation on the basis on numerous forward-looking factors. The notion of forward-lookingness is closely related to rationality of expectations. The rational expectation hypothesis was introduced to economics by J.F. Muth (1961). It gained recognition after a seminal papers by R.E Lucas (Lucas 1972(Lucas , 1976 and brought the revolution in macroeconomics. The rational expectations hypothesis is by far the most common assumption applied in macroeconomic modelling and analysis. This remains true regardless the obvious empirical evidence that the hypothesis does not hold.
The simplest description of the rational expectations hypothesis states that economic agents expectations are the same as the forecasts of the model being used to describe economy. The model reflects adequately economic system and relations. Consequently, private forecasts are, on an average, equal to realization of the variable. The intuition behind the hypothesis is far away from econometrical approach to incorporation of past values in forecasting. The rational expectations story is that economic agents, including consumers, could ignore past information about inflation and refer only to the value of future inflation. They are believed to know economic model as well as policy makers do. There is no need to stick to past inflation values while express their forecasts. The rational expectations are thus fully forward-looking -focused on the future, and equal, on an average, to actual inflation realization. Backward-looking expectations remains in opposition to rationality: they stick to past inflation. Information content of expectations:-forward-or backward-looking is a primary concern of our study. Having in mind that that description holds some simplification, we refer to the former approach as to forward-looking expectations and we call the latter-backward-looking.
Unlike existing literature, our study is firstly methodological. We propose an alternative method for assessing the degree of expectations' forward-lookingness. Our search for a novel solution is motivated by the shortcomings of the existing approaches. The standard procedure estimates hybrid specification of expectations following economic theory and intuition about the information content of private forecasts. However, its application can be questioned due to the properties characteristics of the time series (expectations are quite often non-stationary) and the results' robustness (they are estimator-dependent and react strongly to small adjustments in the research period).
With the findings of previous studies, our own experience with hybrid specification estimations, and the topic's relevance to central banks in mind, we have decided to apply an alternative approach-dynamic time warping (DTW) to assess the degree of expectations' forward-lookingness. The DTW technique originates from speech recognition where it founds numerous applications (Itakura 1975;Myers et al. 1980;Rabiner and Juang 1993;Rabiner et al. 1978;Sakoe and Chiba 1978;Benkabou et al. 2018). In time series analysis, DTW is an non-parametric technique for measuring the similarity or distance between two temporal sequences which may vary in time or speed. DTW application in economics is rare despite its advantages: it does not impose assumptions on the time series properties or the lag structure. To our best knowledge, few examples of DTW application for economic analysis are available in the literature. DTW was used to detect recessions (Raihan 2017) and clustering of business cycles (Franses and Wiemann 2018), similarity networks among 35 currencies in international foreign exchange markets (Wang et al. 2012), and commodity prices' co-movements (Śmiech 2015). Arribas-Gil and Müller (2014) present a pairwise dynamic time warping and show its application opportunities to online auction data.
Apart from a methodological contribution to the research on expectations, our study provides an alternative understanding of forward-lookingness (FL) and backward-lookingness (BL) of expectations as DTW allows for different perspectives while searching for similarities in time series. We compare our findings using theoretical approaches to forward-and backward-looking expectations with the results using modified assumptions about horizons of information incorporated. The DTW algorithm provides both: a distance measure that is insensitive to local compression and stretches and the warping, which optimally deforms one of the two input series onto the other. DTW solves the problem of local time shifting in time series. Thus, it does not assume constancy of delays over time.
This paper offers a practical solution but is not about proposing a new forecasting method. As expectations are forecasts by non-specialists, we do not wish to forecast forecasts. We would like to assess their properties in a proper way. From the policy-maker point of view, the value added arising from the recognition of expectations FL and BL is far enough for policy analysis purposes, inc. inflation modelling. It allows for determining inflation equation (new-Keynesian Phillips curve or its hybrid specification) that better replicates empirical evolution of inflation. It could be useful for calibrating parameters of inflation equation.
The summary of the value added of our paper is as follows: we build up on an existing literature on the assessment of expectations properties. This methodological novelty is extended by the provision of an alternative understanding of forward-and backward-lookingness. Moreover, we offer the modification of DTW algorithm that allows for tackling this specific problem.
Our sample covers consumer expectations derived from the European Business and Consumer Surveys held under the auspices of European Commission. We present DTW for seven monetary areas: Croatia, the Czech Republic, Hungary, Poland, Romania, Sweden, and the UK. This sample covers economies for whom we conducted previous examinations using standard methodology. Thus, we are able to compare the DTW results with our previous findings and that of the others. Apart from our need for comparing results, we find that the economies that we cover function within the European Union monetary policy (price stability as priority, high degree of central bank independence). The research period covers 2001 to mid-2018.

3
The rest of the paper proceeds as follows. Section 2 presents the materials and methods. In this section we briefly outline the standard methodology that estimates the degree of expectations' FL and the DTW technique, in detail. The next section describes the results for both versions of the algorithm and juxtaposes them with the standard estimations of FL. The last section provides the conclusions.

Standard Estimations of the Degree of Expectations for Forward-Lookingness
The state-of the-art in the field of this examination is not referred to theoretical understanding of expectation but to the methodology of their properties examinations. We describe the standard procedure that returns the degree of forward-lookingness to highlight its drawbacks and provide the background for the comparison of our results with findings from previous studies. Once the rationality of expectations is rejected (what means that expectations are not unbiased predictors of inflation), the search for their hybrid specification of expectation is legitimated. With hybrid specification we can then consider the extent to which expectations are forwardlooking and backward-looking. The search for hybrid specification of expectations reflects theoretical models of expectations formation. The forward-looking component of expectations is identified using the rational expectations and the backwardlooking component is identified using adaptive (Eq. 1) or static (Eq. 2) expectations. The specifications of the hybrid nature of expectations involves estimation of Eq. 1 or Eq. 2.
where e t+12|t is the expected inflation rate at time t + 12 formed at time t, t+12 is the actual inflation at t + 12 (analogous meaning of other subindices), t is the white noise error.
For both equations, if 1 = 0 and 2 = 1 , the expectations are fully forwardlooking. Standard specification imposes a certain, constant structure of lags. This is reflected in the subindices of our equations. T + 12 months horizon of expectations relates to the survey questions: consumers are asked about their estimates of price level within the next 12 months. Expectations are juxtaposed with actual inflation in one year horizon and past inflation. Past inflation from two months before the survey is considered ( t − 2 ) as this is the latest inflation available for consumers. If we use June survey as an example, responders could be aware of April inflation (published end May). Moreover, consumers need time to process economic information. Two months lag is the shortest that seams justified. (1) New DTW Windows Type for Forward-and Backward-Lookingness… Equation (1) presents adaptive hypothesis of expectations in its backward-looking part. It assumes that responders refer to past expectations errors (expectations made 14 months ago could be compared with 2 months lagged inflation -latest figure not available). The adaptive specification hypothesis relates expectations to their past values and is corrected by past expectation errors. Additionally, Eq. 1 incorporates the possible impact of a change in the current inflation on inflation expectations.
Second specification (Eq. (2)) reflects more strictly thinking about forward-and backward-lookingness in terms of the distance. This is a static specification -backward-looking part of the equation-relates only to the latest past inflation. This is why compare our results with this specification.
We identify forward-lookingness with the rationality of expectations, knowing that this is only a simplification, as rationality provides much more meaning that just unbiasedness. The above mentioned specifications are broadly used in empirical examinations to assess the degree of expectations of forward-lookingness (Carlson and Valev 2002;Gerberding 2001;Heinemann and Ullrich 2006;Łyziak 2013;Łyziak and Mackiewicz-Łyziak 2014). The authors provide estimations of both, adaptive and static specifications and then interpret the equation with a better goodness-to-fit.
This simple and theory-related procedure is suitable for a stationary time series; however, expectations are not always expressed as a stationary time series. Usually, stationarity is not discussed and tests for unit root presence are not delivered; this is the case of the majority of papers cited above. This means that the time series properties are neglected. This approach is supported by some studies that acknowledge that while dealing with expectations properties, namely their rationality, stationary structure of the time series over some medium horizon may be assumed. The advocates of such approaches claim that producing unbiased expectations in a non-stationary environment would, in many circumstances, be an implausibly demanding task (Evans and Gulamani 1984). Moreover, even if tests of expectation properties for a non-stationary environment exist, they remain almost unused in examinations that aim at delivering economic interpretations and implications as opposed to a methodological solution.
Short of ignoring some assumptions for time series properties, once one decides to test the degree of expectations forward-lookingness using standard tools, a decision on estimators must be made. Owing to the endogeneity problem, the ordinary least square (OLS) method is inconsistent. Hence, instrumental-variables regression (the two-stage least squares (2SLS) estimation method) could be applied. However, the IV estimator is imprecise (large standard error), biased when the sample size is small, and biased in large samples if one of the assumptions is only slightly violated (Martens et al. 2006). Moreover, choosing the right instrument is crucial. To justify the validity of an instrument, one needs to show that it is correlated with the endogenous independent variable, but not with the residual, which is often not trivial. Numerous papers discuss weak instruments and their consequences (Hahn et al. 2004;Staiger and Stock 1994;Stock and Wright 2000). The choice of an estimator is, to some extent, arbitrary and it affects the results.

Dynamic Time Warping Algorithm
A fundamental task in time series analysis is to quantify the similarity (or dissimilarity) between two numerical sequences. The method used to measure the distance is key for the performance of many data mining jobs such as, classification, clustering and retrieval. Considering the time series in an economic context, conventional distance measures such as Euclidean distance, are often not suitable, because time shifts or time distortions exist are common and unpredictable. On the other hand, classical econometric methods usually do not easily adhere to assumptions regarding the distribution of variables and stations, which is the case of hybrid specification of expectations estimations. The DTW is, as the name suggests, align-based. The goal of the algorithm is to find an optimal alignment between two time series. By optimal alignment we understand that it achieves the minimum global cost (distance) while ensuring time continuity. The global cost is the summation of the cost between each pair of points in the alignment. The comparison of the traditional Euclidean distance based and DTW based approach is shown in Fig. 1.
Let assume that we want to compare two time series: a test/query X = (x 1 , x 2 , … , x N ) of the length N and a reference Y = (y 1 , y 2 , … , y M ) of length M. We choose a non-negative, local dissimilarity function f between any pair of elements x i and y j : is small (i.e. low cost) if x i and y j are similar to each other, else d(i, j) is large (i.e. high cost). The most commonly used functions are the Euclidean and Manhattan distances. When employing one of the distance functions, the local cost measure for each pair of elements of the sequences X and Y are evaluated and presented in a cost matrix C ∈ R N+M . A warping path is a contiguous set of matrix elements that defines a mapping between the time indices of X and Y that satisfies the following conditions: • The boundary condition: 1 = (1, 1) and T = (N, M) , which ensures that the first elements of X and Y as well as the last elements of X and Y are aligned to each other. New DTW Windows Type for Forward-and Backward-Lookingness… • The monotonicity condition: ∀ i i = (r, c), i+1 = (r � , c � ) ⇒ r � ≥ r and c ′ ≥ c , reflects the requirement of faithful timing: If an element in X precedes a second element from X this should also hold for the corresponding elements in Y, and vice versa. • The continuity condition: ∀ i i = (r, c) and i+1 = (r � , c � ) ⇒ r − r � ≤ 1 and c − c � ≤ 1 , which means that no element in X and Y can be omitted and there are no replications in the alignment.
Given , the total cost d and the average normalized accumulated cost d between the warped time series X and Y is computed as follows: where m is a per-step weighting coefficient and M is the corresponding normalization constant. To determine an optimal path DTW and avoid an exponential computational complexity, we use dynamic programming. The cumulative cost matrix D satisfies the following identities: The goal is to find an alignment between X and Y having a minimal average accumulated cost.
The optimal path is computed in the reverse order of the indices, starting with (N, M). Intuitively, such an optimal alignment runs along a "valley" of low cost within the cost matrix C (Müller 2007). The density plot of the cost matrix with optimal warping is presented in Fig. 2 and the algorithm pseudocode is given below.  2018)). One common DTW variant is to impose global constraint conditions. A global constraint, or window, forbids warping curves from entering a given region of the (i, j) plane.
where T 0 is the maximum allowable absolute time deviation between the two matched elements. The two most commonly used global constraint regions are the Sakoe-Chiba band (Sakoe and Chiba 1978) and the Itakura parallelogram (Itakura 1975), as shown in Fig. 3. The alignments of cells cannot be selected from the whole matrix, but rather only from the white area. In our study, we also impose New DTW Windows Type for Forward-and Backward-Lookingness… constraints on windowing to obtain two versions of the degree of forward-lookingness assessment.

DTW for Testing Expectations Forward-Lookingness
As mentioned earlier, windowing constraints limit the number of points that each point can link to. It is an intuitive solution to the pathological alignment problem and it speeds-up the algorithm. In our study, it plays also a significant role in economic interpretation.
Forward-vs backward-lookingness. The windowing application provides the possibility to modify the notions of forward-and backward-lookingness. The classic approach to hybrid specification of expectations, wherein backward-looking expectations are related to the latest inflation figure known for consumers (Eq. 2). Thus, the algorithm assesses the Euclidean distance between expectations and past inflation and the distance between expectations and future inflation and compares them both. It is purely related to a theoretical understanding of static and rational expectations. It simply checks the distance of expectations to the most recent inflation and the distance of expectations and inflation realisation 12 months ahead.
The new presented alternative approach provide an intuitive meaning of the forward and backward-lookingness of expectations. This diverges from the standard, theory-related understanding of formation of expectations. Thus, in this alternative specification, the forward-looking component cannot be identified with rational expectations, and the backward-looking expectation cannot be identified with the static specification of expectations. We allow consumers to consider any past or forecasted value of inflation even if they miss the exact, theory-related horizons. This approach is especially applicable for consumers as they are unqualified economic agents. Their limited awareness of economic conditions is even reflected in how their expectations are examined (briefly discussed in the next section). Thus, our main assumption, which differentiates this study from existing works is that we define expectation as forward-looking, when in the case of their formulation, consumers refer to any future inflation and as backward-when they formulate expectations based on the value of inflation from the past.
DTW windowing for the forward and backward-lookingness From algorithmic point of view, the above mentioned modification of BL and FL definition cause, that we do not compare the value of expectations to one specific lag, as in Eqs. 1-2. If the consumers formulate expectations based on inflation from the past, regardless of whether it occurred two (which is a classic static specification of expectations), three or even four months ago, then they are backward-looking. Therefore, to measure the level of forward-lookingness, we search the warping path only within the upper triangular cost matrix. Similarly, to measure the level of backward-lookingness, we use the lower triangular cost matrix. As we can see on Fig. 4 on left panel, with such restricted area the algorithm look for the shortest path only in area of points in time that comes after a i − th point in x set. So we can say that it is forward looking. On right panel we see lower triangular windows, so the area of acceptable solutions is always associated with points occurring earlier in time than the given point. We connect x points with different delays by points from y, that is the situation which is called backward looking.
The pseudocode for the algorithm that incorporates windowing constraints for alternative specification of forward-and backward-lookingness is shown below. We present and interpret the results for both specifications: theory-related and with relaxed assumptions on the relation in time of the time series.

3
New DTW Windows Type for Forward-and Backward-Lookingness…

Empirical Study
This section presents our sample and the empirical results for the standard and alternative understanding of FL. We also compare our results with the estimations of hybrid specification of expectations.

Data
Our sample covers Croatia, the Czech Republic, Hungary, Poland, Romania, Sweden and the UK for the period of 2001 to mid-2018. Evaluation data of this study are consumer inflation expectations. We derive them from European Business and Consumer Survey held under the auspices of European Commission. Regular monthly harmonised surveys are conducted by the Directorate General for Economic and Financial Affairs in the European Union and in the applicant countries. Our sample is thus covered by methodologically consistent survey. The survey questions and methodology are presented in a guidebook (European Commision (2020)).

Fig. 4 New forward and backward windows type
Consumer expectations are examined in qualitative surveys-responders express their opinion about the direction of inflation change in the future. Their responses are quantified. Carlson and Parkin (1975) probability method, in its modified version adjusted to Batchelor and Orr (1988) five-question survey is applied to quantify consumer expectations. This is the most commonly applied procedure which transforms consumers qualitative assessments of perceived and expected price level change into quantified inflation expectations. In this examination, we first quantify consumers' inflation perception and then use a perceived inflation rate as a scaling factor of expectations quantification (subjectified version of quantification). 'Normal level of inflation' is represented by 36M moving average of inflation (scaling factor for question on perceived inflation). Inflation rates used are official statistical offices figures. For each economy we obtained 210 monthly observations (pair: expectations-inflation). The raw data are presented on Fig. 5.

Results
Before we present the aggregate results of our study, an illustrative example of two subperiods between June 2008 and December 2010 for the United Kingdom is shown (see Fig. 6). During the first 15 months expectation were clearly more forward-looking. The distance between expectation and inflation was the shortest for future inflation (the curve that represents inflation was visibly shifted to the right). Since August 2009 (the sixteenth month of this subsample) inflation was visibly shifted to the left in relation to expectations. Expectations were mostly shaped by past inflation, and so they were backward-looking. Theses relations are confirmed by distances measure: in the first subperiod (1-15 months) normalised FL distance is 0.3863 while BL distance is almost two times higher: 0.6137. During the second subperiod (16-30 months) FL distance is 0.68472 and BL is 0.3153. Thus for the first subsample expectations are closer to future inflation (FL), in the case of the second one-to past inflation (BL), which confirms the intuitive understanding of the graph.
Full sample results. First, we present the distance results between the tested series based on the assumptions and measures. Then, we present the results of forwardlookingness estimations for our sample, and we compare them to existing results. Distance and normalized distance estimations for our sample are presented in Table 1.
First, Euclidean distance between expectation and inflation one year ahead, followed by the Euclidean distance between expected inflation and its latest realisation, represent theory-related approach to forward-and backward-lookingness. Time series shifts are imposed to mimic the hybrid specification of expectations. Second, we present the DTW distance with forward and backward window constraints (DTW: one direction-constrained version without lags). Finally, as a reference point, we present the standard DTW distance without constraints. Longer time series have naturally higher total distances, which makes a direct comparison impossible. Analogous to total distance result presentation, we begin with Euclidean distance results, the DTW constrained results, and finally-we show the DTW results. In each case, the standard DTW algorithm returns the shortest distance. This confirms that expectations are neither fully forward-nor backward-oriented, and their formation pattern changes over time. The distances measured by DTW with windows (forwardor backward-looking) are also smaller than those obtained using the theory-related approach, because they are allowed to consider different shifts. The common point of our results is that the forward-looking distance exceeds the backward-looking distance for consumers expectations regardless of the country.
This result confirms suggestions arising from standard hybrid specifications of expectations: backward-looking is far more prominent among consumers than forward-looking. To compare our results with examinations applying standard methodology, we provide the forward DTW distance in terms of FL coefficients. We apply an analogous notation of 2 to express the degree of expectations forward-lookingness: The coefficients of forward-and backward-lookingness, similar to the standard approach presented in Eq. 2, sum to 1. Table 2 lists the ranking of consumers FL in decreasing order.

3
The results returned by the DTW algorithm and their modifications largely confirm the previous results obtained using the standard methodology. Our coefficients cannot be compared to 2 in terms of levels. Hence, we provided a ranking of countries according to consumers FL and refrain from direct juxtaposition of the degrees of forward-lookingness obtained using the standard procedure and ours. Nonetheless, we can point out some common points of previous research. Firstly, similar to   Clinton et al. (2017). Thus, the Czech consumers ranking second in our results was expected and confirms previous findings. Fourthly, consumer expectations in advanced economies are generally more FL compared to transition economies. This is not the case with our study as Czech and Polish consumers outperform Swedish consumers in terms of their FL. With the caveats related to our methodology and the comparability to other studies' results in mind, we summarize that DTW returns promising results, allowing for an international comparison of expectations' forward-and backward-lookingness.

Conclusion
The study aimed at investigating consumer expectations' forward-lookingness by applying a dynamic time warping algorithm and its modifications. Our goal was mainly methodological: we searched for a method that would overcome the disadvantages of standard methodology applied to capture the degree of expectations' FL.
With the results of standard estimations as a possible robustness check, we produced a ranking of consumers' FL for seven economies. Our rankings replicate, to a large extent, the findings of the standard methodology. Additionally, we extended a theory-related understanding of forward-and backward-looking expectations formation allowing for more intuitive lag shifts between the time series (expectations, past inflation, and inflation realization). Relaxed assumptions on the horizons to which economic agents refer is especially applicable for consumers who are the least qualified group of economic agents. We found the DTW an interesting tool to detect the degree of expectations' FL. Its main advantages-lack of assumption about time series properties and time relation of considered variables-should be highlighted once again. Through the DTW application, we avoided the objections that could be formulated toward a standard methodology examination which ignores the properties of time series. We also note that the majority of authors presenting results on expectations rationality and the degree of their FL reject econometric appropriateness of their estimations, if in favour of the results' interpretations. This approach could be justified to some extent. However, a search for more adequate methods is quite necessary. While discussing our results we need to bear two caveats in mind. As the DTW is algorithm-based we cannot estimate statistical significance of numbers that represent forward-and backward-lookingness. It seems obvious when algorithms involved: they measure distance thus, analogously to distances in space, there is no need to check whether the distance is significant. Lack of statistical significance measure may be questioned by econometricians that are used to estimations of parameters. The second caveat we need to make is about proxies of expectations that we applied in this study. Survey-based expectations quantified with Carlson and Parkin probabilistic approach do not avoid the original sin of this method. Criticism towards probabilistic approach spreads in economic literature (Lahiri and Zhao 2015;Lolić and Sorić 2018) and we are aware of it. No broadly accepted alternative of quantification has appeared up to now. The most innovative proposals move verification of expectations or studies on their formation to laboratory (Becker et al. 2009;Cornand and Hubert 2020). The other extreme is that some authors avoid quantification and use balance statistics or fraction of responses (Acedański and Włodarczyk 2016). We are not ready for the former, the latter is not enough for our study. Thus we decided to apply standard and well recognised quantification procedure being aware of its drawbacks.
Finally, we should examine further application of DTW for analysing the properties of expectations. The next step can be imposing local weights to favour the vertical, horizontal, or diagonal direction in the alignment; one can introduce an additional weight vector (w d , w h , w v ) ∈ R 3 , yielding the modified recursion. In the application under consideration, it can be a preference of the horizontal alignment direction. The second interesting development could be using the DTW on moving subsequence. Such research will allow to determine the moment of the expectations changing from forward to backward-lookingness, and vice versa. It would also help us check whether this was related to economic events or the activities of central banks.
Funding This work was supported by the National Science Centre, Poland the grant No. 2018/31/B/ HS4/00164. Availability of data and material Data used in empirical study available on https ://githu b.com/rutko wskaa /DTWfo rInfl ation Expec tatio n