Extracted main text — title through conclusion, appendix excluded. This is what our citation measures are computed over, published so the extraction can be checked by eye.
35,235 characters · 11 sections · 2 citation commands
Clustering Macroeconomic Time Series
\renewcommand \BBAB &
The algorithms for clustering similar time series or, more generally, similar high-dimensional sequences, are important in areas as diverse as biomedicine, computational biology, electronic manufacturing, physics, seismology and speech recognition.
Econometrics could also benefit from a vast research effort made in these and other areas. For example, according to \shortciteA{focardi_clustering_2004}, clustering of economic and financial time series includes the following areas of application:
For studies in macroeconomics, one of the most promising advantages of time series clustering is its ability to identify structural similarities in the processes that generate time series at different points in time and space. This method also allows for presentation of results in the form of easy-to-understand dendrograms.
The aim of this paper is to find the most appropriate dissimilarity measure for macroeconomic clustering analysis.
The problem of time series similarity could be boiled down to measurement of the co-movement of macroeconomic aggregates. The most popular approaches to this issue are croux_measure_2001,haan_will_2005:
According to \shortciteA{croux_measure_2001}, these concepts pose several problems. First, correlations might be detected where no correlation is present. Second, high cross-correlation neither implies nor is implied by cointegration, common cycles, or common features. Third, these three measures are binary. For example, two processes are either cointegrated or not, but different degrees of association cannot be established. Tests such as the Johansen test, performed by commercial econometric packages, consist of fitting empirical data to cointegrated models such as Error Correcting Models (ECM). In the case of a large number of time series, cointegration is a rather cumbersome exploratory methodology.
The contribution of the present paper to the literature is as follows:
The remainder of this paper is organized as follows: in (ref) we evaluate available dissimilarity measures and propose CDM (compression-based dissimilarity measure) as a solution for clustering of the macroeconomic time series. In (ref) we check the robustness of the presented methodology by applying the proposed clustering method and comparing created clusters with the literature. Finally, in (ref) we present concluding remarks.
All figures are the results of own calculations based on R package TSclust and Eurostat data (namq_10_gdp dataset).
A well-known data mining technique, clustering is an example of unsupervised learning: a clustering algorithm creates clusters as a function of its internal rules (whereas in supervised learning the algorithm learns from “known” examples). The objective of clustering is to create groups of objects that are close to each other and distant from other groups of objects. If distance corresponds to similarity, clustering forms groups of objects that are maximally similar.
A dissimilarity measure suitable for our applications could be informally described as attaining low values for pairs of time series that exhibit a causal relationship. This property is hard, if not outright impossible, to formulate in rigorous terms, but it can be approximated well enough by demanding that the measure is insensitive to translating the series in time. Importantly, it should be sensitive to other time transforms, including warping (acceleration), whether uniform or not. Conversely, other kinds of transforms, such as scaling the values by a constant, adding a constant to the values, or adding noise to the values, should not, in principle, affect the measure much.
We can apply this observation to design an experiment to identify prospective measures. For a given time series, we can compute the distance separating it from its delayed copy (i.e.\ a series with the same data, but shifted in time), as well as the distance separating it from its warped copy (i.e.\ a series with the same data, but squeezed in time). The ratio of these distances is a measure of how well a dissimilarity measure performs. We are looking for a measure that performs well for as many as possible time series, delays, and warp factors. Furthermore, this should hold true even if the delayed copy of the series is additionally subjected to perturbations such as scaling, shifting, noise, or a combination thereof.
To formalize the idea, we fix a time series $X=\{X_i\}_{i=1}^T$, dissimilarity measure $M$, delay $\delta\in\mathbb{N}$, and warp factor $\alpha\in\mathbb{R}$. We call the subseries $B[X;\alpha]=\{X_i\}_{i=1}^{\lfloor T/\alpha\rfloor}$ and $D[X;\alpha,\delta]=\{X_i\}_{i=1+\delta}^{\lfloor T/\alpha\rfloor+\delta}$ respectively the base and delayed series. We also obtain from $X$ the warped series $W[X;\alpha]=\{\bar X^{(\alpha)}_i\}_{i=1}^{\lfloor T/\alpha\rfloor}$ by taking averages of every $\alpha$ consecutive elements, trivially extending the notion for non-integer $\alpha$. Strictly speaking, $\bar X^{(\alpha)}_i=\frac1\alpha\sum_{j=1}^T w_{ij}^{(\alpha)} X_j$, where
Let $d_M(\cdot,\cdot)$ be the distance between two time series under the measure $M$. We will use the ratio $R(M,X,\delta,\alpha)=\frac{d_M(B[X;\alpha],\tilde D[X;\alpha,\delta])}{d_M(B[X;\alpha],W[X;\alpha])}$ as a quality indicator, where $\tilde D[X;\alpha,\delta]$ is $D[X;\alpha,\delta]$ with perturbation applied. Note that $X$ is truncated to its prefix $B[X;\alpha]$ for calculating $R$ to fulfill a requirement of many of the measures that the series compared be of the same length.
Note that while the values of distances under different dissimilarity measures are not directly comparable to one another (as different measures may e.g.\ attain values in different ranges), ratios such as $R$ are. Note also that if a measure is good, that is, in general it separates warped series more than the delayed series, its values of $R$ will be in general (or, ideally, always) less than 1. Note finally that a dissimilarity measure is better than another if its values of $R$ are in general smaller.
In our computations, we consider all dissimilarity measures provided by the R package TSdist, which, for the sake of simplicity and avoiding potential cognitive bias, may be calculated without supplying extra parameters. This is possible either thanks to their absence, or default values, or heuristics. These 24 measures are (referred to by names used within TSdist): euclidean, manhattan, infnorm, ccor, sts, dtw, \texttt{fourier}, \texttt{acf}, \texttt{pacf}, \texttt{ar.lpc.ceps}, \texttt{ar.mah.statistic}, \texttt{ar.pic}, \texttt{cdm}, \texttt{cid}, \texttt{cor}, \texttt{cort}, \texttt{wav}, \texttt{int.per}, \texttt{per}, \texttt{ncd}, \texttt{spec.glk}, \texttt{spec.isd}, \texttt{spec.llr}, and \texttt{pdc}.
Furthermore, we consider warp factors $\alpha$ between 1.4 and 3.0 inclusive in steps of 0.2, and delays $\Delta$ of 2 through 10 quarters. Note that for series with quarterly data, the delay in terms of data points is $\delta=\Delta$, while for monthly data it is $\delta=3\Delta$.
We also consider separately two different sets of time series, along with perturbations specific for each set. The first set contains 52 time series of absolute-valued data:
The following perturbations were applied to the delayed copies of the series from this set in distinct computation runs:
The second set contains 45 time series of quarter-to-quarter percentage changes of the same quantities as in the first set, except the three artificial modifications of the UK GDP, as well as four of the UK GDP components for which the percentage data is not available (i.e.\ compensation of employees, taxes on production and imports less subsidies, changes in inventories and acquisitions less disposals of valuables, and operating surplus and mixed income, gross). Also, the four artificial (sine and triangular wave) series are not converted to percentage changes, but (with different value ranges) treated as percentage change series in their own right. Given the different nature of the data in this set, we deem the perturbations of scaling and shifting inapplicable here, and computations are performed in two runs (without perturbations and with random noise, not adjusted for standard deviation in this case).
In each of the seven runs, ratios $R$ are computed for all possible combinations of measures, warp factors, delays, and time series.
Examining the results of all seven computation runs, we have primarily focused on the following quantities:
Based on this, we arrive at the conclusion that cdm is the overall best performing measure. Specifically (see also (ref)):
Another criterion that could be sensibly used here is the count of how often the ratios for a given measure exceed 1. Admittedly, with perturbations present, cdm does not perform well in this aspect. However, precisely in the presence of perturbations this requirement can be argued to be too restrictive: the delayed and perturbed series can be informally considered as at a disadvantage compared to its warped and not perturbed counterpart (especially if perturbations are, in some sense, large). It also does not give consistent conclusions across different perturbations: pdc ranks best for absolute-valued series with scaling or shifting, dtw for absolute- and percentage-valued series with noise, and int.per for absolute-valued series with all perturbations at once. In general, for absolute-valued series, measures performing well with noise mostly perform poorly with other two perturbations, and vice versa. Finally, measures should perform well also without perturbations, and that in these cases \texttt{cdm} together with \texttt{ncd} rank best as the only \emph{good} measures.
CDM (compression-based dissimilarity measure) introduced by \shortciteA{keogh_towards_2004} and further elaborated upon in \shortciteA{keogh_compression-based_2007}, has already been demonstrated (e.g.\ in these two references) to be immensely useful in various data mining aspects, prominently including time series clustering. It warrants mention, however, that it is not a distance measure (which is why we avoid using that phrase altogether throughout this paper), as, among other properties, by definition it attains values in the range $[\frac12,1]$, i.e.\ does not reach 0, even for equal arguments. This also means that the ratios $R$ we compute in our experiment are always going to be within the range $[\frac12,2]$ for CDM, and it may be argued that the setup is biased in favour of this measure. However, we uphold our conclusion because no other measure emerges as a clear alternative, especially if we demand that it performs well both with noise and with other types of perturbations. As a bonus, CDM also performs well with both the absolute- and percentage-valued series, making this measure much more versatile, even though we do not explicitly require such behaviour. Also, the unambiguously good results without perturbations (i.e.\ ratios below 1) and aforementioned reports of CDM suitability for clustering in general support this choice.
The next step in the procedure was to choose the most suitable clustering method. After clustering one should obtain a figure resembling a tree with some main branches and many smaller side branches. Conversely, a structure of ascending steps would disqualify a given clustering method.
We tested the following approaches:
Only the first five of these produced useful dendrograms. Ultimately we decided to pick the Ward method, as it is less sensitive to changes in the length of the time series and creates better separated groups.
For the purposes of this paper we employed the time series of GDP for analysis of the measure's stability, and its direct components (investment, consumption, import, export, employment, wages, etc.) to compare the economic structures of four EU Member States: Germany, France, Italy, and Spain. The reasoning for this choice is as follows: all of them are members of the Eurozone, Germany and France are the most advanced European countries, whereas Italy and Spain are the biggest lagging-behind members of the EU.
In order to establish international comparisons, we used data from the Eurostat after the introduction of the euro currency, that is, from the first quarter of 2000.
We decided to use the “raw” data, that is, quarterly, not seasonally adjusted time series. We argue that using data subject to preprocessing such as seasonal adjusting or detrending could introduce artificial distortions to the time series hamilton_why_2017,haan_will_2005.
In the following calculations we used nominal GDP in millions of euro, but other options are also available:
Which one is the most suitable for the considered method?
First, it depends on data availability. Usually the most up-to-date and the most accessible data is represented in nominal values in a given national currency.
Second, when comparing the behaviour of different real variables we are usually not interested in their nominal values, but their changes. Therefore, percentage change is the one most commonly used. But it is problematic in the case of, for instance, financial data, which is often presented as a percent rate (interest rates, yields, etc.). Percentage change of a percent rate may be hard to interpret.
Third, the answer to the question if real or nominal values are preferable is much more straightforward. If the dataset contains variables measured both in real terms (such as the number of unemployed) and in currency terms (such as consumption or GDP), chain-linked values should be employed. Otherwise, when all variables are represented in currency terms, distortions caused by inflation could be probably neglected.
We argue that the proposed dissimilarity measure is suitable in all of the aforementioned cases.
We begin empirical testing with analysis of the time stability of the CDM measure. To this end, we compare time series of the GDPs of the EU Member States, covering three periods: 2000Q1–2007Q4, 2008Q1–2017Q1, and the complete period of 2000Q1–2017Q1 ((ref)).
The first conclusion is rather obvious: the longer the time series are, the less similarity emerges. This phenomenon is indicated by the dotted line.
A related remark is that the financial crisis reversed processes of economic integration within the EU (both periods are of similar length). This is consistent with the findings of \shortciteA{belke_business_2017,gachter_business_2012,ahlborn_output_2017}, who employed different synchronization measures (respectively: correlation, panel regressions, and nonparametric regressions; correlation; and fuzzy clustering).
The employed similarity method allows us to distinguish two main groups of countries (grey outer rectangles in \hyperref[f:countries]{Figure \ref*{f:countries}c}): the “core”, consisting of France, Germany, the Netherlands, Austria, Belgium, and Spain; and the “periphery”. This structure was slightly different before and after the financial crisis (respectively, \hyperref[f:countries]{Figures \ref*{f:countries}a and \ref*{f:countries}b}).
Hierarchical representation of the distances enables changing the level of clustering (black inner rectangles). On this lower level, in the first period (2000–2007) the countries formed four quite similar groups consisting of: (a) Italy, Denmark, and Slovenia; (b) Germany, the Netherlands, Malta, and Romania; (c) France, Spain, UK, Finland, and Belgium; (d) the remaining 14 Member States.
In the second period, generally speaking, after the financial crisis, countries are less similar and it is more appropriate to cluster them into three groups: (a) the “core”, consisting of France, Germany, the Netherlands, Austria, Belgium, and Spain; (b) the “semi-periphery”, consisting of Croatia, Malta, Slovakia, Sweden, Slovenia, Lithuania, Bulgaria, and Luxembourg; (c) the “periphery”, consisting of the remaining 12 countries, including Greece, Italy, Portugal, and the United Kingdom. This structure holds also for the full time series.
These results are similar to (countries in common typeset in boldface):
To validate the usefulness of the proposed method in the analysis of the structure of an economy, we have selected variables used to calculate the gross domestic product (GDP) and GDP itself.
According to \shortciteA[p.\ 273]{esa_2010_european_2013}, there are three approaches to calculating GDP:
Taking into consideration economic theory and how GDP is calculated, the following distances between variables should be small in all of the analysed countries:
To verify these relations, we performed an agglomerative clustering on a set of 14 macroeconomic variables (for a full list see (ref)) that include these four, for each of the 28 EU Member States in the period of 2002Q1–2016Q4. The computation begins with all the variables in separate clusters, and gradually links them together until the two variables of the pair are in one cluster. The number of clusters at this stage is indicative of how similar are the variables of the pair in comparison with the others: the earlier they are clustered together, or the higher the final number of clusters, the relatively more similar they are.
As a rule of thumb, we propose that if compared variables belong to the same group when three or more clusters are created, then the method proposed in this paper is positively verified (confront \hyperref[f:histogram]{Figures \ref*{f:histogram}} and (ref)).
In the case of GDP and gross value added, there were only two countries for which these variables were linked only in the two last steps of cluster merging. Note that such a situation should raise questions about data quality.
In the case of compensation of employees and household and NPISH final consumption expenditures, the relation is not so straightforward, and therefore the relative distances are larger. Nevertheless, in half of the analysed countries these variables were connected when the number of clusters was more than three.
In our opinion, these results confirm that the proposed method is consistent with SNA methodology and economic theory.
Finally, we selected four countries (Germany, France, Italy, and Spain) for more detailed verification. Relations between variables are compared in (ref). As expected, every country has its unique structure.
Nevertheless, the macroeconomic indicators in Spain, Germany, and Italy form three main clusters, while in the case of France it is more natural to distinguish four main groups.
A more detailed look into the selected countries reveals that all three approaches to the calculation of GDP are generally preserved. This also confirms the robustness of the proposed method.
The aim of this paper was to verify usefulness of the time series clustering method for macroeconomics research, and to develop the most suitable methodology.
After the evaluation of 24 dissimilarity measures, the CDM measure was assessed as the most suitable for our purposes. It most effectively prefers time series with similar frequencies over similar magnitudes of volatility. We assume that likeliness of frequencies could suggest causality.
This assumption and the usefulness of the proposed method is confirmed in the analysis of the distances between aggregated time series of the EU Member States. Results confirm that CDM preserves relations from the national accounts equations as well as from economic theory. It is also robust for manipulations in the length of time series.
It could be therefore recommended for a variety of macroeconomic research topics, including, but not limited to, issues of balance of payments, fiscal and monetary policy, or financial integration in the EU.
\renewcommand \baselinestretch 1