<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Luca Donghi, CFA, CMT, FDP on Medium]]></title>
        <description><![CDATA[Stories by Luca Donghi, CFA, CMT, FDP on Medium]]></description>
        <link>https://medium.com/@lucadonghi_25036?source=rss-41aca90434dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PtNdmLfVIFAhhRMToldvxw.jpeg</url>
            <title>Stories by Luca Donghi, CFA, CMT, FDP on Medium</title>
            <link>https://medium.com/@lucadonghi_25036?source=rss-41aca90434dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 02:31:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucadonghi_25036/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Long story short, a long-short story]]></title>
            <link>https://medium.com/@lucadonghi_25036/long-story-short-a-long-short-story-64c3eec2a5df?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/64c3eec2a5df</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[hedge-fund-strategies]]></category>
            <category><![CDATA[portfolio-construction]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[short-selling]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 22:31:26 GMT</pubDate>
            <atom:updated>2024-12-16T22:31:26.245Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article I am gonna demonstrate how it is possible to leverage machine learning models to construct long/short equity portfolios of high-quality and highly innovative stocks. Starting from the <strong>S&amp;P Kensho New Economies Composite index</strong>, we’ll delve into a simple quantitative approach to security selection, as well as into different approaches to portfolio construction for the long side. We will then explore “<em>alternative</em>” ways to improve risk-adjusted returns by shorting stocks in a systematic fashion thanks to machine learning classifiers. The results indicate that adding a short book on top of a long-only portfolio can add value for the investor over time.</p><p><strong>Agenda</strong>:</p><ol><li>Once upon a time…</li><li>Long story…</li><li>… short</li><li>A long-short story</li><li>Happily ever after?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7kccWstcXDJ3RQvV" /><figcaption>Image generated with ChatGPT</figcaption></figure><p><strong>Once upon a time…</strong></p><p>I started my analysis (or story, if you prefer) with a question in mind: where should I start looking for if I want to pick the most innovative listed companies on the planet? Bottom-up equity managers spend a lot of time and resources doing their fundamental research to select stocks with the best growth potential. At the same time, valuations play an important role in their investment decisions. Unlike retail investors, professional portfolio managers have a dedicated team of analysts and a well established network of company managers they meet with when they carry out their due diligence. Retail investors do not have access to such resources and rarely possess the skills needed to consistently beat the market. So, where should a non-professional investor start digging? How could he/she develop a system to generate good investment ideas for a long-term growth portfolio of stocks? I tried to answer to this question by looking at the S&amp;P Kensho New Economies Composite index. This index was created and is maintained by S&amp;P. Below I report the main characteristics of this index:</p><p><em>The S&amp;P Kensho New Economies Composite Index (the “Index”) is comprised of U.S.-listed equity securities (including depositary receipts) of companies domiciled across developed and emerging markets worldwide. The Index is designed to capture companies whose products and services are driving innovation and transforming the global economy through the use of existing and emerging technologies, and rapid developments in robotics, automation, artificial intelligence, connectedness and processing power (“New Economies companies”). The Index is comprised of each of the eligible Kensho New Economies Sub-Indexes. Each Kensho Sub-Index is weighted by its Sharpe ratio with an annual reconstitution. There are currently more than 20 Sub-Indexes in the Composite. Kensho identifies companies in its New Economy Subsectors using its propriety Natural Language Processing “NLP”, which leverages their artificial intelligence capabilities to screen regulatory forms for key words and phrases in the appropriate context relevant to the respective new economy sector to find companies for inclusion.</em></p><p>It seems that this index could be a good starting point for finding good investment ideas. In fact, it has many benefits for our goal:</p><ol><li>The index has more than 350 stocks, providing a good source of investment ideas.</li><li>It comprises both Developed and Emerging Markets companies, thus ensuring proper diversification.</li><li>These companies belong to different GICS sectors, hence avoiding concentration in a few industries.</li><li>Companies included in the index are considered the most innovative and are transforming the global economy with their products and services.</li><li>Annual reconstitution make sure new ideas can be potentially generated each year.</li><li>The stocks are US-listed, thus facilitating access to companies located in Emerging Markets, and limiting currency risk to the USD (for a non-US investor).</li></ol><p>Please, note that in order to perform all the relevant portfolio construction and back-testing steps, while avoiding look-ahead bias, I took the composition of the index as of 31/12/2018. Hence, you’ll find companies that might have changed their names like Facebook (now Meta), or Twitter (now X).</p><p>If you’re curious to further explore this particular index, you can find more information following this link: <a href="https://www.spglobal.com/spdji/en/indices/equity/sp-kensho-new-economies-composite-index/#overview">https://www.spglobal.com/spdji/en/indices/equity/sp-kensho-new-economies-composite-index/#overview</a></p><p><strong>Long story…</strong></p><p>Ok, so we found a good investment universe for our idea generation step. We said that we are interested in creating a high-quality, high-growth portfolio of stocks, so the next thing we should do is to screen stocks according to these two “factors” (growth and quality). For the former (i.e., growth) we are already ok, because the index itself is build with the 350 most innovative companies. Now we have to take care of the second aspect (quality). To accomplish this, we can sort companies according to quality metrics like gross margin, revenue growth and ROIC (return on invested capital). We can consider other metrics like financial leverage, current ratio, etcetera, but since not all data are consistent across these companies, we can keep it simple and sort companies based just on a few “quality” metrics. We can also include their market cap, so to exclude names with a too small market cap if we want to. Of course, we need to collect the GICS sector to which each company belong to as well, because the screening has to take place within each industry, so to have better confidence in comparing apples with apples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*YgtaigxarEDcTIm5nJEXkA.png" /><figcaption>Screenshot of the <em>S&amp;P Kensho New Economies Composite Index</em>. Source: SPDR &amp; Bloomberg</figcaption></figure><p>Once we have grouped stocks by GICS sector, we need to find a way to create a hierarchy within each group based on a score. To do so, we can apply a Min-Max scaler to the value of each metric and sum all of them column-wise to get the final score for each stock. It’s of paramount importance to calculate the score within each group and on the whole dataset, because companies belonging to certain sectors might have very different metrics than companies in others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*MZsUF__angW6lVU9AedPmQ.png" /><figcaption>Calculation of the “quality” score for each stock within each group</figcaption></figure><p>Good! Now we can split each group of stocks (i.e., each GICS sector) in quartiles. We will consider only those stocks belonging to the highest quartile, because these are the stocks (within each sector) that have the best quality metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*PlRvRNkkqs90ud6ETAe1GA.png" /><figcaption>Splitting stocks in quartiles within each sector</figcaption></figure><p>Finally, we want to exclude those stocks with a market cap smaller than 2 bln. This is because such stocks are the most volatile and can have a strong impact on our risk-adjusted returns. Furthermore, their lower liquidity means that we might get very bad prices when trading them (especially if need to rush to the exit during market turmoil). Finally, this should make us more confident when we perform our back-tests that such companies have not gone bankrupt or have exited the index (so called survivorship bias).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*JPNkDkWbaSjC-2G3QW0Ilg.png" /><figcaption>Info of our dataset if short-listed securities</figcaption></figure><p>As we can see, we started with roughly 350 stocks to end up having 60 stocks in our portfolio with stocks belonging to different sectors. That’s a well reasonable portfolio, that can ensure proper diversification. Below, you can appreciate the breakdown by sector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*HKFswJIK2UWqnm1eAYrDRg.png" /></figure><p>Most of our selected names belong to the Technology and Healthcare sectors. This is not surprising, since most of the companies belonging to such industries are those that have to invest more in R&amp;D to innovate and to stay in the game.</p><p>So far, so good. Now we need to get the historical daily prices of our selected stocks. We need to get such prices starting from 31/12/2018 as previously anticipated, because we want to avoid look-ahead bias and we need enough samples to run a decent back-test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*aQfSFSkVCWthWFieiLclaQ.png" /><figcaption>Historical prices of selected stocks. Source: yahoo!Finance</figcaption></figure><p>The next big question is how to assign weights to each of these 60 stocks. Should we equally weight? Should we weigh them based on their market cap? Or based on their inverse volatility (i.e., risk parity)? Well, there is no right or wrong to this question, but the path I selected to test was to apply hierarchical risk parity (HRP) to construct our portfolio of high-quality, highly innovative stocks. Explaining thoroughly what HRP is can make this article too long, but what you need to know about it is that we’ll group stocks based on their similarity of returns. Hierarchical clustering is a machine learning model itself, and is part of the so called unsupervised learning models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*p0nXBiDiwbIUWKmZ.png" /><figcaption>Source: DataCamp</figcaption></figure><p>To calculate portfolio weights with HRP, I have only used historical returns ranging from 31/12/2018 till 31/12/2019, so we’ll leave enough samples to carry out our back-test. The similarity is calculated with Euclidian distance, and each individual group of stocks will create a single cluster that progressively will be part of a bigger cluster (i.e., including other clusters) till we get a full hierarchy of bigger and bigger clusters (the final cluster contains all the stocks in our data). If you’re curious to know more about hierarchical clustering, here you can find a good article detailing it: <a href="https://www.ibm.com/think/topics/hierarchical-clustering">https://www.ibm.com/think/topics/hierarchical-clustering</a></p><p>This is how our hierarchy of clusters should look like if we plot it with a so-called dendrogram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*Z70JnhbbUrM_ICqHg4RLlA.png" /><figcaption>Dendrogram showing hierarchical clustering based on historical daily returns for the year 2019</figcaption></figure><p>The chart is hard to read, but it gives you an idea of how stocks that are more similar to each other (again, according to their daily returns) form separate sub-clusters. The beauty of this method is that you can group items (in this case stocks) based on whatever metrics (or features in machine learning parlance) you consider explanatory. In this case, it proves very useful because sometimes, classifying stocks by industry or by market cap doesn’t ensure that we are grouping together stocks with similar characteristics (i.e., with similar historical returns “behaviors”). In fact, this is a limitation of traditional risk-parity portfolios, in which stocks belonging to certain sectors get the most weights just because of their lower volatility. The problem is that should a “tail event” occur in that sector (imagine an unfavorable regulation by the government in the Utilities sector) you might end up having most of you portfolio allocated to stocks that you considered “safer” that are no more.</p><p>Good! Once we have our hierarchy of clusters, we’ll then assign weights to each stock based on the inverse of its volatility compared to other stocks belonging to the same cluster. It’s a progressive process that starts from the top of our hierarchy, and that keeps moving down to each sub-cluster, assigning (“progressively”) the remaining weights left proportionally according to the inverse of each stock’s volatility. To be clear, stocks that belong to small clusters (i.e., stocks that cannot be easily grouped with many others because of their highly idiosyncratic behavior) get the highest weight. We can consider it a sort of reward because of the stock superior diversification abilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*kJZJovGmq0Ut4h_LVKCUow.png" /><figcaption>Screenshot of the first ten stocks’ weights</figcaption></figure><p>Great! If we now check our portfolio of stocks we might notice that some stocks get a too big weight, while others have a weight that is too small. If that’s the case, we need to redistribute our weights in a way that we are more comfortable. For example, since we have 60 stocks in the portfolio, and I want to make sure that each of them have the chance to contribute somehow to our final performances, I decided to apply a ceiling to the weight each stock can get that is equal to 3%. You can choose whatever threshold you want, but in my case I opted for such a low threshold because I haven’t carried out any thorough fundamental research on any of these stocks, so my conviction level on any given name is pretty neutral.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*2QeSSkSkiPkP0p3zmZ2l2w.png" /><figcaption>Head of the portfolio after weight redistribution (top 10 stocks)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*nIr7Wu_Sv_JM818D_oiX9w.png" /><figcaption>Bottom of the portfolio after weight redistribution (bottom 10 stocks)</figcaption></figure><p>Excellent! Now that we have found our weights and that we have our historical returns, we can perform our back-test. As said, it will start from 31/12/2019, because we have used the first year of data to calculate weights. We’ll use the S&amp;P Kensho New Economies Composite index as our benchmark, because the reasonable alternative to all such exercise would have been to simply buy an ETF replicating such index. I have used pyfolio in Python to run the back-test, and I have assumed daily rebalance for the sake of simplicity. This is a strong assumption because a normal investor would typically rebalance his portfolio once a year or semi-annually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*asrN-dC9UabV5j68H5pGOg.png" /><figcaption>Cumulative returns of portfolio (“Backtest”) vs benchmark (“Adj Close” on the legend)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*d5fPI7XVm3-1pQUy1s9zmg.png" /><figcaption>Strategy rolling volatility vs benchmark</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*yGRm7vghz8ojyebRI3irgQ.png" /><figcaption>Back-test metrics</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*LcSrjEXd6jVVHb-F24djgw.png" /><figcaption>Back-test returns distribution</figcaption></figure><p>Let’s see… well, we managed to do better than the comparator, which is a good start. In fact, our strategy reported a cumulative returns of 66% in less than 5 years (57 months to be precise), while the KOMP ETF returned around 40% over the same period. In terms of relative volatility, our strategy looks better or in line with the comparator as well. The Sharpe ratio looks fine too, but max drawdown and daily VaR seem to have room for improvement.</p><p>We could adjust the weights in our portfolio, by changing the max weight threshold for example, or by changing the whole weighting scheme (e.g., equally-weighting each stock). Whatever portfolio construction approach we choose, the reality is that we won’t be able to “meaningfully” change things (i.e., increase risk-adjusted returns). That’s because all our assets belong to the same asset class: stocks. And whenever there are big shocks like a pandemic or a war, the idiosyncratic component of a stock return is overwhelmed by systematic factors (the beta), making diversification worthless.</p><p>So, what can we do if we want to construct a portfolio that is more resilient during such shocks, but that keeps outperforming our benchmark at the same time? Well, there are many possible answers to this question, but a simple one would be to take the opposite side of the risk, i.e. short selling stocks with part of our capital. Let’s see how we can accomplish this and if we can improve our results.</p><p><strong>… short</strong></p><p>Ok, good! We identified a possible solution to improve our long book, by including in our portfolio a short book. This should (in theory) reduce our portfolio beta and produce smoother returns. But which stocks should we short sell? Should we short them based on their fundamentals? How long should we keep our short positions open? Well, once again, there are no right or wrong answers to such questions. First, we need to understand that shorting poor companies is a completely different exercise than going long good ones. Professional short sellers know it well. In fact, you cannot simply short a stock because it has poor fundamental metrics: many companies with dreadful balance sheets can deliver astonishing returns based on investors’ future expectations, or simply because market sentiment is so bullish. It’s very dangerous shorting a stock unless there is a strong conviction on its downside (based on super-thorough fundamental research). An old adage goes saying that markets can remain irrational longer than you can remain solvent!</p><p>Hence, the “safest” way for us to take the other side of the risk would be to open positions that are not based on the fundamentals, but on the “<em>technicals</em>”. And to reduce our “<em>duration risk</em>”, we’ll maintain our short positions open for no more than a specific time interval (e.g., 20 days). In other words, we can look for specific price patterns that raise the chance for a short-term correction in any given stock. Ok, but… which stocks should we screen for such patterns, then? Well, liquidity is key when trading stocks, but it’s of paramount importance when you are on the short side. Therefore, we should short only the most liquid stocks, like those in the S&amp;P 500 index. Of course, we don’t want to short those stocks that we hold in our long book, so we need to remove those 60 names from the others making up the S&amp;P 500.</p><p>Now I am gonna show you now how to leverage machine learning models to get short selling recommendations on these stock universe. We’ll then implement a back-test to see how such recommendations have worked out in our case. Since there are many steps involved in the following paragraphs, I think it’s useful to first outline the process followed to get to our final results. Here are the steps followed:</p><ol><li>Collection of S&amp;P 500 data from yahoo!Finance (OHLC and Volume historical data).</li><li>Clustering S&amp;P 500 stocks into four different groups (i.e., clusters), after proper data pre-processing.</li><li>For each stock in each cluster, we first calculate various technical analysis indicators (we use these indicators as our features for our machine learning models).</li><li>We add a label column (i.e., a target variable) for each stock in each cluster that can take two values: <em>1</em>, if the stock price drops by more than 5% over the next 20 days, and if over this same time-frame there is an upward move smaller than 3%; <em>0</em>, in all other instances.</li><li>For each cluster, we develop a machine learning model whose aim is to classify each observation in our data as either 0 or 1 (to train and validate our models, we take one candidate from each cluster).</li><li>Then, we deploy our four selected models to all the other stocks in each of the four cluster to get short recommendations (each cluster has its own model).</li><li>Finally, we aggregate the results from each cluster in a single dataset that we can use for a back-test (we go short a stock if on any given observation we have a value of 1).</li></ol><p>Ok, this might seem complicated, but the intuition behind this approach is pretty simple. We want to limit the number of potential forecasting models to four, because this is the most significant number of clusters grouping stocks behaving similarly. Hence, the biggest of all the assumptions undertaken so far: the same model trained and validated on a specific stock, should perform decently on another stock belonging to the same cluster of that stock. In fact, it would have been impractical to develop a machine learning model for every single stock in our universe (roughly 440 names!). In this way, we keep things simple, while giving our four models a way to test their goodness in an out-of-sample fashion (in fact, each other stock’s data are effectively unseen data for our models).</p><p>Alright, let’s break this elephant into small bites! First, we said that we need to collect our data for the stocks making up the S&amp;P 500 index. I have used yahoo!Finance for the OHLC/Volume data and I have scraped a Wikipedia table to get other data like date of inclusion in the index, foundation year, etcetera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*Apjrw6uBuBlxKK-ONUS5DA.png" /><figcaption>Source: Wikipedia</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*xzFCSIu5w_i0euTuTZMZlA.png" /><figcaption>Source: yahoo!Finance</figcaption></figure><p>I had to drop approximately 10 names for which inconsistent or no data were available, but this hasn’t affected my analysis, since I have plenty of stocks to short potentially. Here, I managed to get data since 2014, but I decided to use only data from 2020, because I had to deal with survivorship bias. Furthermore, I have used not daily but weekly returns for my clustering exercise, since I used more years than previously (i.e., only the year 2019). Please, note that here I indeed relaxed the look-ahead bias “guardrail”, by assuming that clusters won’t change over time. Otherwise, I should have used data till 31/12/2019 to calculate clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*dLgzyeTLDY_-25ySqmdGFg.png" /><figcaption>Clustered S&amp;P 500 using weekly returns from 2020</figcaption></figure><p>Here, it’s impossible to read the tickers of the stocks belonging to each calculated cluster, but you can easily identify four colors, one for each identified cluster. Below, you can see the breakdown by stock ticker for each cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*xljn3SJmJIq1tXMhSloCKQ.png" /></figure><p>Now I am going to detail the steps followed for each cluster, even if I am only going to show this for cluster_0 (the steps are exactly the same for all the other three clusters).</p><p>The first thing we need to do is to select a “champion” (i.e., a candidate) on which to train and validate our model. In this case, since I needed to prevent from look-ahead bias, I decided to pick the candidate with the longest inclusion in the index. For example, in the case of cluster_0, 3M (ticker symbol MMM) was added on 04/03/1957, hence has the longest inclusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*motRLgm6a-X5IbFliSNp5w.png" /><figcaption>Source: Wikipedia</figcaption></figure><p>The next thing to do is to calculate our features for 3M, based on OHLC/Volume data. These are technical indicators such as Bollinger Bands, RSI, ATR as well as candlestick patterns like Doji, Hammer, Engulfing, etcetera. I did this conveniently by using the talib python library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*v7ioM7KEjDIvFz7MABIo1g.png" /><figcaption>Calculating the “features”</figcaption></figure><p>This way, we end up having more than 35 technical indicators. Now, we only need a target variable to let our model learn in the training phase. I calculated it as reported above, by assuming that if over the following 20 days:</p><p>a) the stock falls by more than 5% and</p><p>b) it doesn’t appreciate by more than 3%</p><p>I get a value of 1 (hence, go short), otherwise I get a value of 0 (no action).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*SSXkVlwJKdUD9b4wue0b5A.png" /><figcaption>Calculation of the label column</figcaption></figure><p>At this stage I would be ready to train a supervised machine learning model, because I have features and a label. But the problem with most machine learning models, is that they are not all suitable to deal with time-series (where time dependencies matter the most). Deep learning models like RNN, GRU or LSTM are generally a recommended options for non-linear problems with time-series. But these models are very complex to build and their hyper-parameter tuning may require weeks if not months, given the huge number of parameters to fine tune. Hence, I opted to use a classifier that can handle well non-linear problems, while allowing me to optimize the hyper-parameter tuning with a classic GridSearchCV. The model I opted for this problem is random forest. The reasons why I chose it over other models like Logistic Regression, KNN, Decision Trees, or XGBoost are:</p><ol><li>It is pretty flexible</li><li>No need to normalize my features</li><li>It handles well highly correlated features (like features calculated from OHLC/Volume data)</li></ol><p>In order to overcome the time dependency issue, I have simply augmented my feature space by calculating rolling means and rolling standard deviations of my original features (20 and 60 days rolling statistics). I have also included a column with the day of the week. This is a very simple and effective way to make sure that temporal dependencies are somewhat taken into consideration by models that were not created for this purpose.</p><p>Now that we have our dataset ready, we need to split it into three partitions: training, validation and test. The first one will be dedicated to training the model; the second one will be used to fine tune our hyper-parameters; the last one will be our “moment of truth”, to make sure that our model was not over/underfitting the data used in the other two partitions. For this exercise, I used 70% of the data as my training set, 20% to validate and the remaining 10% for testing the model with unseen data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*FGa_usSH8BJq41XLJ5NSwA.png" /><figcaption>Splitting dataset into training, validation and test sets</figcaption></figure><p>For the random forest model, I have fine-tuned five hyperparameters in GridSearchCV:</p><ol><li>Number of trees in the forest</li><li>Max depth</li><li>Max features</li><li>min_samples_leaf</li><li>min_samples_split</li></ol><p>I have also balanced the class_weight parameter in the training step to avoid any model bias depending on the class frequency. An important consideration to mention here: since shorting a stock when it is soaring is more painful than not shorting a stock when it is indeed tanking, I tweaked the model to label as 1 only those observations with a threshold of 60% probability to be classified as 1. This was done to increase the precision of the model to the expense of other metrics like recall. In fact, if we take action (i.e., we short) when we are wrong, we loose money. While if we don’t take action when we should, we don’t make money, but we don’t lose it either. This tweak will make sure that we will only go short when chances are “really” on our side. Below you can find the results of the training and validation step for model_0 (i.e., the model developed for the stocks grouped in cluster_0).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*8rOdxWW-yNRbA_KH2CZQGQ.png" /><figcaption>Training and validation classification report for cluster_0 model</figcaption></figure><p>As you can see from the report above, the model maintains strong precision metrics for both classes in both data sets, while recall precipitates dramatically in the validation set. That’s acceptable as we explained already, as it’s better to give up some good shorts to avoid false positives that can cost a lot in terms of lost money.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*YQoT1F3_xEDy_sI1EO41GA.png" /><figcaption>Confusion matrix for validation set of model for cluster_0</figcaption></figure><p>What about the test set? Well, it seems that we managed to maintain the same level of precision for both classes as compared to the validation set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*6B5q7-W-hTiKLuA1mgxAIg.png" /><figcaption>Test classification report for cluster_0 model</figcaption></figure><p>Once again, we can notice that we are indeed giving up on many shorting opportunities, but we are also reducing limiting our wrong short to 6 instances (i.e., only 6 false positives).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*kE5jQuWsIDEEbUxSrsfEIQ.png" /><figcaption>Confusion matrix for test set of model for cluster_0</figcaption></figure><p>Marvelous! Now we simply repeat the same steps by training a new model on a candidate taken from each of the other three clusters. In total we will have four selected models, that we will deploy on the others stocks depending on the cluster they belong to. I will show below only the results for the test sets of the other three clusters, as they are the most important ones for our goal. In all instances, I controlled over/underfitting, as the difference between precision (our favorite metric) in the training, validation and test sets remains within -/+ 5%, an acceptable threshold. Furthermore, in all other cases false positives remain at a level that is tolerably low.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*DFB941mrFFSeb4GhGNSRjQ.png" /><figcaption>Test classification report for cluster_1 model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*RE--9ARdASwYucwU4lOZLQ.png" /><figcaption>Confusion matrix for test set of model for cluster_1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*oBfQoPXN3efdzOZ57Dgb9Q.png" /><figcaption>Test classification report for cluster_2 model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*iuEx477jEIqVa_lOCi7nTw.png" /><figcaption>Confusion matrix for test set of model for cluster_2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*P0-YGpF5yRYf-NM87eMHVw.png" /><figcaption>Test classification report for cluster_3 model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*ThEoh54Ild6eawiskxGbPQ.png" /><figcaption>Confusion matrix for test set of model for cluster_3</figcaption></figure><p>For each cluster, we can appreciate the frequency of short signals detected from the above models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*MfaQWbe0PCJDJi4rJn-oeA.png" /><figcaption>Count of 1s for cluster_0</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*FSut6vIJP7_cr3AqEwcNYA.png" /><figcaption>Count of 1s for cluster_1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*V2-2lHLGM3jYLxhQj_S7lw.png" /><figcaption>Count of 1s for cluster_2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*wLaHKTiECVZXHKejHGwR3Q.png" /><figcaption>Count of 1s for cluster_3</figcaption></figure><p>Once the models are applied to the relevant stocks, we get our final dataset containing predictions (either 0 or 1) for every sample. I have excluded from the dataset the four stocks used as candidates to train the models, so to avoid any bias in the back-test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*MBTmVwzrBbIyHzXpqX2XOA.png" /><figcaption>Dataset with short sales predictions</figcaption></figure><p>Now we can create our back-test by calculating the PnL of our strategy. The conditions when a value of 1 is present are:</p><ol><li>We do not open a position on a stock, if a short position is already open</li><li>We set our stop loss on each position to 4%</li><li>Our max holding period for any position is 20 days</li><li>Max weight for each stock if number of open positions &lt; 10 is 10%</li></ol><p>The above parameters are fully discretional and can be tweaked depending on an investor’s goal, risk constraints, risk aversion, etcetera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*uTTgnsVJTNtZwlQ5XS-iRQ.png" /><figcaption>Cumulative returns short book</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*74j3kJoTuUhTwfQwQEOkmQ.png" /><figcaption>Drawdown plot for short book</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*QDQ0guEXt5oBpZgrCx9sZA.png" /><figcaption>Distribution of returns for short book</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*W9GRwGmcwkuJU6FSsskH7A.png" /><figcaption>Back-test metrics for short book</figcaption></figure><p>As we could have expected the bulk of our PnL has been done in 2020 during the pandemic period (when most stocks were in free fall), while it suffered in 2021 and 2024 (until 30th August). 2022 was a flat year, even if the strategy did well for three quarters of the period, while 2023 proved to be a positive, despite mean-reverting year. The annualized return is 1.6%, with a max drawdown of 7% (a fraction of our previous back-test). Sharpe ratio remains positive, but lower than our long book, while daily VaR has improved substantially. This is because our short strategy provides a low number of signals, since we stressed precision as our focused metric.</p><p>Now we’ll finally find out if we can get the best of both worlds by combining our long and short books in a long/short strategy.</p><p><strong>A long-short story</strong></p><p>There are many approaches to alternative strategies like long/short equities:</p><ol><li>Long-biased</li><li>Equity-Market Neutral</li><li>Short-biased (very very rare)</li></ol><p>Typically, professional money managers use leverage to run such strategies, and they can choose to short stocks directly, or to use other instruments like single stock CFDs. In some cases, index futures are used for the short book (especially in EMN strategies). In our case, I wanted to test the combination of a long/short portfolio with a net exposure of +50% (gross exposure 150%, 100% long and 50% short). Here are the results of my back-test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*OMLtuamiKi_Js73GzvlGqA.png" /><figcaption>Comparison of cumulative returns for the two strategies vs the benchmark</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*vi3GF-TRLrXIJKSAjhS9RA.png" /><figcaption>Back-test metrics comparison for the two strategies vs the benchmark</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*GbVAFQlwDEwTibsy2Bd84A.png" /><figcaption>Back-test metrics for the long/short strategy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*jm9V9iEJEYBVD9OSvL2qkw.png" /><figcaption>Distribution of returns for long/short strategy</figcaption></figure><p><strong>Happily ever after?</strong></p><p>If you remember, our goals at the end of the long-only back-test were to:</p><ol><li>Creating a portfolio which is more resilient to shocks,</li><li>While keep beating the benchmark</li></ol><p>Well, we definitely accomplished goal n. 2, because our short book added some extra value to our long/only book in terms of returns. But we can’t claim to have accomplished goal n. 1 in full, since volatility and max drawdown did not decrease as we hoped. Nonetheless, we can see pretty well that during the most acute phase of the pandemic (February and March 2020) our long/short strategy proved to be indeed more resilient than our long/only book.</p><p>Key takeaways are:</p><ol><li>We can build superior portfolios simply by selecting stocks with good quality metrics, and by finding sensible approaches to portfolio construction (e.g., Hierarchical Risk Parity).</li><li>We can improve our risk-adjusted returns by shorting stocks that exhibit specific patterns.</li><li>Such patterns can be detected using machine learning models, like random forests, XGBoost, etcetera.</li><li>Shorting is a very different exercise than buying stocks, so unless we are confident on our thorough research, a short strategy based on technical patterns with a good money management can be a safer approach.</li></ol><p>There are many ways in which this exercise can be improved: we can try different levels of gross exposure in our long/short portfolio; we can include stocks ex-USA for our short book; we can set different money management parameters for our short book; we can adopt a more dynamic approach for our long-only book (e.g., repeat the HRP on an annual basis to the selected group of stocks); etcetera…</p><p>I hope you enjoyed this article, and that it will stimulate further research in this field.</p><p>You can find the full python notebook here:</p><p><a href="https://github.com/babyloncapital/python_projects/blob/main/Long%20Short%20portfolio-ML.ipynb">https://github.com/babyloncapital/python_projects/blob/main/Long%20Short%20portfolio-ML.ipynb</a></p><p><strong>THE END</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yxbNwv15JH9la8FQ" /></figure><p><em>Disclaimer: The content of this article doesn’t constitute investment advice nor any offer or solicitation to offer or recommendation of any investment product. It is for research purposes only, and does not take into account your individual needs, investment objectives and specific financial circumstances.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64c3eec2a5df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Learning for Tactical Asset Allocation]]></title>
            <link>https://medium.com/@lucadonghi_25036/deep-learning-for-tactical-asset-allocation-b7065aa68bc1?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7065aa68bc1</guid>
            <category><![CDATA[tactical-asset-allocation]]></category>
            <category><![CDATA[lstm-networks]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[mean-variance]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Sat, 20 Jul 2024 17:22:24 GMT</pubDate>
            <atom:updated>2024-07-20T17:22:24.974Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBOnLa7nJWU7uV7dJYGS0g.png" /><figcaption>Source: ChatGPT</figcaption></figure><p>In this article I am going to show how Deep Learning models can be effectively used for tactical asset allocation (TAA), and how they can be a superior choice compared to traditional optimization techniques such as mean-variance optimization. We’ll start by understanding the differences between Strategic Asset Allocation (SAA) and Tactical Asset Allocation (TAA), and then we’ll see how we can dynamically adapt our portfolio allocation over time in a systematic fashion using walk-forward optimization. After that, we’ll see how the same goal can be accomplished using deep learning, specifically through Long Short-Term Memory (LSTM), and how these models address the limitations of more traditional techniques. Finally, we’ll understand how we can include exogenous variables to our deep learning model to determine optimized portfolio weights. The following work has been accomplished using Python as programming language to run the proposed models, while market data are taken from yahoo! finance.</p><p>There is a link at the end of the article for those who want to have a look at the entire Python code.</p><p><strong>Sections:</strong></p><ol><li>SAA vs TAA</li><li>Investment Universe</li><li>Mean-Variance Optimization (MVO)</li><li>Walk-forward MVO</li><li>Walk-forward with LSTM</li><li>Walk-forward with LSTM using exogenous features</li><li>Conclusions</li></ol><p><strong>SAA vs TAA</strong></p><p>If we take the Investopedia’s definition, we can define Strategic Asset Allocation simply as<em>“[…] a </em><a href="https://www.investopedia.com/terms/p/portfolio.asp"><em>portfolio </em></a><em>strategy. The investor sets target allocations for various asset classes and </em><a href="https://www.investopedia.com/terms/r/rebalancing.asp"><em>rebalances</em></a><em> the portfolio periodically. The portfolio is rebalanced to the original allocations when they deviate significantly from the initial settings due to differing returns from the various assets.</em>” The factors influencing SAA choices can be the investor’s risk tolerance, time horizon, and investment objectives. Compared to Tactical Asset Allocation, this approach is quite passive, even if every investor can allow for different levels of deviations, or deciding to rebalance the portfolio with different periodicities (monthly, quarterly, annually) according to his/her preferences. On the other side, “<em>Tactical asset allocation is an </em><a href="https://www.investopedia.com/terms/a/activemanagement.asp"><em>active management</em></a><em> portfolio strategy that shifts the percentage of assets held in various categories to take advantage of market pricing </em><a href="https://www.investopedia.com/terms/a/anomaly.asp"><em>anomalies</em></a><em> or strong market sectors. This strategy allows portfolio managers to create extra value by taking advantage of certain situations in the marketplace</em>.” In this case, the approach used is more dynamic compared to SAA, and can entail different levels of deviations from an original SAA. Typically, SAA and TAA are applied to a multi-asset context, in which we have different asset classes with different risk profiles (e.g., equities, fixed income, commodities, etc…). Nonetheless, the same approach can be used within a single asset class (e.g., equities): for example, one can apply TAA to dynamically change weights across different equity sectors (from more sensitive to more defensive sectors), or fixed income sectors (from short-term to long-term bonds, or from investment grade to high yield). The investor’s markets view will ultimately orientate the asset allocation choice in the portfolio.</p><p><strong>Investment Universe</strong></p><p>For this article, I have selected a wide range of asset classes, so to have different risk profiles among the assets composing the portfolio. These are:</p><ul><li>US equities</li><li>European equities</li><li>Japanese equities</li><li>Emerging Markets equities</li><li>US government bonds</li><li>Global inflation-linked bonds</li><li>Investment grade corporate bonds</li><li>High-yield corporate bonds</li><li>Emerging Markets bonds in hard currency</li><li>Emerging Markets bonds in local currency</li><li>Commodities</li><li>Gold</li></ul><p>For each asset class I have chosen a listed ETF to represent that market. All the data were taken from yahoo! finance (<a href="https://finance.yahoo.com/">https://finance.yahoo.com/</a>), through the <em>yfinance</em> Python library (all assets’ prices are in USD). The assets selected are the following:</p><ul><li>IVV: iShares Core S&amp;P 500 ETF</li><li>IEV: iShares Europe ETF</li><li>EWJ: iShares MSCI Japan ETF</li><li>EEM: iShares MSCI Emerging Markets ETF</li><li>TLT: iShares 20+ Year Treasury Bond ETF</li><li>LQD: iShares iBoxx Investment Grade Corporate Bond ETF</li><li>EMB: iShares J.P. Morgan USD Emerging Markets Bond ETF</li><li>HYG: iShares iBoxx High Yield Corporate Bond ETF</li><li>GSG: iShares S&amp;P GSCI Commodity-Indexed Trust</li><li>IEML.L: iShares J.P. Morgan EM Local Govt Bond UCITS ETF</li><li>IGIL.L: iShares Global Inflation Linked Govt Bond UCITS ETF</li><li>IGLN.L: iShares Physical Gold ETC</li></ul><p>Let’s first analyse how these different asset classes have performed over time, by looking at their cumulative returns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*ALW4VgF65r8l7Dl_3g3FHg.png" /><figcaption>Source: yahoo! finance — Cumulative returns of asset classes over time</figcaption></figure><p>With yahoo finance, you can’t go back too much in time with historical prices, so our analysis can only start from 31/12/2012. Nonetheless, we have a decent overview of how each asset class behaved over the past decade. For example, we can see that Developed Markets equities (IVV, IEV and EWJ) have reported the best results, while Emerging Market equities (EEM) lagged behind. At the same time, commodities (GSG) underperformed until the first half of 2020, but then recovered quickly along with higher inflation.</p><p>There are tenths of reasons for why these asset classes have behaved differently over the period considered, but it’s not the goal of this article to explain them. What is more interesting to note for our goals, is that in each period some asset classes outperformed, while other underperformed. Therefore, if we find a way to tactically shift our weights in the right direction, we might end up with a superior allocation compared to an equally-weighted portfolio, or compared to a static allocation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*vnId70EPwkkEamJvfQ_rnw.png" /><figcaption>Source: yahoo! finance — Annual returns by year for each asset class in our investment universe</figcaption></figure><p>It’s also interesting to look at correlations when working in a multi-asset context, as diversification is considered to be the only “free lunch” in finance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*Ja_wujV9FAp9lBcBg023BA.png" /><figcaption>Source: yahoo! finance — Correlation matrix of asset returns</figcaption></figure><p>From the correlation matrix above, we see that assets within the same asset class tend to be more correlated (e.g., US and European equities), while the opposite is true for assets belonging to different categories (e.g., US Treasuries and EM equities). It’s important to note that the above matrix reports just a static picture of asset correlations, but these can change dramatically over time: for example, in 2022 (when Russia invaded Ukraine, and inflation started soaring) the correlation between stocks and bonds rose toward 1, meaning that it was impossible to effectively diversify a portfolio, because both asset classes moved in tandem.</p><p>Now that we have analyzed our asset classes universe, let’s understand how we can optimize a portfolio based on assets’ returns.</p><p><strong>Mean-Variance Optimization (MVO)</strong></p><p>If you have (as in our case) many assets composing your portfolio, it can be challenging to decide how to allocate weights in the best possible way. We have seen the difference between a static (SAA) and a dynamic (TAA) approach, and we have noticed how asset classes’ performances change from time to time. Luckily for us, there are many optimization techniques from which to choose from. Some of these are:</p><ul><li>Mean-Variance</li><li>Black-Litterman</li><li>Risk Parity</li><li>Minimum Variance</li><li>Equally-Weighted</li><li>Hierarchical Risk Parity</li><li>Robust Optimization</li></ul><p>It’s not the purpose of this article to analyze main pros and cons of each of these techniques, but there is a wide literature available on the web for curious readers. Here, I chose to pick the “classic” mean-variance optimization as a starting point for our analysis, as it is widely accepted and adopted in the financial industry.</p><p>Mean-variance optimization, introduced by Harry Markowitz in 1952, is a fundamental portfolio optimization technique that balances return and risk. In a nutshell, in this optimization technique you need to combine assets in a thousands of different portfolios, and then you pick the portfolio with the highest mean-variance ratio (the so called “Tangency Portfolio”): in other words, the portfolio which delivers the highest return per unit of risk. The concept can be grasped easily: as a rational investor, you want a portfolio that maximize your returns, but which takes into consideration risk (represented by the standard deviation).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*4RzgnYUgHpT0UxNfa2eekg.png" /><figcaption>Source: Quantpedia — Efficient frontier</figcaption></figure><p>Therefore, if we want to come up with a SAA based on the Tangency Portfolio, all we have to do is to create a big number of possible combinations of various assets’ weights, and pick the one lying on the tangency of the capital market line. Then, we simply need to rebalance our portfolio periodically, or whenever assets’ weights deviate too much from our target weights.</p><p>So far, so good! But what if we want something more dynamic? What if we want to frequently review such weights, especially if considering that the market environment changes quite frequently (as we have seen with asset classes’ returns)? Well, let’s find out in the next section.</p><p><strong>Walk-forward MVO</strong></p><p>Imagine that you have a dataset of asset returns that spans from 31/12/2012 to 31/12/2023 (as in our case). Now, what you can do to back-test the effectiveness of our mean-variance optimization (from now on MVO) is to split the dataset into two periods: the first one, in which you calculate the optimized weights by applying the MVO; and the second one, in which you back-test the portfolio’s weights obtained in the previous step. For example, you can decide to use the portion of the dataset that ranges from 31/12/2012 to 31/12/2019 for applying the MVO and calculate our weights, and leaving the portion ranging from 31/12/2019 to 31/12/2023 for performance evaluation. This looks simple and intuitive, but also quite naive, unfortunately. In fact, with such approach, MVO would not consider in its optimization those market environments that occurred in the second part of our dataset (like the Covid-19 pandemic, or the conflict in Ukraine). You may end up optimizing your allocation without considering important scenarios, for which your portfolio might not be adequately constructed. This is especially true if (as in our case) you have a relatively short history of assets returns. For example, the highly inflationary period that we have particularly experienced from 2020 to 2023, would be more similar to the one occurred in the 1970s, than to the period 2012–2019. A much better approach is to use something called “Walk-forward optimization”.</p><p>Walk-forward optimization is a technique that helps us in achieving a more dynamic allocation, since we keep re-calculating optimized weights over different periods of time by splitting our dataset in many time windows. These can be fixed (as in the picture below), or expanding (in which the optimization dataset keeps expanding as we move forward in time).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*m8WDWHg2FqgicNmFEkNv-A.png" /><figcaption>Source: <a href="https://caioagrizzi.medium.com/practical-example-of-walk-forward-analysis-for-systematic-trading-5a31ecca31ec">https://caioagrizzi.medium.com/practical-example-of-walk-forward-analysis-for-systematic-trading-5a31ecca31ec</a> — Walk-forward optimization using fixed window</figcaption></figure><p>The advantage of this approach is that we can keep into consideration changes in the market environment, as asset prices will reflect this in their performances. Furthermore, some macroeconomic conditions can be quite persistent (e.g., rising inflation, or economic weakness), giving us sufficient time to recalibrate our allocation if we re-optimize the portfolio regularly.</p><p>So, let’s see how this technique would have performed if we re-optimize weights roughly every quarter, and apply such weights at the start of each following quarter.</p><p>But before diving into the results of our experiment, let’s first have a look at the assumptions/criteria used:</p><ul><li>Portfolio performance assessed against an equally-weighted benchmark</li><li>Fixed window for optimization equals to 60 trading days (roughly a quarter)</li><li>Fixed window for back-testing equals to 60 trading days (roughly a quarter)</li><li>Risk-free rate used in the mean-variance calculation equal to 2%</li><li>Long-only portfolio with no leverage (i.e., no negative weights, and max allocation is equal to 100%)</li><li>For the first 60 days of the back-test, we assume the portfolio to be equally-weighted, as we can’t apply MVO in the first time window</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*c50LEnwbd6mVZYwUpzCubQ.png" /><figcaption>Back-test using Walk-forward MV optimization</figcaption></figure><p>From the back-test above we can see that the Walk-forward optimization (WFO) reaches an average Sharpe of 0.23 over the back-test, less than half the risk-adjusted return of the equally-weighted portfolio. Cumulative returns are roughly equal at the end of the back-test, but volatility is much higher for the MVO portfolio. In fact, the problem with traditional portfolio optimization techniques like MVO, is that they rely on many simplistic assumptions, which can affect the final performance of our portfolio.</p><p>Now let’s see if deep learning can come to the rescue, addressing the issues of traditional optimizers.</p><p><strong>Walk-forward with LSTM</strong></p><p>First things first! What is deep learning? Well, deep learning is a subset of machine learning that uses multi-layered artificial neural networks to model and understand complex patterns in large datasets. It excels at tasks like image recognition, natural language processing, and game playing by learning hierarchical representations of data through layers of neurons. In other words, the machine learns intricate patterns through each layer of the model: in the first layers, some patterns are “discovered”, and these “discoveries” are then passed onto the subsequent layers to improve the learning process.</p><p>Unlike traditional machine learning models, which rely on manual feature extraction and selection, in deep learning models the machine learns feature representations from raw data through multiple layers. Furthermore, deep learning presents many advantages compared to traditional MVO:</p><ul><li><strong>Non-linear patterns</strong>: traditional MVO stick to linear assumptions on market trends, but we often observe non-linear patterns among our data, hence making traditional optimization a less effective way to handle our allocation problem;</li><li><strong>Exogenous variables</strong>: while in MVO we exclusively rely on past returns to determine optimized weights, with deep learning we can include in our model other endogenous (e.g., OHLC, volume, price-determined indicators) and exogenous (e.g., intermarket data, macroeconomic data) variables (or features in machine learning jargon). These extra features can help our model in better understanding the existing non-linear relationships, thus improving our results;</li><li><strong>Time effects</strong>: while traditional optimization techniques assume that asset returns are independent and identically distributed over time (which is not the case in financial markets), AI-based technique allow for considering trends, seasonality or changing volatility regime.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*IVgfHTsgzikpfIelXcyipg.png" /><figcaption>Source: <a href="https://tanzanite.ai/adventures-in-ai-crafting-optimal-neural-networks/">https://tanzanite.ai/adventures-in-ai-crafting-optimal-neural-networks/</a> — Deep Neural Network structure</figcaption></figure><p>Alright, we have seen some advantages of deep learning methods over traditional MVO, but we said that in our exercise we would have used a specific deep learning model named Long Short-Term Memory (LSTM). So the next question is: what is a LSTM model?</p><p>Essentially, LSTM are a form of neural networks designed to capture long-term dependencies in sequential data. This means that they’re well suited for time-series and, unlike traditional Artificial Neural Networks (ANN), they have an additional component called “memory cells”. These special cells help storing time-series data and capture the temporal dependencies over the long sequences of data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*3NQX3yOgoej9myWY6Cznxw.png" /><figcaption>Difference between traditional RNN and LSTM</figcaption></figure><p>Explaining in details how an LSTM cell is structured or how backpropagation works is out of the scope here, but I encourage you to find more on LSTM and neural networks at the following link: <a href="https://blog.quantinsti.com/introduction-deep-learning-neural-network/">https://blog.quantinsti.com/introduction-deep-learning-neural-network/</a></p><p>Having briefly touched on what LSTM models are, and why they are considered a good choice for time-series, let’s now see if they can improve our results for our TAA goal.</p><p>LSTM models are among the most difficult models to calibrate, because of their numerous hyper-parameters (these are parameters not learned by the model itself, but they are manually set before running it). For these reasons, I tried to avoid overcomplicating things with super sophisticated models, but I followed the Occam’s Razor principle: simple is better!</p><p>In this case, I have used the following hyper-parameters in my model:</p><ul><li>One hidden layer with size 64</li><li>kernel_regularizer “l2”</li><li>recurrent dropout = 0.1</li><li>kernel_initializer = glorot_uniform</li><li>activation function for the hidden layer = tanh</li><li>activation function for output layer = softmax</li><li>optimizer used is RMSprop</li><li>loss function aims at minimizing the negative Sharpe ratio with a risk free rate of 0.02 (minimizing the negative Sharpe means maximizing the positive Sharpe)</li><li>Window of 60 days for optimization, and 60 days for the back-test (as we did for MVO)</li><li>Number of epochs used is 100, with patience set at 3</li><li>Lookback of 20 (i.e., roughly a trading month)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*1wJjkXwxSRat9O8KHIh3PA.png" /><figcaption>Back-test using Walk-forward LSTM optimization</figcaption></figure><p>From the chart above, we can see that we dramatically improved our results. In fact, we not only managed to beat an equally-weighted portfolio in terms of cumulative returns, but we also achieved a higher Sharpe ratio (0.57 vs 0.54). We can see how the model reported particularly strong results in 2022, a very difficult period for most asset classes due to rising correlations. Let’s now compare the most important back-test metrics obtained with MVO and LSTM using the pyfolio library:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*WPzridB736qB0OOhABQk4Q.png" /><figcaption>MVO vs LSTM back-test stats</figcaption></figure><p>It seems that most stats look better in the LSTM case, as it shows higher risk-adjusted returns, a lower max drawdown and higher stability. At the same time, MVO looks to be less correlated to the equally-weighted benchmark, since it reports a negative beta.</p><p>But before popping champagne and starting to celebrate these results, we need to carefully look into how they have been accomplished. First, let’s have a look at how allocation weights have changed over time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*vas8jTxTSFSYJRcchs2luQ.png" /><figcaption>Portfolio weights over time obtained by applying LSTM model</figcaption></figure><p>We note that some assets like Japanese equities (EWJ) or EM bonds in local currencies (IEML.L) are set around 0% for most of the time. Furthermore, most of the time our portfolio is allocated to a few asset classes only, which can be problematic for investors who want/need to keep a diversified exposure all the time. Additionally, given the relative small dataset and considering the nature of the problem, I had to regularize more than what is typically recommended to avoid overfitting. Finally, I have set the value of the hyper-parameter “rho” in the RMSprop optimizer at a level that is smaller than what is generally recommended, but I did it to make my model more dynamic.</p><p>As I said, such highly complex modes require lots of training, and tuning their hyperparameters could require a very long time. Now, let’s see what happens if we introduce some exogenous variables in our model.</p><p><strong>Walk-forward with LSTM using exogenous features</strong></p><p>We can think of any possible macroeconomic, financial or alternative time-series as features in a deep learning model. The most important thing to remember is to avoid introducing any look-ahead bias: for example, macroeconomic data for a specific period are generally released only in the following one (e.g., June inflation data are released in July). The problem here is that for most of the freely available datasets you won’t have access to the release date, hence potentially introducing look-ahead bias (in other words, you would not have had access to that piece of data at the moment your model perform its calculations). Furthermore, for macroeconomic releases you have to bear in mind that oftentimes such data are revised, and most available datasets only report the revised version (which, again, is a type of information your model couldn’t have access to in that particular point in time).</p><p>For the sake of simplicity (and honestly without too much research effort), I have selected a few features from the FRED website (<a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a>), using the Python library <em>fredapi</em>. These time-series have been selected because they have the following characteristics:</p><ol><li>They’re from a trusted source;</li><li>They have daily frequency, hence minimizing the risk of look-ahead bias;</li><li>They’re mostly market data, hence reducing the chances of them being revised;</li><li>They’re FREE!</li></ol><p>My goal here is to understand if, by providing extra information, the model can better understand the relationships within the data, hence improving its learning process. Like other traditional machine learning models (and like cooking), the quality and choice of the “ingredients” you use are of paramount importance (“garbage in, garbage out”). So, it’s key to spend enough time investigating which variables are more relevant for one’s forecasting task.</p><p>After these necessary premises, let’s have a look at the variables I selected for the LSTM model:</p><ul><li>10-Year Breakeven Inflation Rate (T10YIE)</li><li>5-Year Breakeven Inflation Rate (T5YIE)</li><li>ICE BofA US Corporate Index Option-Adjusted Spread (BAMLC0A0CM)</li><li>ICE BofA US High Yield Index Option-Adjusted Spread (BAMLH0A0HYM2)</li><li>ICE BofA US Emerging Markets Liquid Corporate Plus Index Option-Adjusted Spread (BAMLEMCLLCRPIUSOAS)</li><li>Crude Oil Prices: Brent — Europe (DCOILBRENTEU)</li><li>CBOE Volatility Index: VIX (VIXCLS)</li><li>Nominal Broad U.S. Dollar Index (DTWEXBGS)</li><li>Discount Window Primary Credit Rate (RIFSRPF02ND)</li></ul><p>So, now we have 9 extra features, besides our asset classes’ returns that we can use in our model. But before proceeding, it’s important to note that we need to scale our features before using them (and we have to do it dynamically, to avoid any look-ahead bias, once again!). If we don’t scale our features, we would end up having some of them weighing more than others during the learning process (biasing the whole model!). For this reason, I have used StandardScaler() over the whole optimization process, but making sure to fit_transform() only the training sets, and to only transform() each individual test window.</p><p>I have applied the same LSTM model described earlier, but this time with only half the regularization (to better balance overfitting and underfitting).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*ppQh-x7SKCA5vACOaExhLg.png" /><figcaption>Back-test using Walk-forward LSTM optimization with exogenous variables</figcaption></figure><p>Well, it seems we have further improved our Sharpe ratio versus the benchmark, even if our portfolio underperformed the EW portfolio for more than four years. Probably, there are better choices for the hyper-parameters, or the exogenous features do not add enough value in the learning process.</p><p>What about the evolution of our assets’ weights over time?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*rOHB1ukXSMtZu2R4HUq3pA.png" /><figcaption>Portfolio weights over time obtained by applying LSTM model with exogenous variables</figcaption></figure><p>It seems we get less extreme allocations compared to our previous LSTM case. This is encouraging, but still not really suitable for the average investor.</p><p>Let’s now compare the pyfolio backtest metrics for the three optimizers used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*ouYbLyszxsV4KK_2ZyIiew.png" /><figcaption>Comparison of various optimizers’ back-test stats</figcaption></figure><p>We note an improvement in risk-adjusted returns, but a worse maximum drawdown compared to our simpler LSTM version.</p><p><strong>Conclusions</strong></p><p>We can conclude that AI can add positive value to an optimization process. We have seen how deep learning models like LSTM can better handle non-linear relationships in time-series, and also how they can easily include external variables to improve results. We also discussed about the limitations of such models, like the need for regularization, or the time spent for tuning their numerous hyper-parameters. The allocation weights were in both LSTM models quite extreme, and not suitable for a typical asset allocation framework. But we can tackle such issues by using these outputs to adjust our allocation according to our allowed ranges. For example, if we get a very high weight for any specific asset class, we can use this piece of information to tilt our portfolio in that direction in a more gentle way, while respecting other constraints. Or we can simply impose min-max weights in the optimization process, so to make sure we never go above a specific threshold in any asset class. Moreover, we can do more efforts in researching what are the best exogenous variables to use in our model, ideally combining our domain knowledge with machine learning models. Finally, we can further improve our allocation by allowing the model to go both long and short, or by going above 100% (hence, allowing for leverage).</p><p>You can find the full Python notebook used following this link:</p><p><a href="https://github.com/babyloncapital/python_projects/blob/main/Deep%20Learning%20for%20TAA%20with%20Python.ipynb">https://github.com/babyloncapital/python_projects/blob/main/Deep%20Learning%20for%20TAA%20with%20Python.ipynb</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7065aa68bc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All Weather Vs Hierarchical Risk Parity: different approaches to asset allocation]]></title>
            <link>https://medium.com/@lucadonghi_25036/all-weather-vs-hierarchical-risk-parity-different-approaches-to-asset-allocation-cd777e89604e?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd777e89604e</guid>
            <category><![CDATA[risk-parity]]></category>
            <category><![CDATA[portfolio-optimisation]]></category>
            <category><![CDATA[asset-allocation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[hierarchical-risk-parity]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Sun, 04 Sep 2022 21:37:19 GMT</pubDate>
            <atom:updated>2022-09-06T21:51:15.078Z</atom:updated>
            <content:encoded><![CDATA[<p>I have recently approached Hierarchical Risk Parity (HRP) as a way to find an optimal portfolio allocation. Being a curious investors, I have decided to compare the results obtained backtesting an All Weather and a mean-variance optimised (MVO) portfolios against HRP. To make my analysis more thorough, I have also included a classic 60/40 portfolio as a benchmark. I have carried out my analysis in Python, given the large number of libraries available and the flexibility of this programming language.</p><p><strong>Sections:</strong></p><ol><li>What is Mean-Variance Optimisation?</li><li>What is an All Weather portfolio?</li><li>What is Hierarchical Risk Parity?</li><li>Data description</li><li>Baseline: 60/40 portfolio</li><li>MVO — Max Sharpe backtest results</li><li>All Weather backtest results</li><li>HRP backtest results</li><li>Comparing results across portfolios</li><li>Conclusions</li></ol><p><strong>What is Mean-Variance Optimisation?</strong></p><p>According to Investopedia,</p><blockquote>Mean-variance analysis is one part of <a href="https://www.investopedia.com/terms/m/modernportfoliotheory.asp">modern portfolio theory</a>, which assumes that investors will make rational decisions about investments if they have complete information. One assumption is that investors seek low risk and high reward. There are two main components of mean-variance analysis: variance and expected return.[…] If two different securities have the same expected return, but one has lower variance, the one with lower variance is the better pick. Similarly, if two different securities have approximately the same variance, the one with the higher return is the better pick.</blockquote><p>For example, with this kink of optimisation investors can identify the portfolio combining assets that results providing maximum expected return for a given level of risk (target risk), the portfolio with the minimum level of variance, or the portfolio with the maximum expected Sharpe ratio (i.e. the tangency portfolio). The idea is to generate thousands of combinations with the desired mix of assets, and then pick the combinations that lie on the so called efficient frontier. This is because any portfolio below the efficient frontier is considered sub-optimal, since investors can find an alternative with superior expected returns for the same risk level.</p><p>For the sake of comparison with HRP, I have decided to select the maximum expected Sharpe ratio portfolio, which is the one located on the tangent of the efficient frontier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*O7ENsTbd0Fzt-QmA3GRyzw.png" /><figcaption>Source: <a href="https://quantpedia.com/markowitz-model/">https://quantpedia.com/markowitz-model/</a></figcaption></figure><p><strong>What is an All Weather portfolio?</strong></p><p>Famous hedge fund manager Ray Dalio (founder of Bridgewater Associates, the world largest hedge fund) came up with a brilliant idea more than 25 years ago: his goal was to find an optimal allocation for his own wealth, an allocation that could navigate all kind of economic environments. He realised that the two main drivers (among the many) of asset classes performances are growth and inflation: therefore, if he could find a balanced asset allocation able to cope with all possible environments (rising/falling inflation/growth), he would have accomplished his goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*nMUeOOuOnryD57Git1Iccg.png" /><figcaption>Source: <a href="https://www.bridgewater.com/research-and-insights/the-all-weather-story">https://www.bridgewater.com/research-and-insights/the-all-weather-story</a></figcaption></figure><p>In the paper “The All Weather Story” (<a href="https://www.bridgewater.com/research-and-insights/the-all-weather-story">https://www.bridgewater.com/research-and-insights/the-all-weather-story</a>) the author demonstrates how different asset classes behave under different scenarios, and thus which ones an investor would hold, according to which quadrant market expectations fall in a specific moment. For example, if growth is falling (maybe because of an economic recession) nominal bonds and inflation-linked bonds would provide the best protection to one’s portfolio. Alternatively, in an inflationary environment, commodities and Emerging Markets debt would represent the “to-go” choice.</p><p>In general, the sources of return of any investment vehicle are given by the following equation:</p><p><strong><em>return = cash + beta + alpha</em></strong></p><p>The problem is that spotting the quadrant in which market finds itself at any given time, and try to time it (i.e. beating the market)is a very hard task, even for veteran investors. Therefore, the genius of the All Weather portfolio resides in getting rid of the “alpha” component of the equation, and thus focus exclusively on cash + beta. How? Well, by assigning an equal chance to every different risk bucket (i.e. to each “economic scenario”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*f9b0ue5sUPtyHj3ar69qPA.png" /><figcaption>Source: <a href="https://www.bridgewater.com/research-and-insights/the-all-weather-story">https://www.bridgewater.com/research-and-insights/the-all-weather-story</a></figcaption></figure><p>This idea turned out to be so appealing to asset allocators (e.g. pension funds managers), that Bridgewater Associates launched an All Weather fund open to institutional investors several years ago.</p><p><strong>What is Hierarchical Risk Parity?</strong></p><p>HRP is a machine learning algorithm, falling within the unsupervised learning category. It exploits the Euclidian (or others like Manhattan, L1, L2) distance to generate proximity tables and then agglomerate clusters of items (or in this case assets) together depending on some mathematical formula (like Ward, single, completion or average linkage). Once you have your clusters, you can then apply a classic risk parity allocation within each cluster, until you end up with clusters made of single assets.</p><p>I know… this sounds a little bit overwhelming, but don’t worry: let’s explain it in a more intuitive way. Suppose you want to organise a world tour to visit all the Seven Natural Wonders of the World.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*5PmUpjGPCnuif66XotlWtg.png" /><figcaption>Source: worldatlas.com</figcaption></figure><p>As you can see, they’re spread across the globe. So, where would you start to plan your trip? Probably, you would like to start clustering Wonders that are located in the same continent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*SnCyS7yYNjneipEkb8ggKg.png" /><figcaption>Source: worldatlas.com</figcaption></figure><p>Then, you may think about grouping together Wonders located in the same hemisphere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCjt3E8KUYysRDGm4YdvHg.png" /><figcaption>Source: worldatlas.com</figcaption></figure><p>Finally, you got your world tour of the Seven Natural Wonders!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DnsDpqLL5yuUa9uSmFwvQQ.png" /><figcaption>Source: worldatlas.com</figcaption></figure><p>Agglomerative clustering for financial problems applies the same logic, but instead of geographic coordinates, you can use other type of variables, like macroeconomic indicators or fundamental ratios. Let’s suppose you want to cluster group of stocks based on two metrics, e.g. ROE and Net Profit Margin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*9Tn2J0ibNVOGOra6WY6dBw.png" /><figcaption>Source: <a href="https://quantra.quantinsti.com/course/portfolio-management-machine-learning">https://quantra.quantinsti.com/course/portfolio-management-machine-learning</a></figcaption></figure><p>Given the chart above, you would probably start clustering together stocks within “closer distances” (e.g. GOOG and EA), and then forming bigger clusters (e.g. GOOG + EA with ATVI) until you have a single cluster with all the assets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*Fo3GnA7qburgSu-ugwu-MA.png" /><figcaption>Source: <a href="https://quantra.quantinsti.com/course/portfolio-management-machine-learning">https://quantra.quantinsti.com/course/portfolio-management-machine-learning</a></figcaption></figure><p>This clustering process is generally visualised through a particular chart named dendrogram, where you can see how different clusters are formed based on agglomerative clustering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*CfV47o5nuUOh-yntyPQn3A.png" /><figcaption>Source: <a href="https://quantra.quantinsti.com/course/portfolio-management-machine-learning">https://quantra.quantinsti.com/course/portfolio-management-machine-learning</a></figcaption></figure><p>Once having obtained the different clusters, we can work backwards and apply risk parity (i.e. each asset contributes to portfolio volatility in equal amount) to find optimal weights within sub-clusters, until we end up with clusters made of single assets. This way, we can benefit from the typical low volatility of risk parity portfolios, while avoiding to over-weight a certain sector or asset class. The problem with traditional risk parity portfolios is that you may end up over-allocating to some sectors due to their historical low volatility contribution (e.g. healthcare or utilities). But, imagine that an unexpected negative event (e.g. a new government regulation) impacts the whole sector: your low volatility goal through risk parity would fail in this case. HRP offers an alternative solution that avoids this pitfall, as assets are clustered together based on the similarity of the pre-selected features.</p><p><strong>Data description</strong></p><p>In order to perform my analysis, I have selected six different ETFs as proxies for the asset classes described in the above “All Weather Matrix”. Specifically, I have selected six ETFs:</p><ul><li>iShares MSCI ACWI (ACWI) for equities;</li><li>Invesco 1–30 Laddered Treasury (PLW) for nominal bonds;</li><li>iShares TIPS Bond (TIPS) for inflation-linked bonds;</li><li>iShares iBoxx $ Investment Grade Corporate Bond (LQD) for corporate spreads;</li><li>iShares J.P. Morgan USD Emerging Markets Bond (EMB) for Emerging Markets bonds;</li><li>Invesco DB Commodity Index Tracking Fund (DBC) for commodities.</li></ul><p>Obviously, more securities reflecting more sub-asset classes (e.g. European government bonds or gold) could have been selected for a more granular analysis. But this would have over-complicated things. Also, I wanted ETFs with a long-enough track record, and many other ETFs were only launched a few years ago. In fact, by selecting these six specific assets, I have obtained a time series that goes back until 30/06/2008. The length of the time series in machine learning is crucial, because the more data we provide to the model, the more accurate it becomes (more data = more learning).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*to4S9188_ueo-PopFn6A4w.png" /><figcaption>Dataset head</figcaption></figure><p>The series ends on 29/07/2022, and this provides me with more than 3.500 daily observations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*QjwYTa2lFeUjOQCovshgfg.png" /><figcaption>Dataset stats</figcaption></figure><p>The chart below representing daily prices don’t tell much about these assets, but at least we can appreciate the behaviour in terms of volatility for each of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*kA0SDnWBeiYNgIwH84-TtA.png" /><figcaption>Daily prices time series</figcaption></figure><p>For example, we note that equities are far more volatile than TIPS or Treasuries. This is even more clear if looking at daily returns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*kHX0bNTCj5rdjs65gu5sKA.png" /><figcaption>Daily returns time series</figcaption></figure><p>We could better appreciate the behaviour of each asset in any give time by plotting cumulative returns over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*SsM3rK9dzz5XuPCR88kXdg.png" /><figcaption>Cumulative returns over time</figcaption></figure><p>Finally, it is interesting to see correlations across all assets, as it is important for investors to have a combination of assets that are uncorrelated and thus offering real diversification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*OoUE9UR1Mrkl4-u6zLHdjw.png" /><figcaption>Correlation Heatmap</figcaption></figure><p>As we could have expected, some assets have negative correlations, e.g. ACWI and PLW, given their different characteristics. Nevertheless, we should keep in the back of our minds that correlations change over time, and often they tend to become high right at the worst possible moment (e.g. during the Covid crisis).</p><p>For the backtest, I have split the dataset into a train set and a test set: the train set spans from 30/06/2008 until 30/06/2016, while the test set ranges from the 01/07/2016 until 29/07/2022. This would leave me with roughly 57% of observations in the training set and 43% in the test set. As a rule of thumb, 20 to 30% of observations should be kept for the test set, but here I preferred to keep some more for the out-of-sample test.</p><p><strong>Baseline: 60/40 portfolio</strong></p><p>The 60/40 portfolio is the classic reference point used for multi-asset investors, as it is split into two components: sixty percent of it is allocated to equities (which should provide growth), while the remaining 40% is allocated to fixed income (to shield portfolios in bear markets). I decided to use it as the baseline scenario for my analysis. Therefore, I created a portfolio made up of 60% ACWI (global equities) and 40% PLW (laddered US Treasuries). Then, I backtested it using the test set returns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*fWoL5V0gFwbJR737aOH_zA.png" /><figcaption>Backtest stats for 60/40 portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*Ix3AsNaLuIeGvI6OLXTU9Q.png" /><figcaption>Cumulative returns for the 60/40 portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*QJRKCsgfkzme_IOOVHSLGg.png" /><figcaption>Rolling Sharpe ratio and underwater plot for 60/40 portfolio</figcaption></figure><p>From the table and pictures above we can see how the 60/40 portfolio (our benchmark) performed during the test set period (01/07/2016–29/09/2022). We can see for example that the portfolio has a positive Sharpe ratio (even if the rolling six month is occasionally negative) and volatility is probably around half the one we would have obtained if allocating only to stocks. We also note that the skewness is negative (i.e., a longer or fatter tail on the left side of the distribution) and that, at a certain point in time, we would have been down by almost 20% from the peak (i.e., max drawdown). Finally, we see that on any given day 1.3% of our capital would have been at risk of loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*Wl86I4zCObAIpqXoZUCXJQ.png" /><figcaption>60/40 portfolio composition versus risk contribution</figcaption></figure><p>From the charts above, we can appreciate the risk contribution of each asset to portfolio volatility. Clearly, we see that equities represent the major source of risk to the portfolio, despite bonds weighing for 40% of it. All in all, we can claim that our baseline portfolio performs quite well during bull markets, but tends to suffer significant drawdowns during bear markets.</p><p><strong>MVO — Max Sharpe backtest results</strong></p><p>Now let’s see how the Tangency portfolio would have been performed in the same period. First, let’s plot the efficient frontier and the Tangency portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*GX1NsAog2lqsnjsldo0fRQ.png" /><figcaption>Efficient frontier with Tangency portfolio</figcaption></figure><p>I have run an optimisation using pyportfolioopt to find the Tangency portfolio weights given weights for each assets that range from 0 to 1 (i.e. no short and no leverage), and adding an L2 regularisation (<a href="https://pyportfolioopt.readthedocs.io/en/latest/MeanVariance.html#more-on-l2-regularisation">https://pyportfolioopt.readthedocs.io/en/latest/MeanVariance.html#more-on-l2-regularisation</a>) to prevent the optimisation from producing negligible weights. Worth to mention that, in order to provide the input to the optimisation (i.e. expected returns and the covariance matrix), I have used prices present only in the train set. This is to avoid any look ahead bias in the backtest. Once run, the optimisation gave the following weights for each asset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*N32uTJfZJtLI6mzj0P3_aQ.png" /><figcaption>MVO weights for Tangency portfolio</figcaption></figure><p>As we can see, the optimisation allocate more than half of the portfolio weights to equities and commodities, two asset classes that perform well during periods of economic growth, but which also have highly volatile returns. Let’s see the results of the backtest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*aPtVWGO7YnCEQyJbwYJ2CQ.png" /><figcaption>Backtest stats for MVO portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*gLGD_UpEyVcO4-13x8NwOg.png" /><figcaption>Cumulative returns for the MVO portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*6FzZTjxT8Lgf6hBGX-c0Gg.png" /><figcaption>Rolling Sharpe ratio and underwater plot for the MVO portfolio</figcaption></figure><p>In the chart above I have compared the performance of the MVO Tangency portfolio against the 60/40 portfolio. The benchmark portfolio seems to capture more upside during bull markets (e.g. after March 2020) thanks to its higher allocation to equities. Nevertheless, the MVO portfolio shows superior risk-adjusted returns, e.g. higher Sharpe and Sortino ratios. On the opposite, max drawdown and daily VaR worsened compared to the 60/40.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*VOz2rohZ2JmoBB-3888KVw.png" /><figcaption>MVO portfolio composition versus risk contribution</figcaption></figure><p>Once again, we note how stocks play a key part in risk contribution compared to other asset classes, despite weighing around half the amount in the benchmark portfolio.</p><p><strong>All Weather backtest results</strong></p><p>The weights and composition of the Bridgewater Associates’ All Weather portfolio are, of course, not public. Nevertheless, in an interview with Tony Robbins, Ray Dalio provided an approximation that even unsophisticated investors can replicate to achieve a portfolio mix similar to Bridgewater’s All Weather strategy. The composition and weighting scheme is the following:</p><ul><li>30% Equities</li><li>40% Long-Term Treasuries</li><li>15% Intermediate-Term Treasuries</li><li>5% Gold</li><li>5% Diversified Commodities</li></ul><p>Having read the above mentioned paper about the All Weather strategy, I preferred to come up with my own solution for the All Weather portfolio. In fact, following the logic highlighted in the paper, I created four different sub-portfolios, each for every quadrant of the economic environment matrix (see section “What is an All Weather portfolio?”). Each of the four sub-portfolios contains the mix of assets that would benefit from that specific economic environment. The weights have been found by applying risk parity to each sub-portfolio: in this way, I make sure that each asset within each sub-portfolios contributes in an equal manner to the overall sub-portfolio risk. Below, I report weights and risk contribution of each asset for each of the four sub-portfolios:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*AFmFyqSiL3hS1NxPoDZDcQ.png" /><figcaption>“Rising Growth” sub-portfolio weights</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*0DH2qsXiFDFDhRcKaoPFkg.png" /><figcaption>“Rising Growth” risk contribution per asset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*FCTNMCTK7aRwx7XZ8TUBuQ.png" /><figcaption>“Rising Inflation” sub-portfolio weights</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*NpnfumZSj1wQ73caHFIazA.png" /><figcaption>“Rising Inflation” risk contribution per asset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*PUfztUfM4NAmRizl2RlwJg.png" /><figcaption>“Falling Growth” sub-portfolio weights</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*BbbBdQ4tR-92rCrYS_E1-A.png" /><figcaption>“Falling Growth” risk contribution per asset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*My8bcSCR7HpV6StopcphnQ.png" /><figcaption>“Falling Inflation” sub-portfolio weights</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*DH0bcWN12ha6PYg1egKq6A.png" /><figcaption>“Falling Inflation” risk contribution per asset</figcaption></figure><p>We note that within each sub-portfolio the contribution to total risk is equal across assets, thus reaching our goal. Then, in order to find the final weights for the All Weather portfolio, I have multiplied sub-portfolios assets’ weights by 25% (remember that we assign a 25% chance to each economic environment) and add them up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*z8zRaFtW6lOcz3ejoDJKGQ.png" /><figcaption>All Weather portfolio composition</figcaption></figure><p>We immediately note that the highest allocation has been attributed to TIPS and nominal Treasuries, while stocks received slightly more than 10% of portfolio allocation. Also, EM debt received higher weight than stocks, which is interesting, considering that investors naturally tend to invest more in global stocks, and marginally to EM debt. This is even more apparent when comparing assets’ weights between the MVO and the All Weather portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*tpOGBsvaoKn8zv0eitleww.png" /><figcaption>MVO versus All Weather weights</figcaption></figure><p>We see that EMB and LQD have more or less the same weights, but the other asset classes differ substantially. Now, let’s see how the All Weather portfolio performed versus the benchmark (i.e., 60/40 portfolio).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*bdm5mE7y4jJGuJFj345vlQ.png" /><figcaption>Backtest stats for All Weather portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*Ux8S2EPedkJGJcrs9cAMyA.png" /><figcaption>Cumulative returns for the All Weather portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*RBhpz5ogTj67mDa2uVcNMg.png" /><figcaption>Rolling Sharpe ratio and underwater plot for the All Weather portfolio</figcaption></figure><p>From the table and charts reported above, we can see now some interesting outcomes from the backtest. First, we note how annual and cumulative returns resulted being lower compared to what we experienced with the benchmark and the MVO portfolios. For this reason, we also see lower metrics for risk-adjusted returns, as the numerator declined significantly. At the same time, we note a significant reduction in annual volatility, max drawdown and daily VaR compared to previous backtests. Furthermore, the beta of the All Weather is less than half that for the MVO, as returns tend to be less correlated to those of the 60/40 portfolio (0.42 versus 0.87).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ER3C6MyHltVnWQ8vPK7Jtw.png" /><figcaption>All Weather portfolio composition versus risk contribution</figcaption></figure><p>From the risk contribution analysis, we note how, this time, all assets contributed more evenly to overall risk, thus making returns more stable over time.</p><p><strong>HRP backtest results</strong></p><p>In order to create a HRP portfolio consistent for this kind of comparison, I have selected as features the correlation between the annual returns of each asset with two economic variables, that we have already encountered when talking about the All Weather portfolio: GDP growth and CPI. This makes sense, as my goal was to cluster group of assets based on the two economic features that drive the allocation in the Bridgewater Associates’ paper for the All Weather portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*b-ysYR84AzPKqJIea5VQxg.png" /><figcaption>Correlation between assets’ returns and economic variables</figcaption></figure><p>From the above correlation heatmap, we see for example that (not surprisingly) returns of equities (ACWI) are positively correlated with economic growth (gdp_world), while nominal bonds’ returns (PLW) have a negative correlation with inflation (cpi_world). This makes economic sense, as we already know that stocks benefit in a rising growth environment, while nominal bonds suffer from rising inflation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*UFghD2-uUcjYyTr8r7V9og.png" /><figcaption>Scatter plot of GDP versus CPI returns correlations across assets</figcaption></figure><p>From the scatter plot above, it’s even more clear how each asset class’ returns are related to each economic variable. This is perfectly aligned to what explained in the above mentioned paper.</p><p>From here, I started to calculate the clusters with the agglomerative clustering technique (using Euclidian distance and Ward linkage on the training data exclusively), and then I plotted the dendrogram showing all the different clusters. Worth mentioning that I have scaled the training data before using the agglomerative clustering: this is important to avoid that outliers can impact the way the algorithm learns during the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*OsHOOtGtx25BzS5m3RbU1g.png" /><figcaption>HRP dendrogram</figcaption></figure><p>We see from the dendrogram that the algorithm correctly clustered together asset classes based on their correlation with the selected features. This is even more clear when contrasting the scatter plot with the dendrogram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*1nUZ9ABX2Dah4W0fZBt_7g.png" /><figcaption>Comparing scatter plot and dendrogram</figcaption></figure><p>Once again, I have used the training set to calculate assets’ weights with the process explained in the section “What is Hierarchical Risk Parity?”, and then I have backtested the portfolio using the returns in the test set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*18kJCor-JJj1kL6bNJNGZg.png" /><figcaption>HRP portfolio composition</figcaption></figure><p>Surprisingly, the HRP approach results in allocating the most to EM debt, an asset class which, generally, has only a modest weight in traditional allocations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*nV3twY56q9RQ0Mtag06CtA.png" /><figcaption>MVO versus All Weather versus HRP weights</figcaption></figure><p>In the bar chart above, I have reported the comparison across all the different asset allocation approaches: we note that, with the exception of corporate spreads (LQD), weights differ substantially across all portfolios. Let’s now examine the performances of the HRP allocation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*yeiBHXSeOUu0RXbHdOFHDA.png" /><figcaption>Backtest stats for HRP portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*zHjkcHU9Ff8ePPstFn5HEA.png" /><figcaption>Cumulative returns for the HRP portfolio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*4CcQYmr6clppXF-pH_qQnw.png" /><figcaption>Rolling Sharpe ratio and underwater plot for the HRP portfolio</figcaption></figure><p>It seems that performances are more aligned to the All Weather portfolio rather than to the MVO. HRP managed to increase returns compared to the All Weather, but risk also increased a little bit (both max drawdown and daily VaR increased). Compared to MVO and the benchmark portfolio, HRP produced lower returns, but better risk metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*zqD3dXlsiNUTgHDvyQj3KQ.png" /><figcaption>HRP portfolio composition versus risk contribution</figcaption></figure><p>From the bar chart of risk contribution, we note that, unlike All Weather, the major sources of risk come from equities and EM bonds: this may explain why risk statistics worsened compared to the All Weather portfolio, while returns turned out to be higher.</p><p><strong>Comparing results across portfolios</strong></p><p>It’s now time to wrap up and compare the results obtained with each different allocation. The most obvious place where to start is the plot of cumulative returns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*dzAHWjizlkIlgk7OsZmfSg.png" /><figcaption>Cumulative returns comparison line chart</figcaption></figure><p>It seems that both the 60/40 and the MVO portfolios produced superior returns in the backtest period compared to the All Weather and the HRP allocations. Nevertheless, it seems that these two portfolios produce more stable returns and are offer more protection in case of external shocks (as it happened during the first months of the pandemic crisis).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*af_M8dn3UweigAa-MiVl8A.png" /><figcaption>Stats for all portfolios</figcaption></figure><p>Looking at the above table we see that all the different portfolios have pros and cons, and there is not a clear best option. In fact, the 60/40 produces the highest return/MDD ratio, while the MVO scored the highest result for the Sharpe ratio, despite having the worst max drawdown. The All Weather seems to be the least risky allocation, with a MDD of -14.74%, but provides the lowest returns. Finally, the HRP seems to be halfway, with higher returns than the All Weather and lower risk than the benchmark and the MVO. Nevertheless, returns for the HRP are lower than the benchmark and MVO portfolios, while risk metrics are higher than those of the All Weather.</p><p><strong>Conclusions</strong></p><p>We compared four different allocations and obtained quite different results for each of them. It may seem that the benchmark and the MVO portfolios should be chosen by an investor more focused on growth, while the All Weather or the HRP seem more obvious choices for a very risk averse investor. Nevertheless, we must consider that the backtest period, despite including bull and bear markets, is characterised by very low interest rates and low inflation across markets (even if this trend started to reverse since late 2021). This clearly benefits assets like stocks or nominal bonds, thus improving performances of allocations particularly tilted toward these asset classes (like the 60/40 or MVO). But, in periods of high inflation and low growth (as it happened in the 1970s), these portfolios would have suffered tremendously that economic environment. Therefore, before drawing any conclusion, it would be wiser to backtest these allocations in other economic periods too(maybe using indices rather than ETFs, as their time series may not go back in time enough). Furthermore, it would be interesting to repeat this experiment using more assets, to allow for a more granular allocation within major asset classes. Finally, we should have selected different features for the HRP model, or used another way of finding weights for the All Weather portfolio. Backtest are what they are: backtests! And we should always keep in mind that they are a representation of what would have happened, but not of what might happen in the future.</p><p>You can find the python code of this analysis here: <a href="https://github.com/babyloncapital/python_projects/blob/main/All%20Weather%20Vs%20HRP%20-%20daily.ipynb">https://github.com/babyloncapital/python_projects/blob/main/All%20Weather%20Vs%20HRP%20-%20daily.ipynb</a></p><p><em>Disclaimer: The content of this article is not an investment advice and does not constitute any offer or solicitation to offer or recommendation of any investment product. It is for research purposes only and does not take into account your individual needs, investment objectives and specific financial circumstances.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd777e89604e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparing rising and declining global powers]]></title>
            <link>https://medium.com/@lucadonghi_25036/comparing-rising-and-declining-global-powers-e4129226d783?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4129226d783</guid>
            <category><![CDATA[global-macro]]></category>
            <category><![CDATA[geopolitics]]></category>
            <category><![CDATA[macroeconomics]]></category>
            <category><![CDATA[international-relations]]></category>
            <category><![CDATA[changing-world-order]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Sat, 26 Mar 2022 16:20:28 GMT</pubDate>
            <atom:updated>2022-03-26T16:20:28.955Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oMnGEVC3Q5PzAmht7OjjuQ.jpeg" /><figcaption>Source: unsplash.com — Christine Roy</figcaption></figure><p>After reading the last book by Ray Dalio “<em>Principles for Dealing with the Changing World Order</em>” (which I warmly recommend to all macroeconomics and geopolitcs enthusiasts), I was curious to put into practice the lessons learned from it. So, with the help of Python and DBnomics (<a href="https://db.nomics.world/">https://db.nomics.world/</a>), I compared the G20+ 4 (I added Spain, Switzerland, Singapore and Netherlands because of their historical and current importance) countries in relation to various dimensions of power. These are both economic (e.g. GDP ) and non-economic (e.g. military strength). Since data are taken from well trusted sources (like the IMF, World Bank, etc…) they can be considered reliable, but (unfortunately) not always consistent across time or countries. The main goal of this analysis is to highlight which countries are rising as dominant powers and which ones are waning.</p><p>A note of caution: this is a much more simplified work compared to the complex models deployed by Bridgewater Associates (the investment firm of Ray Dalio): in fact, they probably use millions of different time series for each dimension analysed in order to rank countries, while I have selected no more than two for each one. This is because I just wanted to obtain a very high-level perspective, therefore I simply selected indicators that could act as proxies for each aspect taken into consideration. If you want to dig deeper into these topics, I suggest you to visit Ray Dalio’s website <a href="https://economicprinciples.org/">https://economicprinciples.org/</a> where you can find many useful videos and research documents for free (thanks Ray!!).</p><p>So, let’s move on with the “agenda”.</p><p><strong>Contents</strong></p><ol><li>The dimensions of the “Big Cycles”</li><li>The eight key measures of power</li><li>Additional measures of power</li><li>Rising and declining powers: United States vs China</li><li>Key takeaways</li></ol><p><strong><em>Legend of abbreviations</em></strong></p><p>‘ARG’ → Argentina<br>‘AUS’ → Australia<br>‘BRA’ → Brazil<br>‘CAN’ → Canada<br>‘CHN’ → China<br>‘FRA’ → France <br>‘DEU’ → Germany<br>‘IND’ → India<br>‘IDN’ → Indonesia<br>‘ITA’ → Italy<br>‘JPN’ → Japan<br>‘KOR’ → South Korea<br>‘MEX’ → Mexico<br>‘NLD’ → Netherlands<br>‘RUS’ → Russian Federation<br>‘SAU’ → Saudi Arabia<br>‘SGP’ → Singapore<br>‘ZAF’ → South Africa<br>‘ESP’ → Spain<br>‘CHE’ → Switzerland<br>‘TUR’ → Turkey<br>‘GBR’ → United Kingdom<br>‘USA’ → United States</p><p><strong>The dimensions of the “Big Cycles”</strong></p><p>In his book, Ray Dalio explains that there are some power dimensions capable to indicate on which point along the so-called “Big Cycle” a country find itself. Among these there are a country’s expected growth, debt burden, internal and external order. So, let’s see how the G20+ countries relate to these dimensions.</p><p>In order to analyse the expected growth I have taken the forecasted growth rates from the IMF WEO (World Economic Outlook) and then I re-based them, so to obtain the cumulative growth over the next five years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*v3hB5GU575IdNTch8qpahw.png" /><figcaption>Source: IMF</figcaption></figure><p>From the chart above we can see that China, India and Indonesia are the countries expected to grow the most in the coming five years (according to the IMF). But since China is the second country by GDP size, its growth rate is very impressive (especially if compared with USA). Typically, emerging countries like Brazil, Mexico and China (just to mention a few) have a higher growth rate than more developed nations, because their economies are smaller and tend to grow faster than bigger more developed ones. We have to keep this in mind when making comparisons among countries having different economic sizes. Definitely, emerging markets represent an interesting investment opportunity in the long-term, but they are also highly volatile. Furthermore, we have to consider that the statistics from the IMF have been released before the start of the conflict between Russia and Ukraine: therefore, we may expect lower growth rates when these same forecasts will be revised in the coming months.</p><p>The next dimension to look at is the debt burden, since countries with a higher debt level are (generally) in a worse financial position: in fact, they need to service this debt (i.e. paying interests on it and principal as it comes due) and this may slow down their growth. Typically, countries borrow to finance their growth (investing in productive functions like infrastructures, research, education, etc…), and if the return on such investments (ROI) is higher than the nominal interest rate paid, borrowing is fine. But, when productivity falls and the ROI turns smaller than the interest rate, debt acts as a drag on the country’s growth and ability to re-pay it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*xjtUG_278_A66BzDnfKbqQ.png" /><figcaption>Source: IMF</figcaption></figure><p>There are no precise rules to gauge the impact of debt on a country’s growth, but (generally) when it becomes greater than 100% of its GDP, then we should pay closer attention. Countries like Japan, USA and Italy have all passed this threshold, but unlike the first two, Italy doesn’t have the possibility to “monetise” its debt (i.e. financing it with more money printing by the central bank, because the Euro is not a currency that Italy directly controls, but it’s controlled by the European Central Bank), so it’s at greater risk.</p><p>Another interesting indicator to assess is the net international investment position (NIIP), which, according to the definition given by Investopedia, “<em>[…] measures the gap between a nation’s stock of foreign assets and a foreigner’s stock of that nation’s assets. Essentially, it can be viewed as a nation’s balance sheet with the rest of the world at a specific point in time</em>”. In general, a positive value is viewed favourably, but a negative one may simply indicate that a country is benefitting from external financial flows (like Foreign Direct Investments, or FDIs) that support its growth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*5Ht6lqRJkzTeTpARR5VtCw.png" /><figcaption>Source: OECD</figcaption></figure><p>The United States have a deep negative NIIP, while China’s one is positive. Countries that are “net savers” (i.e. having a current account surplus) tend to have lots of investments abroad (e.g. Germany, Japan and China). What’s important to look at when analysing a country’s NIIP is its composition: in fact, the NIIP is composed by different items like FDIs, the portfolio (i.e. equities and bonds), loans and reserves. Countries with a negative NIIP tend to be more at risk if the portfolio component has the lion’s share, because it’s easier for foreign investors to take away their capitals from the country (while FDI and loans are more long-term in nature and less liquid). This is especially important to consider when talking about emerging markets: in fact, foreign investors rush to the exit during market turmoils or geopolitical tension periods. Here I haven’t reported a detailed breakdown of each country’s NIIP, but these data are available at DBnomics (if the reader wants to further deepen this topic).</p><p>Next, let’s look at the ability of central banks to sustain their economies with monetary policy. Specifically, we compare the current policy rates with inflation levels in each country (or area, since European countries share the central bank). In fact, when inflation is under control, the central bank can afford to keep monetary policy accommodative, but if inflation expectations surge, then a central bank may find itself “behind the curve” (i.e. its policy is in late) and is forced to raise interest rates at a faster pace. This may result in a too much aggressive tightening, which may eventually trigger an economic recession.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*ovhSGz4eU82TxwlbqpPGQg.png" /><figcaption>Source: IMF</figcaption></figure><p>Currently, the central banks that have less ability in stimulating the economies are the ones where the inflation rate is way higher than policy rates: this is especially true for most developed countries, like USA, Europe and UK. Turkey and Argentina seem to be especially vulnerable given the already high level of domestic inflation. China, on the other side, seems to have still some margin to ease its monetary policy in case of need. Please, note that the above data do not represent the very last observations for all countries: in fact, at the time of the writing of this article, USA, UK and Russia have already increased their policy rates. The first two countries hiked by a quarter of percentage point (USA set it at 0.5, while UK is at 0.75%), while Russian central bank was forced to bring its rate at 20% from around 10%, following the invasion of Ukraine (in order to tame domestic inflation and to defend the ruble which collapsed after the start of the war).</p><p>Another aspect analysed by the author which is important for societies to thrive is the presence and magnitude of wealth, opportunity and value gaps. It’s not easy to identify variables that can correctly reflect such broad themes. Therefore, I simply took the inequality in income and the inequality in education indices by the United Nations Development Programme as proxies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*Z3fJmgR86BaevmdN0JpP8Q.png" /><figcaption>Source: UNDP</figcaption></figure><p>As one may expect, the greatest inequalities are registered in emerging countries, like Brazil and South Africa. But in the United States (probably the most advanced country in the world) inequalities are at the same level of other developing nations, which may be one of the causes for discontent within US borders. We do not have data for Saudi Arabia (as I anticipated, not all time series selected have data for all countries or years), but we might expect it to be in line with other emerging countries. On the other side, I was quite surprised to see nations like India and Indonesia reporting a score that is better than other more developed countries like Italy or Singapore.</p><p>The education inequality index is approximated only by inequality in years of schooling of the adult population drawn from nationally representative household surveys. For some countries this inequality is computed from the education attainment tables of the UNESCO Institute for statistics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*2-sW5z-uqrx6gNHZ0mDkOQ.png" /><figcaption>Source: UNDP</figcaption></figure><p>From the chart we note that emerging countries tend to have a high level of education inequality, since poverty levels are typically higher, and young people tend to abandon school earlier to sustain themselves and their families. With regard to developed countries, Spain probably raises a red flag, with a score that is more comparable to those of poorer countries.</p><p>For the analysis of the internal order, I used the “Political stability and absence of violence/terrorism index” developed by the World Bank. Once again, this may result in a too much simplistic analysis, but I hope it could give us at least a general idea of the situation among countries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*69Pkxevgy64__t1VFfYV4w.png" /><figcaption>Source: World Bank</figcaption></figure><p>The higher the index, the higher the political stability. As we may notice, developed countries tend to report a higher score, while countries subject to autocracies (e.g. Turkey and Russia) lie in the lowest ranks. Interestingly, United States have the lowest index among developed nations. This may reflect the fact that, despite being the most powerful democracy in the world, the US are currently facing internal conflicts that need to be managed before getting worse.</p><p>Before moving to the next section of our analysis, I need to clarify that another aspect that the author takes into consideration in his book is the so-called “external order”, which extends from trade wars to military ones. I haven’t found relevant statistics on DBnomics (there are many interesting data sets with regard to tariffs, but no reliable indicators reflecting geopolitical tensions). Therefore, I decided to report below the BlackRock Geopolitical Risk Indicator (visit <a href="https://www.blackrock.com/corporate/insights/blackrock-investment-institute/interactive-charts/geopolitical-risk-dashboard#risk-summary">https://www.blackrock.com/corporate/insights/blackrock-investment-institute/interactive-charts/geopolitical-risk-dashboard#risk-summary</a> for more information on the methodology used by BlackRock Investment Institute), which provides us with a good high-level picture of the current and past geopolitical risks at a global level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*cpmsG7yawTWCXbL4TjvQ3A.png" /><figcaption>Source: BlackRock Investment Institute</figcaption></figure><p>We can note that it recently spiked, obviously as a consequence of the Ukraine-Russia conflict. Military conflicts are often (and sadly) historical moments in which the defeated powers start their inevitable decline, while winning ones set the rules for the new global order. This happened last time after World War II, when the United States rose as the dominant super-power, and the US dollar became the new world reserve currency.</p><p>Now, let’s have a closer look at the key measures of power and try to determine which countries are rising and which are not.</p><p><strong>The eight key measures of power</strong></p><p>The first key measure of power we look at is the level of development and accessibility of markets and financial centres within a country. Financial centres are important for a country because they allow it to raise the capitals needed to promote growth. For this measure I selected the “Financial Development Index” by the IMF, which takes into account several metrics of financial institutions and financial markets development, as you can see in the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrrLR5HhJ8ZeLVx3sMlhbw.png" /><figcaption>Source: IMF</figcaption></figure><p>As reported on IMF’s website, “[…] <em>the index summarises how developed financial institutions and financial markets are in terms of their depth (size and liquidity), access (ability of individuals and companies to access financial services) and efficiency (ability of institutions to provide financial services at low cost and with sustainable revenues and the level of activity of capital markets”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*xI9bXTvJ_Bu8KhHNkEd-7w.png" /><figcaption>Source: IMF</figcaption></figure><p>From the chart above we note that the United States (not surprisingly) report the highest score, followed by Great Britain, Switzerland and Japan. Logically, these are all home to the most important stock exchanges and financial centres in the world, giving these countries an important edge in terms of financial resources attraction.</p><p>Innovation and technology is another strategic area when looking at a country’s power: in fact, technology has always played a decisive role in countries’ ability to dominate economically and militarily (think about the steam engine or nuclear weapons for example). A good proxy for this dimension can be represented by the number of patent applications submitted in a country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*-BFirrRpGGFiQ7JjjUUV_w.png" /><figcaption>Source: World Bank</figcaption></figure><p>We clearly see that China retains the lion’s share, followed by the US, Japan and South Korea. Before jumping to “easy” conclusions, we must also consider the quality of these patens. In fact, it’s a well known fact that (at least until now) the quality of Western technologies are far better than those developed in non-Western nations: this is why China keeps importing lots of technological applications and systems from the US. Nevertheless, it’s undeniable that China is quickly rising as a tech hub, while trying to rely less and less on the West’s technology.</p><p>In order to assess our next variable, i.e. military strength, I selected a very simple (but highly representative) indicator: the military expenditure in percentage of a country’s GDP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*P0aiJ8EJxierqpCdBe-ZxQ.png" /><figcaption>Source: World Bank</figcaption></figure><p>It quickly jumps at us that Saudi Arabia invests a lot compared to other G20+ countries in the defence sector (more than 7% of its output). The next in line are (unsurprisingly) the United States and Russia, which have respectively the first and second military apparatus on the planet. Typically, countries that devote much of their budget to defence tend to invest less in other more productive sectors like education, infrastructures and healthcare. In my humble opinion, they do it for three reasons: 1) cultural heritage; 2) geopolitical tensions close to their borders; 3) to defend their status as super-powers. In any case, the fact that the second world power (i.e. China) devote around half the budget (in percent of its GDP) of the United States can be seen as a signal that Beijing prefer to focus its investments on more productive uses to increase its influence worldwide (just think about the Belt and Road Initiative).</p><p>Talking about productive investments, let’s have a look at expenditure on education, which I am convinced represent a strategic lever for increasing a country’s competitive advantage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*IjLMxYhIB3iRYpkJjjJSoA.png" /><figcaption>Source: IMF</figcaption></figure><p>Unfortunately, we do not have data for some countries (i.e. Mexico, South Korea and Saudi Arabia), while for some others (specifically USA and India) the last observation dates back to 2018. Nevertheless, I find such statistics interesting and useful to have a high-level picture. For example, Australia is the country investing the most (in proportion to its GDP) in education, followed by the USA, while (surprisingly) Japan invests less than Indonesia (a less developed nation). China lies midway, investing 40% less than other developed economies.</p><p>The possibility for a country to rule the global financial system thanks to its own currency represents one of the most important advantages, because international trades are settled in that specific currency (on which the country retains direct control). Furthermore, it allows the nations controlling world reserve currencies to threaten other countries in case of conflicts (as we are currently observing with Western sanctions on Russia following the Ukraine invasion). As reported on Investopedia’s website, “<em>Holding a reserve currency minimises exchange rate risk, as the purchasing nation will not have to exchange its currency for the current reserve currency to make the purchase. Since 1944, the U.S. dollar has been the primary reserve currency used by other countries. As a result, foreign nations closely monitor the monetary policy of the United States to ensure that the value of their reserves is not adversely affected by inflation or rising prices”</em>. To evaluate a country’s reserve currency status, I selected the Currency Composition of Official Foreign Exchange Reserves (COFER) from the IMF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*t_Y2WL4JqyqfJpn10C_F7g.png" /><figcaption>Source: IMF</figcaption></figure><p>From the pie chart we see that the US Dollar still retains the role of reserve currency of the world (that won following the end of World War II), followed by the EUR. The CNY (the currency of the second world power) accounts for only 2.29%, a negligible weight compared to the USD or the EUR. Nevertheless, China is increasing its efforts to make the yuan a more accepted currency in international trade: this would definitely rise Chinese influence worldwide.</p><p>A topic closely related to the reserve currency status is the power a country retains in international trade, which can be measured by the share of total world exports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*MwqbmkjPpSXKqH0ZfBi9kg.png" /><figcaption>Source: UNCTAD</figcaption></figure><p>From the graph we see that China retains the lion’s share of worldwide exports: in fact, China is appealed as the “factory of the world”. For more than 20 years, China has rapidly increased its influence as a major exporter of goods produced at cheap cost. Then, the Trump’s Administration began a trade war in 2018 with the scope of taming the Chinese flood of goods in the US market. In fact, the US trade balance against China worsened considerably in the past decade, and the Trump’s Administration used to refer to Chinese trading practices as unfair. Nevertheless, the pandemic gave a boost to Chinese exports: in fact, Western countries (subject to strict lockdowns) helped Chinese exports thanks to consumers shifting demand from services to goods (obviously manufactured in China). Exports are one of the major drivers of Chinese GDP, but Beijing is increasing its effort to increase domestic consumption, in order to rely less on the West. Personally, I am convinced that China, with a domestic market of around 1.4 billion people, will successfully reach this goal soon. On one side, labor cost is increasing in China, as middle class becomes richer (thus making outsourcing to China less advantageous for Western countries); on the other, the increasing polarisation between West and East, as well as the threats to Chinese growth posed by Western tariffs, are pushing Beijing to insulate itself more and more. Behind China, we see two other major players: the United States and Germany. But, whilst China and Germany run a positive current account, the US imports more than what it exports, as we can see from the below chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*QLQIV4rPLAZxgEJDcUREXQ.png" /><figcaption>Source: IMF</figcaption></figure><p>This is not necessarily a problem: many countries, especially low-income ones, run a current account deficit in order to finance their growth, importing foreign goods and attracting external capitals that can be invested productively. But for Washington, reducing the trading gap with Beijing is also a geopolitical matter and a way to tame Chinese global influence.</p><p>Another aspect considered by the author is cost competitiveness. As said, in many emerging markets (especially China) the labor cost that once was extremely cheap, is becoming dearer and dearer, thus reducing their competitive advantage. Here, I propose to look at two indicators: the first one is the indicator of competitiveness based on relative unit labor costs in total economy by the OECD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*Z2Wd5c03cKZPfNytmteluw.png" /><figcaption>Source: OECD</figcaption></figure><p>Unfortunately, some countries are missing (i.e. India, Saudi Arabia and Singapore), but we clearly see that among developing nations the indicator is generally lower, reflecting less attractive wages. Nevertheless, China’s indicator seems to be more aligned to Western developed countries than its peer countries, like Indonesia or Brazil. A sign perhaps, that things are changing in the Chinese labor markets, with workers demanding higher wages as the middle class expands. To double-check, let’s have a look at statutory minimum wages too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*PHfnlc8RnxT-AYAfHRY-UA.png" /><figcaption>Source: ILO</figcaption></figure><p>Well, from the chart above it seems that China still maintains its competitive advantage in terms of cheap labor cost, but we can simply interpret this indicator as lower living standards in EM compared to the West. In any case, the minimum salary gap between the first and second world powers is undeniably huge. Interestingly, South Korea’s minimum wage is higher than that of a very advanced country like Japan, signalling that the country can be considered as a full-fledged developed nation.</p><p>The last measure of power we look at is a very intuitive one: the economic output. More specifically, I selected the GDP based on PPP share of world total. Technically, PPP GDP is gross domestic product converted to international dollars using purchasing power parity rates. An international dollar has the same purchasing power over GDP as the U.S. dollar has in the United States. GDP at purchaser’s prices is the sum of gross value added by all resident producers in the economy plus any product taxes and minus any subsidies not included in the value of the products. It is calculated without making deductions for depreciation of fabricated assets or for depletion and degradation of natural resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*G1-EeExpKVrpS6u5EWwgTw.png" /><figcaption>Source: IMF</figcaption></figure><p>I think that this chart accurately reflects the current and perspective status of rising and declining global powers, with China slowly eroding the American supremacy. India is definitely another rising power on the scene, with a population of 1.3 billions, but at the moment it cannot be considered as advanced as China. In fact, we have seen that India suffers from many internal inequalities, especially on education, besides having low political stability and a financial centre that cannot be considered much developed.</p><p><strong>Additional measures of power</strong></p><p>Now let’s have a look at some other interesting measure of power like resources, infrastructure investments and rule of law. These indicators can be considered as a corollary to the previous ones, even though are critical in determining a country’s power.</p><p>The first measure we will discuss is the resource-allocation efficiency: for this purpose I have taken the total natural resources rents (%GDP). Total natural resources rents are the sum of oil rents, natural gas rents, coal rents (hard and soft), mineral rents, and forest rents. The estimates of natural resources rents are calculated as the difference between the price of a commodity and the average cost of producing it. This is done by estimating the price of units of specific commodities and subtracting estimates of average unit costs of extraction or harvesting costs. These unit rents are then multiplied by the physical quantities countries extract or harvest to determine the rents for each commodity as a share of gross domestic product (GDP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*CSvJYWZO7omhvx0xo4YEvg.png" /><figcaption>Source: World Bank</figcaption></figure><p>We immediately notice how countries rich in natural resources (like Russia, Saudi Arabia and Australia) report big scores. On one side, this means that these countries can benefit from their abundance of natural resources (especially oil), influencing other powers that depend from them to obtain the resources they don’t have on their soil; but on the opposite, these same nations risk having revenues not properly diversified and can suffer from sanctions or embargoes (just think about oil from Russia, Iran or Venezuela). Oil is a strategic natural resource for every country, and when its price rises dramatically, this can act as a tax on an importer’s growth. The US is a particular case because it turned from being the biggest oil importer to one of the major oil producers thanks to the introduction of the fracking technique, which allows the United States to obtain shale oil. Today, China is the biggest oil importer, and it is critical for this country to ensure regular supplies at the lowest possible cost from oil-producing countries. For this reason, it is trying to buy oil from some of these countries using its own currency (the yuan) instead of the US dollar. This would definitely help China to increase its influence, as the yuan becomes more and more accepted in international trade.</p><p>Assessing the governance quality of a country is very important, because it offers a glance on the level of democracy reached. Furthermore, I consider it a key gauge of the living standards, freedom level enjoyed, as well as how well bureaucratic mechanisms work in a society. Sometimes, this aspect may be overlooked, but history teaches us an important lesson in this regard: in fact, the most important inventions and innovations in humankind took place in those liberal and democratic countries where freedom of thought was more guaranteed and corruption levels were law, thus favouring a better allocation of resources. This was the case for Northern-European protestant countries in the XVIII and XIX centuries: just think about how many technological revolutions and scientific discoveries took place in such places (e.g. telegraph, vaccines, etc…). When steam engine spread in England, the Industrial Revolution began, making it the world dominant power. To reflect this aspect, I selected the Rule of Law indicator by the World Bank. According to it, <em>Rule of Law captures perceptions of the extent to which agents have confidence in and abide by the rules of society, and in particular the quality of contract enforcement, property rights, the police, and the courts, as well as the likelihood of crime and violence. Percentile rank indicates the country’s rank among all countries covered by the aggregate indicator, with 0 corresponding to lowest rank, and 100 to highest rank</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*tNKRQ3rkGD16DNcq0DjdEw.png" /><figcaption>Source: World Bank</figcaption></figure><p>As we can see, in most emerging countries this indicator is well below the level in more advanced countries. Interestingly (and sadly for Italians like me), this indicator for Italy, a developed country, is at the same level of many other developing nations. Perhaps, a sign that the internal order in this nation has to be re-assessed by the political establishment. With regard to the US and China, the former lies in the upper range, while the latter is way below. Thus, this is to be considered in favour of the US.</p><p>Now let’s move on to assess investments and infrastructures. More specifically, we will look at two indicators: how much the country spend on gross fixed capital formation (defined as the acquisition of produced assets, including the production of such assets by producers for their own use, minus disposals) and the vulnerability of its infrastructures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*aP7ES55ljtIIX9eLivpiow.png" /><figcaption>Source: World Bank</figcaption></figure><p>From the chart above, we can clearly note how much China is investing in produced assets compared to peer countries (exactly double the amount of the US ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*JakMH0g82Tw0uLMFwoVSLA.png" /><figcaption>Source: Notre Dame University</figcaption></figure><p>Above we can see the vulnerability at the infrastructure level according to the Notre Dame University based on its ND-GAIN Index: the infrastructure score captures the vulnerability of coastal and energy infrastructure to climate change, primarily general preparedness to climate-related natural disasters, coastal hazards, and energy supply challenges. Indicators include projected change of hydropower generation capacity, projected change of sea level rise impacts, dependency on imported energy, population living under 5m above sea level, electricity access, and disaster preparedness. It would also have been interesting to assess the vulnerability in terms of cyber attacks, but I couldn’t find such statistics on DBnomics. Therefore, I just report below data taken from the National Cyber Security Index (NCSI) ranking by country for the “Protection of e essential services”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*3rhJaoUdjuJ-3NLZV-5CNw.png" /><figcaption>Source: NCSI</figcaption></figure><p>We notice that countries scoring poorly in the previous metric (like Japan, Netherlands and Singapore) should also improve their ability to protect essential services from cyber attacks. On the contrary, the two current super-powers, US and China, reported very high scores, showing their preparedness against such threats.</p><p>For our next measure, acts of nature, I once again decided to rely on data from the Notre Dame University. But this time, taking the most comprehensive ND-GAIN Country Index. The ND-GAIN Country Index summarises a country’s vulnerability to climate change and other global challenges in combination with its readiness to improve resilience. It aims to help governments, businesses and communities better prioritise investments for a more efficient response to the immediate global challenges ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*Q5M21rGnFUiNGjNLKDQFJA.png" /><figcaption>Source: Notre Dame University</figcaption></figure><p>This time we see that it’s the less developed nations being more at risk with regard to climate change challenges. Not surprisingly these are also those countries demanding a greater investment effort from Western nations in order to reduce the negative impacts coming from climate change.</p><p>Finally, to better contextualise the metrics seen so far, I would like to pose the attention of the reader on a specific variable: total population. In fact, it’s true that throughout history nations and kingdoms with a population of a few million people managed to rule the world (the Dutch empire counted no more than 2 million people during its peak), but, in my opinion, having a potential domestic market of hundreds of millions (if not billions!) represents a clear advantage (especially in developing countries once the middle class expands itself). Furthermore, nations with a huge population are a strategic target for multinational corporations which, in exchange for selling their products/services in those countries, bring important FDIs (welcomed by rulers of such countries, of course).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*RtmTLvIAIs_0O2BPq_xCPg.png" /><figcaption>Source: World Bank</figcaption></figure><p>Clearly, China and India have the ability to shift the “world epicentre” closer to south-east Asia in the coming decades (with almost 3 billion people within two countries). And we shall not forget about Indonesia, another very populous nation (273 millions). United States has the advantage to possess a great domestic market, with private consumption representing around 70% of its GDP. European countries together count 478 million people, definitely a respectable figure.</p><p><strong>Rising and declining powers: United States vs China</strong></p><p>Now that we have gone through the main indicators reflecting the measures of power, I would like to dig deeper in the trend of these same metrics with regard to the two current world super-powers: the United States and China. The former is sometimes considered a declining empire (with lots of internal divisions and many value/wealth gaps), while the latter is seen as the rising star among world powers. So, let’s see how the metrics we have examined so far (from a static perspective) have evolved through time. Please, note that, despite it would have been interesting to analyse all other nations as well, it would also have been too much difficult to represent more than 20 countries on line charts. Therefore, I preferred to analysed just the first two global super-powers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*m7xz1Df6GTR9P_k1RrQmcg.png" /><figcaption>The Big Cycles</figcaption></figure><p>From top to bottom, we see that China (the green line) is growing faster and it is also expected to keep growing at a faster pace than the United States (the blue line). We also note that government debt is much higher in the US than China, and American NIIP is also quickly deteriorating (meaning that foreign liabilities are greater than foreign assets). From a monetary policy standpoint, the US has less room than China to stimulate the economy, since rates are already near zero (we previously saw that inflation is skyrocketing in the US compared to China, thus limiting the FED ability to keep a dovish stance). While income inequality is more or less the same for both countries, the political stability index shows a deterioration for the US while an improvement for China.</p><p>Since we have already analysed the eight key measures of power (as well as the additional measures of power) in great detail previously, I will just report below the line charts of these indicators for the US and China without commenting them (please, note that some series do not extend for the same time span, since not all observations are available).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*OB9V2PYYrsUoS1pTM4wlBQ.png" /><figcaption>Source: IMF</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*E5n8FBSB6m6L1fdeJZppHw.png" /><figcaption>Source: World Bank</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*-C1hGncbzqaBzwtH72wlAg.png" /><figcaption>Source: World Bank</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*tTwbeep1vxZmZwRrk2XOmg.png" /><figcaption>Source: UNDP</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*6uCzAIrqEl8U_bVGLWtWhQ.png" /><figcaption>Source: IMF</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*riQYqXq-F-gdH9eavcYFYA.png" /><figcaption>Source: IMF</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*Dpfn_bKJ_x6aLDWoEf2Leg.png" /><figcaption>Source: UNCTAD &amp; IMF</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*9cTYvLNVmkTBJMa3ggJaGw.png" /><figcaption>Source: OECD &amp; ILO</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*OpUIgG8qClUM3LCe8ERtPg.png" /><figcaption>Source: IMF</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*D8LYSDufQpSgHP9czqlSGA.png" /><figcaption>Source: World Bank</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ryn1jjWRivfgTSfwYm9wHg.png" /><figcaption>Source: World Bank</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*n4LcLQSZg3xWdXdJOUGtOg.png" /><figcaption>Source: Notre Dame University &amp; World Bank</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*xOPme3nvBObdDsvvzTCN1g.png" /><figcaption>Source: Notre Dame University</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*wGHjqmVQnQQQ2Ss1tKd71w.png" /><figcaption>Source: World Bank</figcaption></figure><p><strong>Key takeaways</strong></p><p>We have gone through a lot of economic and non-economic indicators with the goal of assessing the “power level” of the world major countries. For this analysis I adopted the framework suggested by Ray Dalio in his latest book “<em>Principles for Dealing with the Changing World Order</em>”, with the due premise that mine is a much simplified experiment. We have highlighted strengths and weaknesses of major world powers. We have also dig deeper into the evolution of these variables through time with regard to the first two current super-powers: US and China.</p><p>I guess that, eventually, each of us will interpret such data differently, and can draw his/her own conclusions. So, I will let the reader to determine on his/her own which countries are rising as global powers and which ones are slowly declining in geopolitical, economic, financial and military terms.</p><p>Future works may investigate deeper the existence of patterns and relations within these data, or perhaps can attempt to cluster nations within sub-groups using specific machine learning algorithms.</p><p><em>Disclaimer: this article does not represent in any way investment recommendations. It represents the personal views of the author and does not necessarily reflect those of Ray Dalio nor Bridgewater Associates. The author of this article is not affiliated with Mr. Dalio or his firm.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4129226d783" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Market Watch — Episode I: a commentary on macroeconomic trends and assets performances]]></title>
            <link>https://medium.com/@lucadonghi_25036/market-watch-episode-i-a-commentary-on-macroeconomic-trends-and-assets-performances-2d17239c5bf6?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d17239c5bf6</guid>
            <category><![CDATA[technical-analysis]]></category>
            <category><![CDATA[financial-markets]]></category>
            <category><![CDATA[sector-analysis]]></category>
            <category><![CDATA[macroeconomics]]></category>
            <category><![CDATA[business-cycle]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Sat, 05 Feb 2022 19:47:11 GMT</pubDate>
            <atom:updated>2023-01-14T22:06:22.335Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to build a Market Watch to assess macroeconomic trends and market’s performances</h3><p>In this article I am going to analyse and compare different economic indicators of some major Economies (both Developed and Emerging). Then we’ll see the evolution of the US business cycle and conduct a sector relative strength analysis. Finally, I am going to highlight performances across asset classes (in USD for easy comparison) and show some interesting technical charts. Economic and market data have been re-elaborated using Python. So, let’s start!</p><h3>Contents:</h3><ol><li>Macro heat-maps</li><li>Business cycle analysis</li><li>Sectors relative strength</li><li>Asset classes performances</li><li>Technical charts</li></ol><h3>Macro heat-maps</h3><p>For this analysis, I selected eight major countries. These are: US, EU (this is actually a region), UK, Japan, Australia, China, Russia and Brazil. Many others could have been added, like India, Canada and Mexico, which I may consider to add in future articles. Let’s start then with our first heat-map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R190Kn1yOFVrz7fFAlntfg.png" /><figcaption>Source: IHS Markit</figcaption></figure><p>The Manufacturing Purchasing Managers’ Index (PMI) is a diffusion index incorporating survey results provided by manufacturing firms throughout the country. A reading above 50 suggests the manufacturing sector is expanding, while a reading below 50 suggests the manufacturing sector is in contraction. This is classified among leading indicators, i.e. it anticipates trends in the real economy: therefore, it is a closely watched indicator by traders and policy makers. Data for the PMI are reported twice a month: a preliminary released is generally published toward the 20th of the month, and then the actual release is made available to the public on the first day of the month. In this case, we note that, with the except of China and Brazil, all other countries are expecting an expansion on the manufacturing sector. Probably, the reading below 50 for China is due to the impact of the Omicron variant that pushed the central government to shut down factories, as China pursues a zero-covid strategy. The same goes for Brazil, which is struggling due to the new virus strain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xlzjuLNggSxX9RGTgx12JA.png" /><figcaption>Source: IHS Markit</figcaption></figure><p>The Services Purchasing Managers’ Index (PMI) is a diffusion index incorporating survey results provided by firms in the services sector throughout the country. A reading above 50 suggests the service sector is expanding, while a reading below 50 suggests the service sector is in contraction. As for the manufacturing PMI, the services PMI is a leading indicator, and is reported twice a month as well. In this case, we note a reading smaller than the manufacturing PMI, with Japan, Australia and Russia exhibiting a contraction expectation in the service sector. Of course, we may easily understand why: Covid-19 impacted more severely services than manufacturers, since in-person activities tend to fell in winter times when coronavirus cases surge. Please, note that for China I have taken data from the China Federation of Logistics &amp; Purchasing (CFLP) and China Logistics Information Centre (CLIC), collected by the National Bureau of Statistics (NBS). These statistics tend to show better figures: in fact, NBS include more companies, many of which are state-owned enterprises. However, we see that the trend is improving in those areas, like US and UK, where Covid restrictions are easing or less stringent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arWxBk8CFnPbYfn2fMLJzg.png" /><figcaption>Source: OECD</figcaption></figure><p>Our next leading indicator is the OECD LI, designed to provide early signals of turning points in business cycles showing fluctuation of the economic activity around its long term potential level. Data is reported up until December and we note a common pattern among countries: a declining trend started in November as a consequence of the Omicron variant. Nevertheless, for the moment it seems that outlook remains optimistic, at least in the short-term.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pOuolXccylzzMJDypeffyA.png" /><figcaption>Source: Central Banks</figcaption></figure><p>And here we come to a very interesting part of our analysis: monetary policy. In fact, we know that, at least among developed nations, monetary conditions are extremely loose. Nevertheless, a spiralling inflation resulting from pent-up demand and supply-chain snarls, is bringing up costs for consumers and businesses. As a result, some Central Banks like the FED and the BoE are already tilting their monetary policy toward a more hawkish tune. We do see that in the UK rates passed from almost 0 to 0.5% from December, while the FED announce in its January meeting that multiple rate hikes are expected for 2022. On the other side, the ECB is trying to resist to change its course of action, but Ms Lagarde claimed that a rate hike in 2022 cannot be ruled out, should inflation pressures persist. For Japan, Australia and China the situation is quite difference, since these countries have more room for accommodative policies. Finally, Russia and Brazil have been forced to increase rates faster to tame inflationary pressures that are typically higher in Emerging Countries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2K-dv8cx7nVhF7C9Hlwhrg.png" /><figcaption>Source: OECD</figcaption></figure><p>With regard to growth, we first need to note that we only have figures available for the US, EU and China. Furthermore, it’s not easy to compare these growth rates trends for 2020 and 2021, since the pandemic made these readings extreme. Nevertheless, we can highlight that, after the plunge in 2020, the recovery has been fast and consistent among countries. Interestingly, China already reported strong positive quarterly y-o-y growth in the first quarter of 2021 (+18.3%), as it managed to exit the first phase of the pandemic quicker than other economies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xk4XIalLCCZMjxQsT4weZQ.png" /><figcaption>Source: OECD</figcaption></figure><p>This is probably the “hottest” topic, and not only for the darkening red colour of the table. In fact, price levels have become the top concern for policy makers, especially among Western countries where consumers were used to low level of inflation since the 90s. Here, I reported only data until December ’21, but data for the month of January have already been released. For example, the EU reported a reading of 5.1%. The takeaway here is that inflation is becoming entrenched, despite central bankers initially claiming it was a temporary effect due to bottlenecks in the global supply chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JksP9s47QMqdwj_w7Srw7g.png" /><figcaption>Source: ILO</figcaption></figure><p>The unemployment level is trending down, with the only exception of China (where it moderately increased lately). It would have been nice to compare current levels with pre-pandemic and 2020 levels, in order to show the fast changes happed in the labor market in the last three years. Nevertheless, we can notice that labor market is quite tight in the US, and this another major cause of inflation. In fact, as the labor market becomes tighter and tighter, workers tend to demand higher wages, which translate into higher costs for businesses, which in turn are forced to increase their prices. This creates a vicious cycle that leads to higher and higher inflation levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICLf1KSGRfdVv-vAFUD0gQ.png" /><figcaption>Source: IMF</figcaption></figure><p>Debt to GDP reveals how governments among countries have all reacted in the same fashion to the pandemic crisis: with huge fiscal stimulus. The pattern is similar for all the countries examined, despite different starting levels. The US and the UK are, probably, the ones having experienced the highest percentage increase of government debt, with America surpassing the 100% level for the first time in its history. These generous fiscal expenditures are another reason of why inflation skyrocketed there. The problem with too much debt is that it’s good as long as the proceeds are invested in investments that generate a nominal return higher than interest rates paid. Otherwise, it’s a drag on the economic growth of the country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjTmvpfx3Hxan28PRAy3XQ.png" /><figcaption>Source: OECD</figcaption></figure><p>For the current account to GDP indicator, I preferred to report annual (instead of quarterly figures) values. This is because not all countries in our sample report this figure with the same periodicity. The OECD kindly releases projections up until the next two years as well. If we focus our attention just to actual data (up until 2021), we note a further decline in the case of US and UK, while other countries have reversed the trend. It’s especially particular the case of Australia, where the current account surplus was driven by strong prices for exports of coal and other mineral fuels as well as greater volumes of agricultural exports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRJVHey7qXfI9DaacKqdFA.png" /><figcaption>Source: BIS</figcaption></figure><p>In connection with the current account analysis, in the above table we can see the trend in the REER (the weighted average of a country’s currency in relation to an index or basket of other major currencies). This is important, because REER and the current account are inversely related, since an appreciation of a nation’s currency negatively impacts its exports and vice versa. We see here how the appreciation of the USD may have played a key role in this case, and the same goes for the AUD, as mentioned before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vG3US0ls98Vx5knBasdvg.png" /></figure><p>For convenience, I reported above a comparison of each indicator for each of the countries we have analysed before.</p><h3>Business cycle analysis</h3><p>The business cycle analysis is carried out by comparing leading, coincident and (sometimes) lagging indicators. If we see that leading indicators are increasing compared to the others, then we may expect an expanding business cycle. In the other case, the opposite is true. There are many ways to conduct this analysis. In this instance, I proceeded in this way: for the calculation of the leading economic indicator, I have taken the 10 leading indicators used by the Conference Board (<a href="https://www.conference-board.org/data/bci/index.cfm?id=2160">https://www.conference-board.org/data/bci/index.cfm?id=2160</a>) and related standardisation factors. Then, I multiplied these factors for each indicator’s score to obtain an adjusted score. The above score can have three different values: -1, 0 and 1, depending on whether the current value improved or not compared to the previous one-month and previous twelve-month values. Once obtained the adjusted scores, I summed them up. For the coincident indicators, I proceeded in the same manner, but this time taking the four indicators suggested by the Conference Board and using the related weights. Finally, I compared these two indicators along with the lagged one-month performances of the S&amp;P 500.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*agM8jlsA6qElPrwQjyujuA.png" /><figcaption>Source: The Conference Board and Yahoo!Finance</figcaption></figure><p>We can notice that, generally, when the LEI &gt; CEI the S&amp;P 500 reported a positive performance in the following month. This pattern failed in the last two months, maybe because of the impact of the Christmas rally (that boosted S&amp;P 500 returns) combined with the Omicron strain (which weighed on non-farm payrolls and retails sales in December).</p><h3>Sectors relative strength</h3><p>In this section we’ll see which sectors (in the US financial markets) are outperforming and which are underperforming relative to the broad S&amp;P 500. To do this, I used the 11 sector SPDR ETFs data and then calculated the RS Ratio and RS Momentum, as per the Julius de Kampenaer methodology (<a href="https://www.relativerotationgraphs.com/">https://www.relativerotationgraphs.com/</a>), while for the Python code, I referred to the github repository of <a href="https://github.com/vlaranjo/Vasconomics_Materials/blob/master/Articles/RRG/Relative_Rotation_Graphs.ipynb">https://github.com/vlaranjo/Vasconomics_Materials/blob/master/Articles/RRG/Relative_Rotation_Graphs.ipynb</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*a0skTAzBPBQmYhIkg7I7EA.png" /><figcaption>RRG plot functioning</figcaption></figure><p>The relative rotation graph takes into consideration two dimensions: the relative strength of the base security compared to the benchmark (RS = security A / benchmark); and the relative momentum (rate of change). If the security is in the top right quadrant (both values above 100) it said to be leading; if both are below 100, then it is in the lagging quadrant; in the other two cases it is either improving or weakening. Sometimes, especially during small corrections, securities can fall into the weakening quadrant and then get back to the leading one. The same goes for the lagging quadrant. This way of analysing sectors (or other asset universes) is interesting, because it has been demonstrated that sectors tend to follow this cyclical pattern.</p><p>The 11 sectors composing this stock universe are the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*_BbzbflpI-638i_mZ_VK7A.png" /><figcaption>Source: SSGA</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*cGPwUjAQS_CUJIEFhdToCw.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>As of January 31st, we see that most sectors still find themselves in the leading quadrant, with the following exceptions:</p><ul><li>XLY (Consumer Discretionary) → Improving</li><li>XLB (Materials) → Lagging</li><li>XLK (Technology) → Weakening</li></ul><p>This can be interpreted as if the US economy is moving to a new phase of the business cycle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uNJHDKKmV_aOdaINYiO-w.png" /><figcaption>Business cycle Vs Financial cycle</figcaption></figure><p>From the chart above we note that in the first phase of the financial cycle (typically when rates are low, stocks have started to recover along with bonds) sectors like technology and cyclicals tend to outperform others; as the economy (i.e. the business cycle) improves other sectors like energy and services generally do better. This is not always exactly like this, but it would be considered as the norm: in fact, it’s normal that, as sentiment improves, consumers tend to increase their spending for services and energy prices soar following pent-up demand. Therefore, we may conclude that the US economy is transitioning to the “Full Expansion” phase.</p><h3>Asset classes performances</h3><p>We move along looking at performances (in USD) of the different asset classes on monthly, yearly and YTD basis.</p><p><strong>Equities</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ou_9BcxkbPhXiHXbGerAdA.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>From the charts above, we note that Bovespa (the major Brazilian stock index) and the FTSE 100 are the only indices in green territory. This may be attributable to the fact that both benefitted from two factors: rising commodity prices (of which Brazil is a net exporter) and rising rates (the FTSE 100 is heavily tilted toward financials, which benefits from rising rates).</p><p><strong>Government bonds</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsMyFF43uimo67g7KLxfgg.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>Moving to government bonds, we note that most countries have suffered the increase in inflation, with yields (that move in the opposite direction of bond prices) rising. Only China has experienced a different trend, and PBoC is one of the few central banks that is moving in opposite direction with regard to monetary policy (easing instead of tightening).</p><p><strong>Credit</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEDJw3UKNAbWfibFNKoVsg.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>With regard to credit, we see that investment grade (both US and EU) suffered the most, while MBS resisted better to general rising yields. Noteworthy, investors have warned throughout 2021 that high-quality credit was expensive on a spread-adjusted basis.</p><p><strong>Commodities</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*towzfMcF0k_Jf1Ib_j-t-A.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>Commodities are probably the brightest spot so far. In fact, as demand speeds up in most developed economies and geo-political tensions rise, commodities prices soar. We see that copper (considered an economic leading indicator) slowed down recently, while natural gas and crude oil reported the best results, as a consequence of rising tensions over Ukraine. Interestingly, gold and silver (usually considered safe havens) underperformed so far, despite rising geo-political tensions. We may attribute this to the fact that yields are rising globally (neither gold, nor silver pay any dividend or interest), but a potential invasion of Ukraine by Russia (or an invasion of Taiwan by China) may invert this trend.</p><p><strong>Forex</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLcne8l_IJLWfRFUJXmXAw.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>From the charts above we note that the threat of economic sanctions to Russia are having the desired effect. The ruble tumbled in January compared to the USD, while the Brazilian real reported the best result (probably, because of rising commodity prices). In general, most currencies underperformed the USD, as the FED is turning more hawkish (pushing yields higher).</p><p><strong>Cryptocurrencies</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fz-rNtKqXJHFcqjL1p0yBA.png" /><figcaption>Source: Yahoo!Finance</figcaption></figure><p>Finally, we can fully appreciate the effect of rising yields on cryptos. After an explosive 2021, this asset classes tumbled, failing to prove as an inflation hedge (as advocated by many crypto-believers so far).</p><h3>Technical charts</h3><p>In this section I’ll highlight some candlestick charts exhibiting interesting patterns.</p><p><strong>US Corn</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XZXMOqtV-G_9lIdo.png" /><figcaption>Source: investing.com</figcaption></figure><p>In the US Corn chart we notice a negative divergence occurring on the RSI. If we look back further in the past, we actually see that another divergence occurred between November and December as well, but on that occasion the rally went on. But this time we also notice a double inside candle pattern at the end of an over-extended bullish trend. Therefore, it may be even more significant as a reversal pattern.</p><p><strong>Shanghai Composite Index</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CnjEEhwMJ_oDohwd.png" /><figcaption>Source: investing.com</figcaption></figure><p>We know that the Chinese stock market is closed due to the China New Year holiday. It broke on the last available close a key support trend-line. Therefore, it’ll be interesting to see how it will re-open following the New Year’s celebration. Another interesting thing to notice is that volume accompanying the most recent downtrend is decreasing. So, maybe, this was nothing but a false breakout.</p><p><strong>EUR/USD</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jJY2wsnB49G8PnlH.png" /><figcaption>Source: investing.com</figcaption></figure><p>Finally, on the EUR/USD daily chart, we assisted at the occurrence of a positive divergence on the RSI at the end of January. Furthermore, a spinning top at the end of the downward trend followed by a strong bullish candle, may signal the beginning of a new bullish macro trend.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d17239c5bf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A risk assessment of the US economy]]></title>
            <link>https://medium.com/@lucadonghi_25036/a-risk-assessment-of-the-us-economy-95461cbaafe3?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/95461cbaafe3</guid>
            <category><![CDATA[us-economy]]></category>
            <category><![CDATA[risk-assessment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[alternative-data]]></category>
            <category><![CDATA[macroeconomic-analysis]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Mon, 31 Jan 2022 14:53:10 GMT</pubDate>
            <atom:updated>2022-01-31T15:12:12.791Z</atom:updated>
            <content:encoded><![CDATA[<p>The intent of this article is to dig deeper into the figures of the US economy to determine strengths and weaknesses of it. I will then condense my conclusions in a so-called “Risk Assessment Matrix”, where I will assess the level of risk for each macroeconomic dimension analysed. We will look at a complete set of economic variables, like growth, demand, inflation, financial soundness indicators, monetary and fiscal policy, as well as the external position. Finally, we’ll look at the current impact of the Covid-19 and assess US climate change “readiness” and “awareness”. The data used for this analysis are taken from multiple sources, like the IMF, OECD, FRED, etc. and are elaborated in Python to produce useful charts and statistics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*E3i8VlYvi9H_ppbyrx8aHQ.png" /></figure><h3>Contents</h3><ol><li>Supply and Productivity</li><li>Output Gap</li><li>Aggregate Demand Analysis</li><li>Inflation Analysis</li><li>Monetary Policy Analysis</li><li>Macro-financial Linkages</li><li>Fiscal Policy Analysis</li><li>Fiscal Sustainability Analysis</li><li>External Position Analysis</li><li>Real Exchange Rate and Competitiveness</li><li>Trading Partners Analysis</li><li>Covid-19 Analysis</li><li>Climate Change Readiness and Vulnerability</li><li>Risk Assessment Matrix</li><li>Key Takeaways</li></ol><h3>Supply and Productivity</h3><p>In this section we are going to analyse the total factor productivity and labor supply of the U.S. Our goal is to understand if the so-called “A” factor in the Cobb-Douglas function (Y = A * K^a * L^(1-a)) is positive (meaning that structural reforms, technological progress and policies are contributing positively to the long-term productivity of the country) or not. We will also look at the unemployment level compared to its natural rate and estimate the potential level of labor (L*).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-NSd_Io1truTG9pgLSA0w.png" /><figcaption>Source: AMECO (<a href="https://ec.europa.eu/info/business-economy-euro/indicators-statistics/economic-databases/macro-economic-database-ameco_en">https://ec.europa.eu/info/business-economy-euro/indicators-statistics/economic-databases/macro-economic-database-ameco_en</a>)</figcaption></figure><p>Looking at actual and projected data, we notice an upward trend for TFP (first chart), signalling a positive impact by the intended reforms, as well as technological innovations. At the moment of the writing of this article, the Biden Administration is making an attempt to pass the so-called “Build-Back-Better” act that would pour trillions of dollars in funding for COVID-19 relief, social services, welfare, and infrastructure, in addition to funds allocated towards reducing the effects of climate change. Sen. Manchin of West-Virginia pulled-off his support to the Dems on concerns about debt sustainability and upside risks of inflation on an already hot-running economy. On the other hand, President Biden managed to pass the $1.2 trillion bipartisan Infrastructure Investment and Jobs Act, a law that will rebuild America’s roads, bridges and rails, expand access to clean drinking water, ensure every American has access to high-speed internet, tackle the climate crisis, advance environmental justice, and invest in communities that have too often been left behind. These reforms, if implemented efficiently, should boost US growth, justifying that upward-sloping line depicted in the TFP chart above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*cQI-bNEErUkks5nEuYYwWA.png" /><figcaption>Source: <a href="https://www.whitehouse.gov/bipartisan-infrastructure-law/">https://www.whitehouse.gov/bipartisan-infrastructure-law/</a></figcaption></figure><p>Despite many economists are arguing that simply renovating existing infrastructures won’t boost economic productivity as promised by politicians, these measures may really provide a booster to US growth, especially if it will be more inclusive for minorities that are often left behind, but that constitute an important resource for the Country.</p><p>Moving to another important factor, labor, I have tried to estimate the so-called “potential labor” trend-line, i.e. the labor factor level that would allow an economy to grow at a sustainable level, without triggering a spiralling inflation. For this purpose, I applied the HP-filter to the log of employment level and then plotted it against actual labor level. I also plotted the labor force participation rate and the FRED actual vs natural unemployment rates to have a better picture of the US labor market.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*0fYPUjkWTTr5BS3QUfYulQ.png" /><figcaption>Source: <a href="http://www.ilo.org/global/copyright/request-for-permission/lang--en/index.htm">http://www.ilo.org/global/copyright/request-for-permission/lang--en/index.htm</a> and <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>From the charts above we can notice three important things: first, it’s impressive the resilience of the US labor market after the pandemic struck the economy; second, we notice that it seems the labor market is quite tight currently, with the last reading of unemployment rate standing at 3.9% (almost the same level as before the Covid-19 crisis); finally, the participation rate is way below the level seen before 2020, indicating that lots of workers dropped off the unemployment statistics, either because they are discouraged or because many of them decided to retire earlier, thus avoiding the risks of getting sick with Covid. This is a clear sign that the low unemployment rate is actually “masked” by a reduction in the participation rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*oChgvGrU3N2LSOl3ZjoZWA.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>In fact, the U6 indicator (defined as “Total Unemployed, Plus All Persons Marginally Attached to the Labor Force, Plus Total Employed Part Time for Economic Reasons, as a Percent of the Civilian Labor Force Plus All Persons Marginally Attached to the Labor Force”) stands at 7,3%. That said, we can conclude that the current labor supply in the US is quite tight and this is definitely contributing to the high inflation being experienced since 2021.</p><h3>Output Gap</h3><p>In this section our goal is to understand if the economy is running a positive or negative output gap. In the first case we should expect a more tightening approach from policymakers, while in the second one a more dovish attitude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*3OFHAAuEHjhFQUzMwQychA.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>From the charts above, we see that according to the IMF WEO, the US is already running an output gap, meaning that the economy is growing beyond its sustainable level (the difference between actual and potential GDP is, in fact, positive). I tried to apply the HP-filter to the log of GDP to derive the potential output of the US and I got to the same conclusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*D92_pAVLpgJGKcDvF4H1NA.png" /></figure><p>The U-turn in GDP growth following the second quarter of 2020 is impressive, a “litmus test” that the ultra-expansive monetary and fiscal policies adopted by the US Government and the FED, not only shielded the economy from a dramatic recession, but also put it on track for the quickest expansion ever registered in US history. The downside is that the economy is probably overheating at the moment: in fact, both the government and the central bank are battening down the hatches, reducing fiscal stimulus and moving toward a hawkish monetary policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*un0EJqQUtO_WYYAXOuqMlA.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>Another confirmation of this, can be derived from the OECD Composite Leading Indicator, which, after spiking since the summer of 2020, is now turning down. The composite leading indicator (CLI) is designed to provide early signals of turning points in business cycles showing fluctuation of the economic activity around its long term potential level. CLIs show short-term economic movements in qualitative rather than quantitative terms. We can interpret this as an indication that growth trend is (likely) expected to slow in 2022 compared to 2021.</p><h3>Aggregate Demand Analysis</h3><p>In this section we are going to analyse the components of aggregate demand to understand from where the positive or negative growth is coming from. We will also look in more detail at the components of the private consumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*2CB1DyV0nS2b3YQIWsgOtQ.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>We see that, as expected, the US economy heavily depends on its huge domestic market: in fact, private consumption is the greatest component of its GDP, followed by private investments and government spending. This composition hasn’t changed much in the latest years (please, note that each observation in the charts is annotated with the first day of the quarter, but refers to the entire quarter. So, “2021–10–01” refers to the data of the fourth quarter of 2021).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*fvakPCCHk6MLHCM5jObrlg.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>From the charts above we notice that the “openness” (defined as the sum of exports and imports) of the US economy recovered well following the spread of the coronavirus. Nevertheless, imports accelerated at a stronger pace than imports, since US consumers having splurging on goods (mostly coming from China) rather than services during this period.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*K3Gq-kpD0jbQ2E4a4ijfYA.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>Looking at the contribution of each component of the aggregate demand to GDP growth, we interestingly notice that in the most recent release, change in inventories contributed positively, as businesses ran to fill their shelves and warehouses amid one of the worst supply chain disruptions ever registered. This may be one of the reasons why analysts reacted with skepticism to the last GDP figure release, as the growth seems to be driven more by an increase of inventories, rather than of private consumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*air1GBoWXG5iYP7ss6v7Qw.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>Taking a more granular view at the “private consumption” component of the aggregate demand, two things immediately jump out: the tremendous spike in durable goods purchases since the pandemic started and the negative contribution of services, generally a steady and positive item in the AD “pie”. It’s not difficult to explain why this happened of course: lockdowns and other kind of restrictions tilted demand away from services (e.g. restaurants, travelling, cinemas, etc…) toward goods. We also note how, since Q2–21 this trend is clearly inverting, with services surpassing purchases of durable goods in the latest two quarters, a positive sign that we might be near the end of the health crisis. Nevertheless, we should also point out that a slowdown in order for durable goods is not a healthy sign for the status of the business cycle (but we learned that a pandemic shakes out the traditional macroeconomic laws).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*Favq0lRhpplNTb2njv7HYg.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>This is even more clear if we look at the chart above, where we can see the contribution toward GDP growth of each component of private consumption, with services retaining the lion’s share in the last three quarters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*7vGttwQrrDry43da5AL-jw.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>The chart above depicts the OECD monthly Consumer Confidence Indicator, a measure of the consumer sentiment in the US. We notice how the trend, after improving following the first months of the pandemic, is currently in a downtrend. One of the reasons behind this negative sentiment, can be attributed to the vanishing effect of the generous fiscal stimulus, as US consumers have been depleting their extra-savings. Furthermore, the Delta variant first, and Omicron strain later have likely contributed to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*uGCSV3lvfjSBM3tsNTB1FA.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>We can repeat the same exercise with private investments and government spending and notice that the former item, which is the second most important item among GDP components, is decreasing at a steady pace since Q2–21. Nevertheless, it’s perhaps coming back to a more sustainable level rather than falling precipitously. In fact, it bounced back sharply at the end of 2020, after becoming negative at the dawn of the pandemic. Of course , a less accommodative monetary policy by the FED may also encourage less businesses to invest in CAPEX.</p><h3>Inflation Analysis</h3><p>In this section our goal is to assess actual and expected inflation pressures from different perspectives. In fact, after analysing different measures of inflations (CPI vs GDP Deflator), we will have a look at 10-year forward expectations (based on the 5y, 5y Fwd Inflation Expectation indicator) and then going deeper on inflation components performances. Then we will have a look at headline versus less volatile core inflation and, finally, we will assess wages and salaries trends, as well as base metals movements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*QQM3KUo7wz85aNUPK3F_oA.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>The first obvious figure we want to look at is the year-over-year inflation growth. According to the statistics, we should go back to the 80s to see such high levels of price levels growth. There’s a 500 basis points difference between the target level and the current level. This is of course not sustainable for US consumers and policymakers. Since September the FED has drastically changed its approach toward monetary policy. Powell clearly signalled that the labor market is not FED’s prime goal anymore, but it’s to rein in inflation. But do we really owe all this inflation spike to aggressive demand? The answer is a resounding “no”. In fact, one of the consequences of Covid-19 has been indeed the global supply chain disruption that we all have read in the news. Interestingly, the NY FED has developed an index that track the pressure on global supply chain, that should help us better contextualise this uncomfortable situation. The index integrates a number of commonly used metrics with an aim to provide a more comprehensive summary of potential disruptions affecting global supply chains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*Ex0-rAITb55PEJncHjgzhQ.png" /><figcaption>Source: <a href="https://libertystreeteconomics.newyorkfed.org/2022/01/a-new-barometer-of-global-supply-chain-pressures/">https://libertystreeteconomics.newyorkfed.org/2022/01/a-new-barometer-of-global-supply-chain-pressures/</a></figcaption></figure><p>In short, we are in uncharted territory. The index, which goes back to October 1997, is at its peak, and despite FED governors kept on predicting that the situation would have eased after the second half of 2021, we are still can’t see the light at the end of the tunnel. Therefore, US is experiencing a rare case of supply-driven inflation, combined with strong appetite for goods, as consumer have been forced to direct their purchases away from services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*pcoC0GfG0Xr98bAlntuD_A.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>The chart above depicts the so-called 5-year, 5-year forward inflation expectation rate: it is a measure of expected inflation (on average) over the five-year period that begins five years from today. We can see that, it remained elevated throughout most part of 2021, but it’s currently fluctuating around the target level of 2%, signalling that these inflation fears are expected to moderate, at least in the medium term. Nevertheless, the situation in the short-term may be quite different, with consumers running the risk of a consistent reduction in their purchase power.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*_yHkPYYCap25J4TzplwXkQ.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>In fact, when looking at the various components of the CPI basket, essential items like housing, water, gas and transport retain the lion’s share. Therefore, we can easily understand why keeping price levels under control is crucial for a healthy economy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*o42vEhn-KlBPD-IEaD6PJw.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>The bar charts above represent the absolute and relative contribution to inflation growth of each CPI item during 2021: we notice how transport and food have impacted the consumers’ pockets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*E5ls7afzVHQbE07lqtJVwg.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>Even if removing the most volatile components (i.e. food and energy) from the inflation basket, we see that the current situation is out of control in the US.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*AkTACQJdZOX5b6KVifgLWA.png" /><figcaption>Source: <a href="https://www.bls.gov/">https://www.bls.gov/</a></figcaption></figure><p>Rising prices and a tight labor market push workers to demand higher wages (as shown in the chart above), which further reinforces the spiralling prices increase. And what about one of the most important assets for consumers?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*_lUEasrS8Y_t1U6bd4cM7g.png" /><figcaption>Source: <a href="https://www.fhfa.gov/DataTools/Downloads/Pages/House-Price-Index.aspx">https://www.fhfa.gov/DataTools/Downloads/Pages/House-Price-Index.aspx</a> and <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>Well, according to the Federal Housing Finance Agency, which reports the House Price Index (a broad measure of the movement of single-family house prices), and to the Home Price Index of S&amp;P/Case-Shiller (a monthly index that tracks changes in the price of residential real estate in 20 major metropolitan regions in the U.S.), the US housing markets is running extremely hot: this is a consequence of the combination of a limited supply on one side, and historically low mortgage rates on the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*3lSrbL1yfZK3_rqrJYo4Cg.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><h3>Monetary Policy Analysis</h3><p>In this section we are about to analyse how the monetary policy is and how it should presumably evolve over time. For this purpose we will look at the FED “Dot Plot”, as well as the Real Monetary Condition Index, which suit well where the CB is focused on inflation goals. The limitation of the latter tool lies in the calibration of the parameter used in the formulas, which may differ from the one used by the Central Bank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*bD7eiDKv_SJ-httGK4NS2Q.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>Our analysis shall start looking at how the FED drastically reviewed its expectations for the future monetary policy path (I am referring to the “dot Plot” chart at the bottom) in light of the risk of an entrenched inflation and a lower unemployment rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*nC0BA6GuNAO1zsyTEYYetw.png" /></figure><p>In the chart above I reported the Real Monetary Condition Index for the US with a value for the alpha parameter set at 0.8 (for Developed Countries this parameter is set at 0.7 or higher, while for Emerging Markets is between 0.3 and 0.7). The index is obtained using the following formula:</p><p><strong>(a * real interest rate gap) + ((1-a) * real exchange rate gap)</strong></p><p>A positive value for the index points to tight monetary conditions, constraining domestic demand and therefore inflation. A negative index points to accommodative conditions, boosting demand and therefore inflation. If we play around with the alpha parameter shifting it to higher or lower values, we still see that the RMCI indicates expansionary monetary conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*Q_hMnETmLdyZAhA0vnXagA.png" /><figcaption>Source: <a href="https://finance.yahoo.com/">https://finance.yahoo.com/</a></figcaption></figure><p>Market participants have also been increasing their bets of at least a 0.25 rate hike at the next FOMC in March. Actually, some are even betting that the FED might be forced to hike rates by 50 bps.</p><h3>Macro-financial Linkages</h3><p>In this section we’ll look at main ratios of financial soundness (FSIs) and their recommended thresholds under Basel III. Furthermore, we’ll evaluate the chance of default in the banking system using the z-score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*zIyILhqKVNt9gYAbDxc-dw.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>From the indicators above we can see that financial institutions in the US are well within key risk parameters in terms of regulatory capital and leverage applied. The former indicator in terms of total assets have considerably fallen following the pandemic, but this may also be a reflection of the increased amount in deposits held by Americans thanks to the generous government fiscal stimulus. In fact, it’s true that deposits represent a liability for banks, but these liabilities must be counter-balanced with high-quality assets, like Treasuries. Furthermore, the aggressive quantitative easing implemented by the FED has resulted in a tremendous injection of liquidity in the system, that boosted asset valuations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Q1qUHUGq9CuwPtnXet5Akw.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>We also note that, despite the dramatic situation induced by Covid-19, the proportion of non-performing loans is under control and way below the level seen during the Great Financial Crisis of 2008.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*-r-hKonpLzVey7VB2ANYAw.png" /><figcaption>Source: <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a></figcaption></figure><p>Return on assets has also came back to its pre-pandemic levels, and we may expect it will also improve as FED is about to increase rates from current levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*gG0Xf4SOajeqFU2olnLvpQ.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>Interestingly, liquidity has never been better than now, probably linked to the reasons mentioned earlier. In general, we can conclude that the US financial system is quite sound despite the threats posed by the pandemic.</p><h3>Fiscal Policy Analysis</h3><p>In this section we look at how discretionary fiscal policy measures compare to the business cycle. Specifically, we want to understand if the fiscal policy is pro or counter-cyclical in relation to the business cycle. We will analyse the fiscal impulse (the first difference of the fiscal stance, that is a measure of fiscal policy net of automatic stabilizers) and the relative position of primary balance vs cyclically adjusted primary balance to assess whether the economy is above or below potential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*UQ8awVFe1VdGEO5coqgxXA.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>From the chart above, which depicts overall and primary balance (i.e. overall balance minus interest spending), we can see that the US government reacted strongly to the current and precedent crisis (i.e. the Great Financial Crisis of 2008). In fact, the fiscal balance dropped sharply in both cases, in an attempt to shield the economy. Nevertheless, IMF projections indicate that this fiscal generosity should be reined in in future years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GTpc9XlB436BW38cz0jPeA.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>The chart above depicts US fiscal impulse, along with the primary balance and the cyclically adjusted primary balance (i.e. the difference between the overall balance and the automatic stabilisers). Before commenting the chart above, we should clarify some concepts:</p><ol><li>When Primary Balance &gt; Cyclically Adjusted Primary Balance, output gap is positive: if fiscal impulse is positive, then fiscal policy is pro-cyclical, otherwise it is counter-cyclical.</li><li>When Primary Balance &lt; Cyclically Adjusted Primary Balance, output gap is negative: if fiscal impulse is negative, then fiscal policy is pro-cyclical, otherwise it is counter-cyclical.</li></ol><p>Generally, we would like to see counter-cyclical fiscal policy to face short-term business cycle needs, but sometimes fiscal policy is pro-cyclical in order to balance medium-term fiscal policy sustainability.</p><p>We can clearly see how much US fiscal policy has been counter-cyclical during the most recent two crisis, but it’s impressive the level of fiscal generosity put in place during the pandemic, which is almost double compared to 2008.</p><h3>Fiscal Sustainability Analysis</h3><p>In this section we are going to look at how Debt/GDP varies according to different scenarios: in fact, changing hypothesis about GDP growth, interest rates, primary balance and currency depreciation/appreciation, we will obtain different paths of debt evolution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*S-sQ-BMaqIzCt4cvNF31ng.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>First, let’s have a look at current figures: Net Debt/GDP reached for the first time in American history the 100% threshold level, which is considered highly significant from international institutions such as the IMF and the World Bank. In fact, when Developed Countries pass this threshold, they tend to exhibit lower level of growth compared to their peers that have less debt. Furthermore, it is interesting to notice that the slope of the curve steepened dramatically in two occasions: following the financial crisis of 2008 and the Covid-19 pandemic. Projections from the IMF show a positive trend for the coming years: this is something that US policymakers need to consider when contemplating fiscal measures like the “Build Back Better” act.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*OOHwoM25P09s4_jjef8RrA.png" /></figure><p>In the chart above I tried to design a possible path for the US Gross Debt to GDP. The parameters used in the formula are hypothesis for the period 2022-2026:</p><ol><li>gr → GDP growth rate</li><li>r → interest rate</li><li>pb → primary balance</li></ol><p>Perhaps my hypothesis are not realistic, but it’s also true that is difficult to even forecast beyond one month! Under this scenario, we see that gross debt flattens from 2023, as primary balance is expected to recover. What if we assume a negative growth in 2024 due to an unpredictable shock, accompanied by a rate cut and a decreasing primary balance?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*-lt1jswKXYQ7feaZLB0TrA.png" /></figure><p>As expected, the curve steepens from 2023, as counter-cyclical fiscal policy would need to adjust to the unexpected shock.</p><h3>External Position Analysis</h3><p>In this section we will analyse the current account situation of the country. Specifically, we want to understand if the country is running a surplus or a deficit. The CA can be seen from two perspectives:</p><ol><li>net exports + primary and secondary income; or</li><li>savings - investment.</li></ol><p>A deficit means the country is receiving more flows from abroad to finance its investment and have imports &gt; exports; a surplus means that the country is investing more abroad to fund foreign countries investment and have exports &gt; imports. We will also analyse the different components of the financial account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*yho3tkWfk3BMLb66MO2WiA.png" /><figcaption>Source: Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>We see that the US has always been running a current account deficit from the 90s. We also notice that after the Great Financial Crisis of 2008 the CA recovered, primarily as a consequence of lower imports, as we may recall from the chart in the section on AD analysis that I report below for convenience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*fvakPCCHk6MLHCM5jObrlg.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>Interestingly, exports have not risen much in 2021 compared to imports, since China (one of the biggest trading partners of the US) did not meet its promised targets contemplated by the Phase One deal reached under the Trump’s presidency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*mFoiw8bmeav_BseXH9JyNw.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>Looking at it from another perspective (“savings — investment”), we clearly see that this deficits need to be financed somehow (i.e. by countries with a current account surplus that compensate insufficient US savings). We also note that IMF projections point at an improvement of the CA in the coming years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*Vs6Q0VQis4jnTAU7BWCcVQ.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>The Real Exchange Rate is inversely proportioned to the CA. In fact, an appreciation of the REER leads to an increasing CA deficit (because exports tend to decrease compared to imports if the currency appreciates); on the other hand, if the REER depreciates, we may expect a decreasing deficit or an increasing surplus (because exports tend to increase compared to imports if the currency depreciates). The elasticity of CA to variations in REER is given by eta (i.e. the CA elasticity). We can notice how, in recent years, the REER appreciated leading to a deterioration of the CA deficit. This may also explain the willingness to carry on a trade war with China, especially under the Trump’s presidency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*KPipPFj93Rt0bCFf7gQ6Xw.png" /><figcaption>Source: AMECO (<a href="https://ec.europa.eu/info/business-economy-euro/indicators-statistics/economic-databases/macro-economic-database-ameco_en">https://ec.europa.eu/info/business-economy-euro/indicators-statistics/economic-databases/macro-economic-database-ameco_en</a>)</figcaption></figure><p>External Terms of Trade (i.e. Price of exports / Price of imports) tell us how much did the changes in export prices or import prices, holding all else constant, boost or push down the CA balance. Interestingly, we notice that a divergence is occurring between these two indicators. We already know that the US are importing more than they are exporting, but (probably) the appreciation of the USD is making US exports dearer (maybe the US is exporting inflation).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Le27JE_EVUlvdimpEvu5pQ.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>The Financial Account has to be interpreted as: if CA &gt; 0, then FA &gt; 0; if CA &lt; 0, then FA &lt; 0. In fact, the financial account is the way current account is financed. Therefore, a negative change in FDI/Portfolio/Derivatives/Other Investment means that the country is accumulating more liabilities (i.e. inward flows &gt; outward flows); on the contrary, if there is a positive change in FDI/Portfolio/Derivatives/Other Investment this means that the country is accumulating more assets abroad (i.e. inward flows &lt; outward flows). Unfortunately, we do not have data for 2021 yet, but it’s worth to notice the huge inflows of investments in US equities and public debt (i.e. “Portfolio” item), as a result of the accommodative monetary policy implemented by the FED. In fact, we do know that US stock indices outperformed their peers in 2020, also thanks to a tilt toward tech stocks, which benefitted from the “work-from-home” trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*UGcpDQlXWwh6_wWmDwr_YA.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>When reserves are decreasing, it’s likely that the country is financing temporary shocks to the CA with its stock of reserves. This is a short-term strategy that cannot be sustained for long periods, especially if reserves are depleted rapidly. In fact, in such instances speculative attacks on the local currency can easily take place. In the case of the US, we notice how the stock of reserves spiked over the last two years compared to the previous decade. This may be linked to the huge flow of money that foreign investors directed toward US that lead to a dollar appreciation. In fact, the Dollar Index moved from around a level of 90 to almost 96 in 2021.</p><h3>Real Exchange Rate and Competitiveness</h3><p>In this section we are looking at how the current account and REER are positioned relative to their equilibrium levels. Specifically, with the help of the IMF “External Balance Assessment” framework (<a href="https://www.imf.org/external/np/res/eba/data.htm">https://www.imf.org/external/np/res/eba/data.htm</a>), we will see if the country is running a positive current account gap (i.e., Actual CA &gt; Norm CA) or a negative current account gap (i.e., Actual CA &lt; Norm CA). In the former case, the REER is relatively undervalued and it has to appreciate to bring the CA balance back to its equilibrium level (in this scenario, exports are more stimulated than imports); in the latter case, REER is to be considered overvalued and it has to depreciate to bring the CA balance back to its equilibrium level (in this scenario, imports are more stimulated than exports).</p><p>There are several methods used by IMF to assess the current account gap and REER gap compared to their equilibrium level (i.e., EBA CA Regression, External Sustainability approach, EBA REER Regression).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*ksjW5QD3O9xsKKyuo8U6iQ.png" /><figcaption>Source: <a href="https://www.imf.org/">https://www.imf.org/</a></figcaption></figure><p>According to the IMF framework, if the value of the REER gap is between -5% and 5%, then the REER is broadly in line with fundamentals. If it is between -5% and -10% or between 5% and 10%, then it is moderately misaligned.</p><p>Unfortunately, the IMF provides this analysis with a year lag, but we can at least try to interpret the trend of these indicators: more specifically, we can easily see how the REER gap is moderately misaligned compared to the acceptable range (I am referring to the “Index REER Gap” plot). This means that the REER needs to depreciate in order to bring the CA back toward its equilibrium level. We know that the balance of trade has been of particular concern for the Trump’s presidency, which started the so-called “trade war” against China in 2018. In fact, China has been accused by the US to manipulate the yuan (besides other accuses) in order to keep it artificially low versus the USD, thus hurting US exports, while favouring Chinese ones.</p><h3>Trading Partners Analysis</h3><p>In this section we will assess the economic health status of key US trading partners in order to determine if there is an external threat to growth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*R-KoPJwsU2QYZHQZc_VuTw.png" /><figcaption>Source: wikipedia.org/wiki/List_of_the_largest_trading_partners_of_the_United_States</figcaption></figure><p>I highlighted in the table above the most important partners for the US based on total trade. We can see how China has the lion’s share (as a single nation), followed by the countries of the USMCA agreement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*Gd8f8o6z5nhY_bEEWb1tNQ.png" /><figcaption>Source: <a href="https://oec.world/en/profile/country/usa">https://oec.world/en/profile/country/usa</a></figcaption></figure><p>I think it’s also interesting to understand what are the main products exported by the US. In the table above (taken from the Observatory of Economic Complexity — OEC) we can see the products mainly exported by the US in 2019 (we cannot see more recent periods, but the percentages did not changed dramatically over the years), with oil, cars, soybeans and technology having the highest share.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*LQVxKP8yJKkqyQlFAQcQjA.png" /><figcaption>Source: <a href="https://oec.world/en/profile/country/usa">https://oec.world/en/profile/country/usa</a></figcaption></figure><p>We can also see where these exports are predominantly headed to, with Canada and Mexico being by far the greatest importers of US goods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*shUuqwO2jAMc-nkeoDyj1A.png" /><figcaption>Source: <a href="https://oec.world/en/profile/country/usa">https://oec.world/en/profile/country/usa</a></figcaption></figure><p>On the other hand, the image above reports the percentage share of each product imported by the US in 2019.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*sObxzrOO7YqQaN5Soza-Yw.png" /><figcaption>Source: <a href="https://oec.world/en/profile/country/usa">https://oec.world/en/profile/country/usa</a></figcaption></figure><p>And here we go! In the table above we can see from where the US imports its goods, and it’s easy to notice the imbalance between US exports to China compared to US imports from China. This may be a reason why America sees China as a not-fair competitor with regard to trade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*Bua7IzKyRTwoHpEeX_byGQ.png" /><figcaption>Source: <a href="http://www.oecd.org/">http://www.oecd.org/</a></figcaption></figure><p>In the charts above, I plotted the actual (2021) and projected (2022–2023) figures for the GDP growth and imports of goods and services of key US trading partners. We notice that, despite the trend of growth is expected to decelerate, imports levels should remain stable over the period (according to IMF projections).</p><p>Of course, in our analysis we need to take into consideration unpredictable shocks, like an invasion of the Ukraine by Russia, an invasion of Taiwan by China, persistent supply chain disruptions, limited exports of technologies considered strategic, export bans due to economic sanctions, etc…</p><h3>COVID-19 Analysis</h3><p>In this section we cover the evolution of Covid-19 and its impact on the US economy. Besides cases, deaths and vaccinations statistics, we will also look at mobility trends and the cost of transportation to assess the resiliency of the country to the pandemic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*ovMKmUsGX460Ln2e06ecYw.png" /><figcaption>Source: <a href="https://www.jhu.edu/">https://www.jhu.edu/</a></figcaption></figure><p>We see that cases in the US have spiked due to the Omicron variant, which spread in late 2021. Nevertheless, the deaths trend seems to remain constant, hopefully a sign that this last variant is not as lethal as the previous ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*V-RzcI5l3AOiZHOIVxJXww.png" /><figcaption>Source: <a href="https://www.jhu.edu/">https://www.jhu.edu/</a></figcaption></figure><p>More alarming is, instead, the fact that less than 70% of Americans completed the full vaccination cycle (70% is considered by the WHO a significant threshold to fight against the spread of the virus).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*Gvtgfq4osgdQ29_o_U6JoA.png" /><figcaption>Source: <a href="https://covid19.apple.com/mobility">https://covid19.apple.com/mobility</a></figcaption></figure><p>Apple mobility trends (reported in the charts above) indicate that Omicron impacted negatively mobility in recent months. Nevertheless, we see that the situation improved from a year ago.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*LEjcYEHzaIQH8DnXK59AQA.png" /><figcaption><a href="https://www.google.com/covid19/mobility/">https://www.google.com/covid19/mobility/</a></figcaption></figure><p>We can see a similar trend for mobility trends reported by Google.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*Sj-pmAX2vB9M3Zi5bgjlNg.png" /><figcaption>Source: <a href="https://www.opentable.com/state-of-industry">https://www.opentable.com/state-of-industry</a></figcaption></figure><p>Also, we see a confirmation of our conclusions from data reported by OpenTable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*kxS8BP8V9cHb9tzUsFnAvA.png" /><figcaption>Source: <a href="https://www.eia.gov/">https://www.eia.gov/</a></figcaption></figure><p>Finally, we see that airline ticket prices are expected to go up in the coming years, signalling a rebound in the demand. for travelling. On the other hand, gasoline prices, after spiking in 2021, are expected to decline in coming years: perhaps, this is a sign that air travelling will benefit at the expense of car travelling, as Covid-19 restrictions start easing. Of course, we know that this may also be viewed from the supply side, with OPEC+ playing a crucial role in determining the final price of oil.</p><h3>Climate Change Readiness and Vulnerability Analysis</h3><p>In this section we will analyse the evolution of the readiness and vulnerability to climate change indicators of the country. We will specifically look at the Notre Dame-Global Adaptation Index (ND-GAIN) framework, even if data is available only up to 2019. Therefore, an educated guess has to be taken for the most current period and future expectations.</p><p>The ND-GAIN Country Index is a free open source index that shows a country’s current vulnerability to climate disruptions. It also assesses a country’s readiness to leverage private and public sector investment for adaptive actions. ND-GAIN brings together over 74 variables to form 45 core indicators to measure vulnerability and readiness of 192 UN countries from 1995 to the present. All countries, to different extents, are facing the challenges of adaptation. Due to geographical location or socio-economic condition, some countries are more vulnerable to the impacts of climate change than others. Further, some countries are more ready to take on adaptation actions by leveraging public and private sector investments, through government action, community awareness, and the ability to facilitate private sector responses. ND-GAIN measures both of these dimensions: vulnerability and readiness.</p><p>For more information: <a href="https://gain.nd.edu/assets/254377/nd_gain_technical_document_2015.pdf">https://gain.nd.edu/assets/254377/nd_gain_technical_document_2015.pdf</a></p><p>ND-GAIN’s framework breaks the measure of vulnerability into exposure, sensitivity and adaptive capacity, while the measure of readiness into economic, governance and social components. The construction of the ND-GAIN framework is based on published peer-reviewed material, the IPCC Review process, and feedback from corporate stakeholders, practitioners and development users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*lDjq6kCMQutHxxbRkVeBfw.png" /><figcaption>Source: <a href="https://gain.nd.edu/our-work/country-index/">https://gain.nd.edu/our-work/country-index/</a></figcaption></figure><p>The chart above depicts a comparison of the ND-GAIN among Developed Countries plus China. At first glance, we see that there are three outliers: New Zealand, which is unfortunately converging downward toward other peers; Italy and China, with a lower score but that are slowly trying to gain ground. The value for the US doesn’t differ much from those of other Developed Countries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*4jBVcviBXZlnUXJmU_-aIg.png" /><figcaption>Source: <a href="https://gain.nd.edu/our-work/country-index/">https://gain.nd.edu/our-work/country-index/</a></figcaption></figure><p>ND-GAIN assesses the vulnerability of a country by considering six life-supporting sectors: food, water, health, ecosystem services, human habitat and infrastructure. Each sector is in turn represented by six indicators that represent three cross-cutting components: the exposure of the sector to climate-related or climate-exacerbated hazards; the sensitivity of that sector to the impacts of the hazard and the adaptive capacity of the sector to cope or adapt to these impacts. We notice that, while some indicators exhibits a negative trend (meaning less vulnerability) like food, infrastructure and ecosystem, on the other hand water and habitat have a decreasing rank, signalling weaknesses in these sectors from a climate change vulnerability standpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*dl8X88fb31favMFgAzK-tQ.png" /><figcaption>Source: <a href="https://gain.nd.edu/our-work/country-index/">https://gain.nd.edu/our-work/country-index/</a></figcaption></figure><p>ND-GAIN measures overall readiness by considering three components: economic readiness, governance readiness and social readiness.</p><ol><li>Economic Readiness: The investment climate that facilitates mobilising capitals from private sector.</li><li>Governance Readiness: The stability of the society and institutional arrangements that contribute to the investment risks. A stable country with high governance capacity reassures investors that the invested capitals could grow under the help of responsive public services and without significant interruption.</li><li>Social Readiness: Social conditions that help society to make efficient and equitable use of investment and yield more benefit from the investment.</li></ol><h3>Risk Assessment Matrix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*GwakfqB5F0nPdDHs0BFcWg.png" /></figure><h3>Key Takeaways</h3><p>After conducting a thorough analysis of the US macroeconomic condition, I think we would all agree that the major threats to growth come from inflation and trading partners. Geo-political tensions with Russia over Ukraine and China over Taiwan, as well as a FED perceived to be “behind the curve”, pose the highest level of risk to the US growth. While Covid-19 remains on the background as a material source of risk to growth (especially for services), we are assisting at an increasing ability to co-exist with it based on the “alternative” data analysed (e.g. mobility trends). Aggregate demand analysis highlighted an increase in inventories, which may have masked a slower trend in demand from consumers, confirmed by a downward trend in the Consumer Sentiment Index. Nevertheless, a normalisation of demand for goods and a recalibration toward services in Q2 (as coronavirus cases should decrease), would be more than welcomed, especially in a moment when supply-chain snags are contributing to a spiral in prices. The FED will presumably keep its promises for a reduction in monetary support by hiking rates and scaling down its monstrous balance sheet of almost $ 9 trillion. In the meantime, the Dems should keep on trying to pass their “B-B-B” act at the Congress, while considering that the federal debt is already on a dangerous path. Finally, with regard to the external trade, a further appreciation of the USD (as a consequence of the more hawkish policy implemented by the FED compared to others like ECB and PBOC) may make US exports less competitive and increase already existing trading imbalances, especially with China.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95461cbaafe3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Forecasting macroeconomic variables with multi-variate time-series models]]></title>
            <link>https://medium.com/@lucadonghi_25036/forecasting-macroeconomic-variables-with-multi-variate-time-series-models-afe13172ac40?source=rss-41aca90434dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/afe13172ac40</guid>
            <category><![CDATA[macroeconometric]]></category>
            <category><![CDATA[vecm]]></category>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[varma]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Luca Donghi, CFA, CMT, FDP]]></dc:creator>
            <pubDate>Wed, 26 Jan 2022 17:45:24 GMT</pubDate>
            <atom:updated>2025-11-06T19:01:07.621Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll try to predict the trend of US real GDP and US GDP deflator with the aid of multi-variate models such as VAR, VECM and VARMA. We will use the data from the FRED database (<a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a>) and the Python statsmodels library (<a href="https://www.statsmodels.org/dev/index.html">https://www.statsmodels.org/dev/index.html</a>) to build our models and make our forecasts.</p><h3><strong>Contents:</strong></h3><ol><li>Data set description</li><li>Exploratory Data Analysis</li><li>Data set split</li><li>Data transformation</li><li>Granger’s causality test</li><li>VAR model</li><li>VECM model</li><li>VARMA model</li><li>Forecasting four quarters ahead</li><li>Key takeaways</li></ol><h3><strong>Data set description</strong></h3><p>We are going to select several economic variables for these models:</p><ul><li>Real GDP</li><li>GDP Deflator</li><li>Total Employees Non-farm</li><li>REER (Real Effective Exchange Rate)</li><li>Money supply (M2)</li><li>Real disposable income</li><li>Personal Consumption Expenditure</li><li>New orders for durable goods</li><li>Crude Oil prices</li><li>New housing starts</li></ul><p>For the sake of simplicity when dealing with transformation, we have decided to select only levels and prices formats for our variables. Generally, as stated in <a href="https://www.princeton.edu/~mwatson/papers/favar.pdf">https://www.princeton.edu/~mwatson/papers/favar.pdf</a>, first differences of logarithms (growth rates) are used for real quantity variables, first differences are used for nominal interest rates, and second differences of logarithms (changes in growth rates) for price series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*HmnUdl3_AENH7qegBvpwRQ.png" /></figure><p>For the variables with a higher frequency than quarterly, we have used the “avg” aggregation method from FRED api.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*qDBm7_rTHIemgPjLG55qVw.png" /></figure><p>After a first look at the main stats of our data set, we see that some variables have almost 300 observations, while others less than 120. We may decide to discard those variables with too few observations, but we prefer to keep them all and train our model on a shorter time frame. From a macroeconomic standpoint, this is not necessarily harmful, since we know that some important structural breaks have happened after the 1980s (e.g. inflation trends).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*E1xLcLodo2Mlcn7H4EOfHw.png" /></figure><p>We have our aggregated and non-aggregated quarterly variables up to the third quarter of 2021, but the starting period differs among them. Therefore, in order to have all columns of the same period length, we delete the initial observations where we have NaNs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*5tLGErI2y0GHzu6LtBqNVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*fWOnQy-RA8QLgX9N-Ugx-w.png" /></figure><p>Now we have a 10-variable data set with a total of 111 quarterly observations starting on January 1st 1994.</p><h3><strong>Exploratory Data Analysis</strong></h3><p>It is considered best practice to start by visually inspecting the time-series in order to have an idea of their characteristics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*KcXIeIlB-s_Tzqvg7Kkxmg.png" /></figure><p>From the charts shown above, we immediately see that these time-series do not appear to be stationary. At first glance, we also observe typical features of economic variables, such as trends, heteroskedasticity, seasonality and structural breaks. So, let’s move on with our EDA to confirm our suspects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*v9t6y56vih-8W6K4CbTZ_A.png" /></figure><p>The violin plot, useful to detect seasonal patterns, does not seem to highlight the presence of seasonality (1 shows the distribution of data for the first quarters, 4 for the second ones and so on), but a series decomposition may reveal some hidden components of our time-series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*iJrekzQsPHMBc4sqFB8kzw.png" /></figure><p>After applying the seasonal_decompose method to our series, we can better break down each of them into their different components: notably,</p><ol><li>Trend;</li><li>Seasonality;</li><li>Residuals.</li></ol><p>Above we can have a look at the decomposition of our first three time-series and the importance of each of them. Now, let’s move on with another set of important plots: the ACF and PACF plots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*b26LmhF78LN77PjLHXU35g.png" /></figure><p>The ACF plots are useful to assess the auto-correlation of our variables and see how previous values influence today’s value. Specifically, the ACF plot shows the cumulative effect of each previous lag on current values, while the PACF (see below) accounts only for the direct effect that each previous lag has on today’s value. It measure the direct effect on the relationship between the time series and its lagged version (i.e. without taking into account indirect effects stemming from intermediate lags in the sequence). In fact, values three days ago affect values two days ago, which in turn affect values one day ago. These indirect effects are not considered by the PACF.</p><p>The first line indicates the auto-correlation one period ago; the second one indicates the auto-correlation two periods ago and so on. The max values that it can equal are -1 and +1. The blue-shaded area reflects significance: values outside this area are considered significant, suggesting the existence of auto-correlation. The greater the distance in time, the more unlikely it is that this auto-correlation persists (in fact, the area expands as lags increase).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*DtXFZsl7ROjkaLrVOao0_g.png" /></figure><p>From the ACF and PACF plots above we can clearly see that there is autocorrelation among the variables for several lags: this is an important indication of non-stationarity. We will need to transform our data in order to make it stationary, otherwise some of our models won’t be reliable (please, note that, out of simplicity, I only showed the charts for the first three variables, but results are quite similar for the remaining ones).</p><p>Now, we are going to run a specific test to check if our suspects of non-stationarity are true. This test is called ADF test (short for Augmented Dickey-Fuller test) and it has the following hypothesis:</p><ol><li>H0: the time-series is not stationary</li><li>H1: the time-series is indeed stationary</li></ol><p>As a quick refresh, the assumptions of a stationary time-series are:</p><ol><li>Constant mean</li><li>Constant variance</li><li>Cov(X(n), X(n+k)) = Cov(X(m), X(m+k))</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*11BFK1SwFcIcXSsoBIEUXw.png" /></figure><p>Looking at our first two time-series, we immediately notice that we cannot reject the null hypothesis of stationarity for both rgdp and gdp_defl (the remaining ADF tests, even if not shown here, point at the same conclusions). Therefore, we’ll need to transform our data in order to make it stationary and usable for our models.</p><h3><strong>Data set split</strong></h3><p>Before transforming our data set to make it stationary, we need to split it into a train and a test set so to perform validation tests with a hold-out set. Specifically, we’ll set aside 12 observations (i.e. 12 quarters): therefore, we’ll perform parameters estimation up to the third quarter of 2018 and then validate our model up to the fourth quarter of 2019 (a five-quarter ahead prediction).</p><p>We decide to estimate our parameters without taking into consideration the outbreak of Covid-19. This is because we want to avoid our model from being impacted by a shock that would distorte our estimations, due to the magnitude of the volatility of our variables. This is also acceptable according to: <a href="https://www.ecb.europa.eu/pub/pdf/scpwps/ecb.wp2461~fe732949ee.en.pdf">https://www.ecb.europa.eu/pub/pdf/scpwps/ecb.wp2461~fe732949ee.en.pdf</a>. Of course, we assume that the shock is temporary and that the “normal” model still holds in the future.</p><p>Below we can see the split of our original data set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*bYQo7BZqERMUTozLQMxJcA.png" /></figure><h3><strong>Data transformation</strong></h3><p>As anticipated, we first apply the natural log to our training data set in order to make all variables on the same scale and to deal with any potential skewness within them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*K76RJHPu2-ARPdiysQ4x4g.png" /></figure><p>After that, we’ll try differencing once our time-series and check for stationarity: unfortunately, differencing (also named integrating) a time-series leads to the loss of a row of observations, but this would make our data more stationary and, hence, useful for our forecasting purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*Vp23vnsr2wIa0jGcLmfgHA.png" /></figure><p>We notice from the charts above that our series now resemble “white noise”, i.e. a series type that meets all the requirements for stationarity mentioned above. But in order to double check our hypothesis, let’s run again an ADF test and see if integrating once was sufficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*RIQ7b91MY3xDgA4jcQUUDg.png" /></figure><p>From the image above, we clearly see that we are now able to reject the null hypothesis and claim our series to be stationary (despite not being shown here, all other p-values are below 0.05 too). If we plot the ACF and PACF charts again, we’ll notice that now fewer more recent lags are significant, which is good for our modelling purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*eR19fS1FllruEeZysHee6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*Z578RgLFLHfVmJKNXnFlaw.png" /></figure><h3><strong>Granger’s causality test</strong></h3><p>This test helps us to understand if a variable has explanatory power with respect to any other variable and vice versa. Before running it, we need to set the maximum number of lags to be used: a widely accepted rule of thumb states that the lag order “p” should be equal to:</p><p>(T/3) / n</p><p>where:</p><ul><li>T is the sample size</li><li>n is the number of variables</li></ul><p>Since our training set has 99 observations, we should not use a lag greater than 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*mLXX70KCjBSZtQ05eFuZDA.png" /></figure><p>The row are the Response (Y) and the columns are the predictor series (X). For example, if you take the value 0.1608 in (row 1, column 2), it refers to the p-value of gdp_defl causing rgdp_y. If a given p-value is &lt; significance level (0.05), then, the corresponding X series (column) causes the Y (row). In that case, we can reject the null hypothesis.</p><p>We note that each variable cannot be a good predictor of all other variables: for example, the real effective exchange rate (reer_x) seems to have good explanatory power for the gdp_defl_y (p-value less than 0.05), but not for r_gdp_y (p-value greater than 0.05). Theoretically, we should keep only those variables that have the greatest explanatory power and drop those that are not highly significant, but, for our exercise, we will keep them all. In fact, we are specifically interested in predicting rgdp and gdp_defl, and it seems that all the other variables can explain at least one of the two.</p><p>Now that we have performed all the necessary transformations and tests, we can move on with our first multi-variate model: the VAR.</p><h3><strong>VAR model</strong></h3><p>A multivariate regression is just several regressions in a trench-coat: in other words, we have regressions stacked on top of one another, one for each time series we’re including. For example, if we have a data set with four time series, a multivariate regression will fit a model for each one and include all of them in the regression. These are called vector models because every component contains a value for each of the time series. If we wish to include past values, we’ll be dealing with a vector auto regressive model simply known as VAR. If we include past residuals, in addition to that, we’ll be dealing with a VARMA and so on.</p><p>We start by initiating the VAR model and using the “select_order” in order to get the best value for “p”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*KZGrWWxSM2wGT3yXgDgcUQ.png" /></figure><p>The table above shows for each lag we decided to include in our model (in this case we opted for 3 as our “maxlags” parameter) what is the associated information criterion: for example, the AIC is an <a href="https://en.wikipedia.org/wiki/Estimator">estimator</a> of prediction error and thereby relative quality of <a href="https://en.wikipedia.org/wiki/Statistical_model">statistical models</a> for a given set of data. In short, we favour models with low information criteria. We notice that the AIC criterion indicates lag 1 as the best, while BIC another (but more parsimonious) information criterion indicates 0. For the sake of our model, we will stay with the lag indicated by the AIC (the most commonly used in econometrics), which is in agreement with other two criteria (FPE and HQIC).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*zn2fwxjzAS5Rc16h0q7HQw.png" /></figure><p>After fitting our model with the desired number of lags, we check for the serial correlation of residuals. Serial correlation of residuals is used to check if there is any left-over pattern in the residuals. If there is any correlation left in the residuals, then, there is some pattern in the time series that is still left to be explained by the model. In that case, the typical course of action is to either increase the order of the model or induce more predictors into the system or look for a different algorithm to model the time series. So, checking for serial correlation is to ensure that the model is sufficiently able to explain the variances and patterns in the time series.</p><p>We can use the Durbin-Watson statistic for our purpose. The value of this statistic can vary between 0 and 4. The closer it is to the value 2, the lesser the likelihood of significant serial correlation. The more it is close to 0, the higher the chance of positive serial correlation, while the closer it is to 4 the higher the chance of negative serial correlation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*Hmb0Gj-5SFkKnmxIe_fJ_A.png" /></figure><p>The Durbin-Watson test seems to indicate absence of serial correlation among residuals, as the values of the statistics lie around 2. A rule of thumb is that DW test statistic values in the range of 1.5 to 2.5 are relatively normal.</p><p>Now we can move on with our predictions. We predict five quarters ahead, i.e. up until the fourth quarter of 2019 (before the pandemic struck). We’ll then use a specific helper function in order to transform back our data to its original scale (applying the cumsum() and np.exp() methods). Before plotting our predictions against actual data, let’s see how accurate our predictions were, looking at the MAPE (i.e., |actual-forecast| / |actual| * 100). Taking 1-MAPE, we obtain the accuracy of our prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*bJsFBYAVW4p1h8CCVQ2wzQ.png" /></figure><p>The accuracy was quite high, but we need to remember that we have not taken into consideration the period when the Covid-19 hit the economy and therefore our economic variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*f-7dNTN-gp7loqN6rphblg.png" /></figure><p>From the charts above we can have a better view of how our predictions behaved in the out-of-sample backtest. Despite some clear failures, as is the case for oil prices and housing starts, the other variables have been decently predicted.</p><h3><strong>VECM model</strong></h3><p>Let’s now move to our next model: the VECM model. This model can be applied only to variables that are cointegrated, i.e. variables that, if combined in a linear way, ended being stationary. Therefore, we need to perform a test that assess whether for each lag allowed there exist at least one combination of our variables that allows for stationarity. This model imposes additional restriction due to the existence of non-stationary but cointegrated data forms. The advantage of VECM over VAR is that the resulting VAR from VECM representation has more efficient coefficient estimates.</p><p>First, we need to determine the order of “p” for our cointegration test and to later build our VECM model. To do this, we build a simple VAR model with our non-integrated variables and see what the optimal number of lags is. Then, we will take p-1 lags for our cointegration test and for our model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*0-0Bn3xr2SSDSlPBn3Ki_Q.png" /></figure><p>This time, we see that the suggested number of lags by the AIC is 2. Therefore, for both the Johansen cointegration test and for our VECM model, we will use 2–1 lags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*c1B2nZqIYrXV81_8ex3gbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*S7PPngZB4NIWb4VEcG6eyg.png" /></figure><p>The Johansen test reveals that there are 8 linear combinations at 1 lag. This number indicates the rank order of the VECM model. If the rank is 0, then there is no cointegration; if it is between 0 and n (where n is the number of our variables) there are r independent cointegration relationships; if it is equal to n (also called a full rank) then all variables are I(0) (in this case we must use a simple VAR model).</p><p>After fitting our model with 1 lag and a rank of 8, we then check for serial correlation of the residuals and move to the next steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*kFyb554sU_lMJQbCAfBQmg.png" /></figure><p>The Durbin-Watson test seems to indicate absence of serial correlation among residuals, as the values of the statistics lie around 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*Id--dG1n-i8GP5btzd3A7Q.png" /></figure><p>We note that the model slightly improved the prediction accuracy compared to a simple VAR. Now, let’s plot the predictions versus actual data for the same period we used in the VAR case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*8Vph9SsHJApIlMYztOE5ew.png" /></figure><p>We note that some variables that previously were badly predicted, are now more aligned to actual data, which is encouraging. Now let’s see if we can build a more complex model than our previous VAR and get better results.</p><h3><strong>VARMA model</strong></h3><p>The VARMAX model adds a moving average component to the VAR model, and it can allow for external, or exogenous, variables as well. Likewise VAR models, VARMA models need stationary data, so we’ll rely once again on our log-differenced training data set for training our model. We will then back-transform our results to make them comparable with actual values.</p><p>Since there is no easy way to estimate the best parameters p and q for our VARMA model, we need to create a for loop which iterates through all possible combinations of hyper-parameters and then select the optimal ones. We allow for a model with a maximum of 3 lags for each p and q (since we follow the rule of thumb already discussed in the VAR section for finding max p).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*RR3kbEvFtmgGWH5SY3X87w.png" /></figure><p>From the table above, we note that the top models in terms of lowest AIC are:</p><ul><li>p=1, q=1 with a constant</li><li>p=2, q=1 with a constant</li><li>p=2, q=1 with a trend</li></ul><p>We can mechanically select the first combination that returns the lowest AIC value, but we will also test the following two and see if the accuracy of our predictions decreases or improves.</p><p>After running all the three options, we end up selecting the third one as the one with the highest accuracy. We also run the Durbin-Watson test and plot the predictions against actual data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*cUvllEowk9juJ4zK8EFE7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*WUqDONdLh6HPY_bAx4u2bA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*2XRq9OL5qrdQzUGQJ12yAw.png" /></figure><p>Our VARMA model seems to have further improved the prediction accuracy compared to our previous models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*b5mJycZyQGQxN_TcV1wGZA.png" /></figure><p>Now, let’s make some actual forecasts!</p><h3><strong>Forecasting four quarters ahead</strong></h3><p>The difference between making predictions and making forecasts is that predictions are comparable against an hold-out set, as was the case for our test set. On the other hand, when forecasting we cannot verify the performance of our results, since we do not have any actual data for comparison yet.</p><p>For this exercise, we define our forecasting window from the fourth quarter of 2021 to the third quarter of 2022 (please, note that at the moment we do not have data for rgdp and gdp_defl since they are released the month following the end of each specific quarter).</p><p>We will fit our models again, but this time on the whole range of observations available (as you may recall, from the first quarter of 1994 up to the third quarter of 2021). If we train them again on the whole data set, we may get different values for our parameters, since we would include a period with severe variance in our variables. Nevertheless, we decide to stick to our pre-selected parameters for each model, being aware that results may underestimate the true uncertainty due to the Covid-19 pandemic. This way we should be more parsimonious and, hopefully, avoid overfitting: we should always remember that models are just a simplistic representation of the reality and that we will get “perfect” forecasts only by chance.</p><p>As usual, we plot the output of our forecasts, but this time we cannot assess the accuracy, since we do not have the actual data yet to be released.</p><h3><em>VAR forecasts:</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*4ceDbiebCCSO3oTWbAEXfA.png" /></figure><h3>VECM forecasts:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*5tQxfpyTcemMq2YxQzHdCw.png" /></figure><h3>VARMA forecasts:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*rIW8TwEspnNBaBaI9ip-yQ.png" /></figure><p>As expected, we can see that each model resulted in a different forecast for each variable. Some variables are forecasted with a similar path among our models, while others differ completely. Also, take into consideration that, despite having already the actual data for monthly and daily variables like new_ord and oil, in our exercise we used an average aggregation of them in order to align these series to our variables of interest (i.e., rgdp and gdp_defl) that are released on a quarterly basis. Therefore, it would be impractical to assess the results obtained for these daily and monthly variables with already-released actual data. We will focus our analysis. For all these reasons, we will focus our attention only on the forecasts of rgdp and gdp_defl, which, as stated in the first section of this article, are the variables we are interested in.</p><h3>Comparing the results: rgdp</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*fWXmRBRFu_Sx1At4E1UCIg.png" /></figure><h3>Comparing the results: gdp_defl</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FRt8McYpxfwRmRep1iI9KA.png" /></figure><h3>Key takeaways</h3><p>We have trained three multi-variate models and then made out-of-sample predictions to assess their ability to predict future values of the selected variables. Then we have made an attempt at using those models to make actual forecasts with a four-quarter time horizon. We have deliberately avoided the inclusion of observations for 2020 and 2021 to train our models (as we do think that these periods include the effects of a temporary shock to the macroeconomic environment), knowingly running the risk of underestimating uncertainty when producing forecasts. We also know that such models are better at estimating shorter time horizons, so our forecasts should probably be more accurate in earlier periods. When looking at the comparison of our models, we note that while for GDP deflator there is a general agreement among the models, for Real GDP levels the VECM and VARMA are less pessimistic than the simple VAR (at least for the first quarter forecasted — Q4&#39;21). Although we learned that VARMA and VECM returned better results in our out-of-sample prediction exercise, we should be careful in discarding any result <em>a priori</em>. Being well informed about the latest developments and aware of economists’ expectations with regard to these variables can be a form of “validation” when judging the outputs we obtained. For example, we know that currently inflation is running hot in the US and it’s reasonable to expect that it continues on this way. Nevertheless, an informed market participant knows that the FED is considering hawkish measures to tame price increases. Furthermore, even if the Omicron variant has impacted considerably the growth in the last quarter of 2021, we may not exclude a positive growth during this same period, as Christmas is usually a booster for end-of-year growth. Finally, if we want to further improve our models, we may consider re-training them with the addition of a dummy variable that activates from Q1–2020, i.e. when Covid-19 hit our economy and our lives.</p><p>You can find the whole python notebook following this link: <a href="https://github.com/babyloncapital/python_projects/blob/main/US_macroec._forecasting.ipynb">https://github.com/babyloncapital/python_projects/blob/main/US_macroec._forecasting.ipynb</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afe13172ac40" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>