{'fraction_non_alphanumeric': 0.04062147085999795, 'fraction_numerical': 0.021183395503233976, 'mean_word_length': 4.4084767721636124, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Continuous-Time Inequality Measure Applied to Financial Risk: The Case of the European Union

: In this paper, we apply information theory measures and Markov processes in order to analyse the inequality in the distribution of the ﬁnancial risk in a pool of countries. The considered ﬁnancial variables are sovereign credit ratings and interest rates of sovereign government bonds of European countries. This paper extends the methodology proposed in our previous work, by allowing the possibility to consider a continuous time process for the credit rating evolution so that complete observations of rating histories and credit spreads can be considered in the analysis. Obtained results suggest that the continuous time model ﬁts real data better than the discrete one and conﬁrm the existence of a different risk perception among the three main rating agencies: Fitch, Moody’s and Standard & Poor’s. The application of the model has been performed by a software we developed, the full code is available on-line allowing the replication of all results.


Introduction
Literature on risk management has become more and more focused on sovereign securities. The events of default of some countries and the economic and financial crisis registered during the last decades has increased the need to investigate causes and consequences of such events (see e.g., Knieling and Othengrafen (2015)). In particular, the Eurozone has been investigated from several points of view. The problem of income inequality has been faced by D' Amico et al. (2012), whereas the systemic risk has been analysed through a network approach by Westphal (2015). The financial implications of any possible changes in the European structure has been investigated by Escalera andTarrant (2014) andD'Amico et al. (2018).
The present work aims at gaining insights on the behaviour of the financial risk inequality among European countries over the next future. Precisely, we want to extend our previous work (D'Amico et al. (2018) to a continuous-time setting with the intention of achieving more precise previsions. We refer to financial risk inequality as a measure that summarizes the degree of disorder or concentration of the financial risk within a given group of countries. In particular, we rely on a stochastic measure of inequality proposed by D' Amico et al. (2014) that generalizes the static measure of inequality proposed by Theil (Theil 1967), whose properties make this index

Data
The financial risk is expressed by the value of the credit spread paid by each country. This results from the difference between the long-term interest-rates and the minimum value among all countries as observed at the same time t. Hence, it can be interpreted as the premium for the risk paid by country a corresponding to the amount of the "spread" compared to the ideal situation where the country pays the minimum value ("risk-less"). The choice of this kind of indicator is justified by the fact that we are interested to the difference between countries and not to the precise amount of debt paid. Moreover, we used the minimum value rather than the interest rate of German sovereign bonds because other EU countries experienced lower interest rates than those paid by Germany (for example Luxembourg, Sweden and, for very short period Czech Republic, United Kingdom and Netherlands). To compute the credit spreads, the harmonised long-term interest rates of government bonds have been collected from the Statistical data Warehouse of the European Central Bank (ECB) website on a daily scale. In particular, they consist of interest rates on sovereign debt securities with maturity of 10 years. The horizon time ranges from 1/1/1998 to 31/5/2017 for the countries which found the European Union (EU). While for the rest of the dataset it depends on the entry date of the countries in EU, i.e., 1/5/2004 for Latvia, Lithuania, Malta, Poland, Czech Republic, Slovakia, Slovenia, Hungary, 1/1/2007 for Bulgaria and Romania and 1/7/2013 for Croatia Figure 1 shows the evolution of the total cost of sovereign debt paid by the member states in the left panel and the minimum value useful to assess the credit spreads in the right panel. The credit spread paid by all countries was moderately low until the entry of 9 new member states in 1/5/2004, while the entry of the others countries in 1/1/2007 and in 1/7/2013 did not cause crucial variations. At the beginning of the 2012 the value of the total credit spread had a peak of about 10.000 basis points (bp) and this growth was driven by the rise of the securities yield of Greece (2.924 bp), Ireland (1.245 bp) and Portugal (1.385 bp). On the contrary, the benchmark went down over time, except for a minor increase around the period of the financial crisis, reaching negative values in the 2016 related to German government bonds. One of the main determinants of the credit spread is the credit rating. Thus, we downloaded the sovereign rating transition histories, on a daily scale, from the Tradingeconomics web-site for the three agencies. Rating ranks are continuously observed for all agencies so that the exact dates of rating transitions are registered. We built three datasets starting from 1/1/1998 to 31/5/2017, depending on the data availability for each agency. The resulting datasets consist of 184.340 observations for Moody's, 179.686 observations for Fitch and 175.916 for S&P 1 . All data are grouped in 8 rating class such that: AAA (Aaa) = 1; AA (Aa) = 2; A = 3; BBB (Baa) = 4; BB (Ba) = 5; B = 6; CCC-CC-C (Caa-Ca-C) = 7; SD/RD = 8 for S&P / Fitch (Moody's). For the sake of clarity we will denote the rating notations as k = 1, . . . , 8. Conventionally, credit ratings from k = 1 to k = 4 are defined investment grade rating classes, while credit ratings from state k = 5 to state k = 8 are defined speculative grade rating classes. 1 The countries composing the datasets are 26 and not all the 28 Members of European Union, due to lack of data in the case of Cyprus and Estonia.
The former are assigned to obligors with relatively low to moderate risk of default. Speculative grade rating categories denote an higher risk of default until the occurrence of the event of default or selected default. From the datasets we observed that most of the sample countries had an investment grade rating class. In fact, the percentage of speculative categories is low and it increases after the 2008 (around the financial crisis), reaching the maximum in the period surrounding the Greek crisis (2012) with only the 19% of the sample experiencing this ranking. This was caused by the fact that after the 2008, European countries experienced a lot of downgrades (i.e., transition to a lower credit rating class). Almost the 80% of the transitions observed between 2008-2015 are to a lower credit rating, for all three agencies.

The Model for Rating Migrations
Consider the pool of N = 26 countries of the European Union. Let denote by x c v (t) the variable rating which is assigned by the rating Agency v with v ∈ [Moody s, Fitch, S&P] to country c at time t. The rating assignment process depends on macro and microeconomic conditions and differs among rating agencies. This is the reason we assume that the sequences . . , 26}. We assume that the processes X c v (t) are independently and identically distributed according to a continuous time homogeneous Markov process taking values in the finite state space E = {1, 2, . . . , K}, representing the rating class. This assumption allows to build a flexible and simple model to be estimated and applied for real purpose, given the sparsity of data of the sample. We will denote as X(t) the stochastic process resulting from the common distribution of all countries, leaving aside the notation of rating agencies. The transition matrix of the continuous Markov process is denoted as P(t) = {p ij (t)} i,j∈E whose elements represent the probability of moving to state j starting from state i in a given time interval [0, t], i.e., p ij (t) = P(X(t) = j|X(0) = i). (1) Transition probabilities are computed according to: where A = {a ij } i,j∈E , is the infinitesimal generator matrix, whose elements represent the intensities of transition from state i to state j over a given period. It is defined as the derivative at 0 of the matrix function t → P(t). In compact notation it is given by: and it satisfies the following properties:

Dynamic Measurement of the Inequality
The measure of the inequality of the financial risk distribution has been based on the Theil index (see Theil (1967), which is computed as follows. Let denote by r c (t) the credit spread paid by country c at time t: with y c (t) representing the interest rate paid by the same country c. Let s c (t) be the share of credit spread among N countries attributed to country c at time t. It is given by: For all t ≥ 0, the vector s t = {s 1 (t), . . . , s N (t)} forms a probability distribution. The Theil index is given by: where S(s t ) is the Shannon entropy (for further informations, see Shannon (1948)). To forecast the future inequality a dynamic measure is required. The measure of entropy indeed depends on credit spreads which, in turn, are influenced by rating dynamics. These last follow a stochastic process and, as a consequence, the measure of entropy becomes a stochastic process too. We will call this index as Dynamic entropy. In particular, we refer to the Population Dynamic Theil's Entropy, i.e., DT(n(t); K), proposed by D' Amico et al. (2014). In this work, the authors derived a formula to assess the dynamic entropy by decomposing it into inter group entropy and intra-group entropy. Thus, the countries are allocated in K groups, i.e., the rating classes {C 1 , . . . , C K }, whose evolution is described by a multivariate stochastic process n(t) = {n c 1 (t), n c 2 (t), . . . , n c K (t)}. The probability distribution is then built on the shares of credit spread paid by the rating classes s (n(t)) = {s c 1 (n(t)), . . . , s c K (n(t)), where where r c i is the mean credit spread paid by class C i , estimated on historical data. It should be noted that r c i is supposed to be constant over time and for each rating class. So that the dynamic entropy depends on n(t), which is given by: In the rest of the paper we will denote DT (n(t); K) by DT(t).
The first addendum represents the intra-group entropy. It is given by the product of the entropy assessed within each rating class, i.e., TE (r c i ; n c i (t)), and the share of rating class C i . The entropy measure within a given rating class can be estimated according to Equation (6). However, in our application, it is equal to zero. As we suppose r c i to be constant over time and for all countries within the same rating class, the resulting distribution is a uniform one. The two other addenda steam from the decomposition of the inter-group entropy. The second one describes, in fact, the inequality evolution among the K rating classes. The last addendum summarizes the divergence of the actual distribution about the uniform distribution of countries equally rated. For further information about the interpretation of this index see D' Amico et al. (2018).
The dynamic index will be close to zero if all countries pay almost the same value of credit spreads. On the contrary, DT(t) will reach the highest value if one country pays the total spread. Thus, an increasing value of this index denotes growing risk in EU due to a concentration of the financial risk on a few countries, or in the worst case, on only one country. The process DT(t) is better summarized by its first and second order moments. However, the computation of them would require the set of all possible population configurations which stem from 26 countries and 7 or 8 rating classes. Hence, the number of required configurations would become ( N+K−1 K−1 ) = ( 33 7 ) = 4272.048 (906.192 with 7 rating classes). The Monte Carlo simulation represents a valuable tool to get around the computational problem given by the huge amount of combinations to be calculated.

Monte Carlo Simulation to Forecast the Financial Inequality
We aim at computing the expectation E[DT(t)] and the standard deviation σ DT (t) of the dynamic entropy by means of Monte Carlo simulations. Precisely, we simulate N trajectories for a number R of experiments. In particular, for each experiment, we generate future rating dynamics and, assigning the mean value of the credit spread distributions, we assess the future inequality evolution, as in Equation (8). The rating dynamics are generated according to a continuous time Markov chain {X(t)} t≥0 with the generator A = {a ij }, and the initial distribution µ up to time t > 0. Thus, we have to construct the sequence: where X 0 is drawn according to µ, X n denotes the rating class occupied at the n-th transition and T n − T n−1 represents the time length between the n − 1-th and n-th transition. As usual, the simulation of a trajectory of a continuous time Markov chain is done according to the following formulas: They denote the fact that, using current rating class (say i ∈ E), firstly we simulate next rating using the probability distribution ( a i. a i ) and then we simulate the sojourn time in rating i according to an exponential distribution of parameter a i . In particular, if T n is the increasing sequence of transition times of the process X(t), then, by X n = X(T n ), we denote the embedded Markov chain. It results that represents the probability of transition from state i to state j disregarding the sojourn time length, which follows an exponential distribution with parameters a i . Furthermore, we simulate the evolution of the credit spread by assigning the mean value of its distribution to the corresponding rating class. The dynamic index is then computed as showed in Equation (8). Finally, the first and the second order moments result from the average value and the standard deviation of DT(t) over all Monte Carlo iterations.
The whole methodology described in the present work has been implemented using the Python programming language (Dubois et al. (1996)) in order to obtain all results reported in the next Section. The main Python packages we used are NumPy (Oliphant (2006)), SciPy (Jones et al. (2001)), Matplotlib (Hunter (2007)) and PyQt4 (Summerfield (2007)). The whole code can be easily downloaded by the following GitHub repositories: https://github.com/lstorchi/markovctheil/ tree/continuous. The main computational kernel can be found in the mainmkvcmp.py source code file, when one can found the main_mkc_comp_cont function. Furthermore, there are two utilities one can use to reproduce the full set of results reported in the present paper: the markovc.py CLI code, and a minimal GUI implemented using PyQt that is the named markovc_qt.py.

Estimation of the Infinitesimal Generator A
The generator matrix useful to simulate future rating dynamics is estimated, as suggested in Sadek and Limnios (2005), by means of its maximum likelihood estimator (MLE), i.e.,Â = a ij (T, N) i,j∈E . Denoting by N the number of considered countries and by T the observation period: where n ij (T, N) is the number of total transitions from i to j observed for all countries over the time interval [0, T] and v i (T, N) is the total time spent in rating class i by all countries.

Results and Discussion
The methodology presented above has been applied for the three rating agencies, investigating both the current scenario, i.e., with all countries and the scenario including Brexit. We start by discussing the current scenario. In particular, we report the generator matrices for all agencies to highlight any differences, and the rate of occurrence of failures to understand if the system has degraded. Finally, the results of the expected value of the financial inequality is showed and discussed. For sake of synthesis we will report only the results about the expected inequality in the Brexit scenario.

Generator Matrix
Tables 1-3 show the generator matrix for Moody's, Fitch and S&P agencies, respectively. The first matrix has 7 rows and columns because Moody's consider 7 rating classes. For Fitch and S&P the rating classes are 8 as both agencies rated Greece with Selected Default (SD) in 2012.    The generator matrices highlight the fact that rating agencies have different rating assignment process. As a matter of fact the generator estimated using Moody's data differs from the others for several reasons. Firstly, it has an absorbing state (k = 7), secondly, some of the transition intensities of 2 notches are positive i.e., a 2,4 = 0.000035 and a 3,5 = 0.000025 and the intensities of transition are smaller than those estimated for the other agencies. This finding supports the existent literature (see, among others Hill et al. (2010)): Moody's use to maintain its rating assignments as steady as possible. This fact could cause sometimes the need to adjust the assignment of 2 notches, as shown above. However, also for Fitch and S&P we observe an upgrade of two notches from k = 8 to k = 6. If for Fitch k = 6 is the only state after experiencing the default, for S&P the way to leave the state of default are k = 6, 7 (as highlighted in the generator matrices).
Despite the differences on rating assignment process among the agencies, the evolution of the transition probability are almost similar except for the probability to migrate to the worst rating class (i.e., k = 7 for Moody's and k = 8 for Fitch and S&P). For instance, according to Figure 2, while p 2,1 (t) and p 3,5 (t) are very similar for all rating agencies, the transition probabilities to the last rating class are dissimilar. The reason is the presence of the absorbing state k = 7 in the case of Moody's. Thus, to better compare the three agencies, we consider the Default as absorbing. Therefore, looking at the second and third rows of Figure 2, the evolution of p 6,8 (t) and p 7,8 (t) of Fitch and S&P are close to p 6,7 (t) of Moody's.

Rate of Occurence of Failures
The rate of occurrence of failures (Rocof), see Shi (1985), is an important indicator which derives from the reliability theory. It is the derivative of the expectation of the number of failures which have occurred by time t within a given system. Thus, it can be interpreted as an indicator of the deterioration of a given system. The term failure, in our application, refers to the entrance of sovereign securities to specific rating categories called failure states denoted as F, starting from the ratings classes belonging to the working states = W. In particular, we compute the conditional ROCOF, as proposed in D'Amico (2015) and applied to credit ratings. We need the conditional Rocof because of the absorbing state. Thus, to compare the rating agencies, we make the rating class Default as absorbing for Fitch and S&P and then we compute the conditional probability given no default (no rating class C for Moody's) as follows: Then, the conditional Rocof D ro i is calculated according to: where p i,w (t) is the probability of transition from any states i to a working state over the time interval (0, t). While a w f is the entry of the generator matrix, denoting the intensity of moving from a working state to a failure state. The D ro i (t) is computed fo the three agencies in two different cases: • W = 1, 2, 3 and F = 4, 5, 6, 7 fo Fitch and S&P and F = 4, 5, 6 for Moody's; • W = {1, 2, 3, 4, 5, 6} and F = {7} for Fitch and S&P and F = {6} for Moody's. Figure 3 shows the evolution of ROCOF over time (horizontal axis of each sub-figure) in both cases. Generally, Rocof values are lower in the case of Moody's agency (values of the order of 10 −4 ) than the other agencies (whose maximum values are close to 1.5 × 10 −3 ).
The results with W = {1, 2, 3} are shown in the first column. D ro 1 (t) is increasing over time whereas D ro 2 (t) and D ro 3 (t) are, instead, decreasing. On the right panel of the Figure, the Rocof estimated in the second case illustrates that better higher quality rating classes have lower chance of entrance in F; however, this likelihood goes up over time. On the contrary, the Rocof for the B-rating categories (i.e., 4, 5, 6) start with the highest values but, by the time, it falls down. The general shape of the Rocof in the second row of Figure 3 is financially sound. Indeed, for high rating classes, in a given short time, the probability of entering into the failure states is low and it is growing over time as the system tends to deteriorate. On the other hand, low credit ranks exhibit the opposite trend: in a short time horizon there is an a high probability to enter into failure states, implying low chance of entering into failure in the long run.

Financial Inequality
The expected value and the standard deviation of DT(t) are computed by means of Monte Carlo simulation with 100.000 runs and given horizon time of three years (from June 2017 to May 2020). As explained before, the simulation requires, first of all , the generation of a continuous time Markov chain (Equation (9)). Figure 4 shows the result of a simulation of rating migration using the estimated S&P generator.
According to this Figure, there are some rating migrations: for example the second country is upgraded. Actually, the rating evolution is simulated for each run, resulting in an array with dimension [26 × 1096 × 100, 000]. To assess the financial inequality, we need the variable related to the financial risk. It is expressed by the mean of the credit spread distribution estimated for all rating categories and all rating agencies, whose values are reported in Table 4. Even if the agencies share almost the same view about rating assignment, they have different perception of risk when expressed in terms of credit spreads. In fact, some of the credit ranks (6, 7 and, to a less extent, 3, 4) have different values. The evolution of the credit spreads influences, along with the rating dynamics, the evolution of the dynamic entropy. Thus, the differences described above could cause divergences on the forecasted financial inequality as shown on the left panel of Figure 5. The value of Theil entropy estimated on the observed data at t = 31/05/2017 is 0.50031. The value has been reached after a general decrease. This suggests a convergence towards greater equidistribution of the risk over time 2 . The evolution of the forecasted inequality resulting from the three agencies is different in terms of its shape but also of its values. For instance, E[DT(t)] Moody s is increasing over time with values spreading between 0.59281 and 0.64308 at the end of the horizon time. E[DT(t)] Fitch , on the contrary, would decrease starting from the highest value (0.64713) up to 0.60414 which is close to the inequality predicted with S&P data in May 2020. Finally, S&P is particular because the dynamic entropy starts with 0.58748, it increases with a peak of 0.6028 and then it falls up to value close to 0.59506, suggesting that for this agency the financial risk would be more equidistributed than Fitch 2 The historical entropy is assessed according to Equation (6). For further details on the measure and on its evolution during the analysed period see D' Amico et al. (2018). and Moody's. There would be dissimilarities also among the share of basis points paid by each rating class i.e., s c i n(t) : rating class CCC's share in Fitch would decrease by 50%,in S&P it would increase ranging between 0 and 0.04% and for Moody's it would remain almost stable. On the other hand, s 6 n(t) would grow both for Fitch and for Moody's, while for S&P it would go down. Finally rating class 4 would have the highest percentage of credit spread for all agencies (>30%), this could suggest that countries close to the speculative grade rating classes (i.e from BB to D) would pay higher costs of debt.
The right panel of the Figure 5 shows the standard deviation of the forecasted inequality. It rises for all rating agencies over time. However, S&P shows the highest values, which, at the end, converges with those predicted by Moody's. On the other hand, Fitch would have the lowest values.

Simulation in the Case of Brexit
The whole methodology has been replicated for the Brexit scenario. To build this scenario we follow the hypothesis of independence, previously stated, between sovereign credit ratings and, as a consequence, between credit spreads. This is why we have just removed the historical data of United Kingdom (UK) from the datasets, without changing the other countries.
As this country experienced only one transition from rating k = 1 to k = 2 , the generator matrices are similar with a Brexit 1,2 < a 1,2 ; a Brexit 2,1 > a 2,1 and a Brexit 2,3 > a 2,3 . Furthermore, the credit spread distribution does not change dramatically. In fact, the average value of rating classes 1 and 2 reduces by, respectively, 6% and 2%.
This is the reason, as shown in Figure 6, the results about the financial inequality are close to the previous ones. Looking at the left panel, the evolution of the expected value of the dynamic entropy exhibits the same trend as the current scenario: E[DT(t)] Fitch would decrease, ranging between 0.64567 to 0.603641 at the end of the horizon time. The evolution of the inequality forecasted using Moody's data starts with value close to that of S&P (0.59034 and 0.58740, respectively), but the first one would rise up to 0.63967 while the second one would reach 0.594711 after having a peak of 0.601. Also the standard deviation is almost similar as can be seen on the right panel of the Figure 6. It is increasing for all agencies and the values are close to those of the actual scenario, spreading between: 0.003142 to 0.065296 for Fitch; 0.004465 to 0.099404 for Moody's and 0.004673 to 0.100193 for S&P.

Discrete vs. Continuous
The advantages of the continuous time framework are well known and documented. First of all, the main advantage refers to the ability of capturing all transitions. As a matter of fact, the continuous observation of the rating migrations (i.e., in a daily scale) allows to estimate probabilities of rare events that we would never have observed in the discrete-time framework. Furthermore, by using daily data, the generator matrix estimated for Fitch matrices has dimension (8 × 8) while, using the discrete-time model the transition probability matrix have dimension (7 × 7). This happens because we observe the transition to and from the default state (RD), occurred only for four days in a month. Moreover from the S&P dataset we register two transitions to and from default state (k = 8).
A further advantage, which directly derives from the first one, is the estimation of the transition probability from high rating classes to the speculative grade rating classes and, more importantly, to default states. For example, as shown in Figure 7, the transition probability from state AA to default state is non-zero even if it is very small. Finally, another advantage in our application, is the estimation of the first and the second order moments of the Dynamic Entropy. Figure 8 shows the inequality estimated in this work compared with the inequality we assessed in D' Amico et al. (2018) using the discrete-time framework. The values resulting from the continuous time model are discretized to allow the comparison. It can be seen that the expected inequality as forecasted in the discrete-time framework is always higher than that calculated using the methodology presented here, and more importantly, the latter is closer to the observed entropy (0.50031 on the 31/05/2017) than the discrete-time one. Also the standard deviation is higher in the discrete time case except for Moody's, where in May 2019 σ DT (t) estimated in the continuous framework would match and then overcome σ DT (t) assessed by means of the discrete time framework. These results suggest that the continuous time framework is more precise than the discrete-time both in the case of the data processing and for the forecasted part. Thus, it fits better with our purposes.

Conclusions
A continuous time Markov process has been proposed to model rating dynamics underlying the credit spread evolution, in order to estimate the future inequality. The use of the continuous time framework allows the forecast to be more precise by including transition probabilities that otherwise would have been neglected in the discrete-time case. For instance both the expected value and the standard deviation would have been smaller. In particular, as the maximum value of the inequality is log(N), our results show that the future inequality would be relatively small. This suggest that there would be a weak inequality. However the forecasts made for the three agencies suggest a different evolution of inequality, confirming what we have found in our previous work. This behaviour could be explained by the different perception of risk founded in the credit spread distribution. Thus, it would be interesting to investigate the reasons of this difference, including others variables. Further variables could be also used to find a source of dependence among countries.