#### Abstract

As the most important component of the capital market, the stock market has always been regarded as the “barometer” of the macroeconomy. However, many researchers have found that the stock market and macroeconomy are operating separately. This paper uses the dynamic Bayesian network method to study the dynamic relationship between the Chinese macroeconomic system and the stock market. The study found that the correlation between the macroeconomic system and the stock market is not consistent in different time periods. For most of the time, the stock system and the macroeconomic system are relatively independent. However, several macroeconomic factors such as Purchase Management Index could affect the stock market through some industries. A conclusion is drawn that the “barometer” function of the stock market is weak and easy to be damaged by factors such as the irrational sentiment of investors.

#### 1. Introduction

Researches on the causal relationships between the macroeconomy and the stock market have been taken by many researchers since Schumpeter [1] proposed the role of the financial market in improving productivity and economic growth. The financial market has played an increasingly important role in risk management and resource allocation for the entire economic system. The Chinese stock market was established in the 1990s. With the development of China’s reform and opening-up process, the size of the stock market is also expanding [2]. As of November 5, 2020, the market value of listed companies on the Shanghai and Shenzhen exchanges has exceeded 76 trillion yuan, equivalent to 77.2% of the gross domestic product in 2019. The stock market has increasingly become an important platform for the market-oriented allocation of China’s economic resources, broadening external financing channels for enterprises. However, looking at China’s economic development process, it can be found that its long-term stable growth trend and the stock market’s fluctuation trend show huge inconsistency. For example, the SSEC index dropped more than 4000 points during 2007-10 to 2008-10, while the growth rate of China’s GDP remained around 9 percent at the same time. As a complex system, the stock market is affected by many factors, including international ones. Some previous studies believed that the development of the macroeconomy dominates the degree of volatility of the stock market, and the stock market can be used as a “barometer” of the national economy to predict the future trend of the macroeconomy.

There have been many studies on stock market volatility and macroeconomics in history. In previous studies, the most frequently used models are econometric models, such as VAR (vector autoregressive model) [3]. However, these models are mainly adopted by researchers to inspect linear relationship via a small cluster of variables. Due to the limitations and the data dependence of the econometric model, the indicators of the macroeconomic system are often selected based on the researcher’s experience and cannot fully reflect the status of the entire macroeconomic system [4, 5].

Therefore, the motivation of this paper is to capture the dynamic changes of the relationships between the Chinese stock market and the macroeconomy. The Bayesian network, as a qualitative modeling method based on probability theory, uses graphs to express the dependence relationship between variables [6]. It could finely module a complex system such as the stock market and economic system. This paper explores the different stages of the Chinese stock market and the macroeconomic system by constructing a dynamic Bayesian network model of macroeconomic variables and the stock market. With the nodes of the network, structural changes are used to analyze if the Chinese stock market can serve as a “barometer” of the national economy. We contribute to the existing literature in two ways. First, we adopt the dynamic Bayesian network method to capture the dynamic relationship between the stock market and macroeconomic indicators, including monetary index and economy index. Second, we focus on how macroeconomic indicators respond to the stock indices from different sectors and the bridge index between these two systems.

The structure of this paper is as follows. Related literature is reviewed in Section 2. Section 3 gives a brief introduction to the Bayesian network methods and the dataset used. Section 4 summarizes the empirical results and analysis. The conclusions and some discussions are given in Section 5.

#### 2. Related Works

In the history of economic research, researchers have proposed many theories for investigating the relationship between the stock market and macroeconomy. The Arbitrage Pricing Theory (APT) uses multiple risk factors to explain asset returns, which include macroeconomic factors [7]. The APT suggests that systemic risk factors can be affected by certain macroeconomic factors and influence stock price ultimately. For instance, macroeconomic fundamentals will influence an enterprise’s stock return through the change of economic activities, the interest rate, and public expenses. On the other hand, the fluctuation of stock prices can affect macroeconomic factors. The manufactories and consumers may enlarge their spending or investment due to the exuberance of the stock prices, thus promoting macroeconomic growth. Another theory to explain the nexus between the stock market and macroeconomy is the Present Value Model (PVM) [8]. The PVM suggests that the stock price is decided by the cash flows and discount rate in the future. As long as the macroeconomic factor can affect these two determinants, it will influence the stock price. However, the empirical studies have shown that the stock market cannot reflect the information when the stock is speculative. The irrational trading will aggravate the degree of market deviation and lead to the deviation from macroeconomy [9, 10]. Behavioral finance theory assumes that investors will be affected by many factors like overconfidence and herd instinct, which can explain the deviation between the macroeconomy and the stock market [11].

There have been ample empirical researches examining the relationship between the stock market and macroeconomy [12]. Some of the researchers found that the relationship between the stock market and macroeconomy is significant, while some did not find a causal relationship between them. Hamilton and Lin found that the volatility of the US stock market is preceded by the economic cycle [13], which can be used to predict fundamental economic activities and the turning point of the economic cycle. The macroeconomic cycle during the economic depression has a greater impact on the stock market volatility. Chauvet uses a nonlinear dynamic monthly indicator to explore the dynamic relationship between stock market fluctuations and business cycles [14]. The results show that the stock market is a leading indicator of the business cycle and can be used to predict the turning point of the business cycle. Gallegati investigated the relationship between stock market returns and economic activity based on wavelet analysis for the US over the period 1961-1–2006-10 [15]. The results show that stock market returns tend to lead an aggregate economic activity at low frequencies based on the maximum overlap discrete wavelet transform (MODWT). Mukherjee and Naka used the VECM model to study the relationship between the Japanese stock market and six macroeconomic variables [4] and found that there is a long-term cointegration relationship between stock prices and macroeconomic variables in different periods. Domian and Louton constructed a model of the asymmetric relationship between CRSP stock index returns and the US unemployment rate [5]. The research results show that when stock returns are negative, the unemployment rate rises sharply, and when stock returns become positive, the unemployment rate gradually decreases. Aylward and Glen studied the relationship between stock prices and macroeconomic variables in 23 countries [16], and the results showed that stock market prices have the ability to predict future economic growth, income, consumption, and investment and that changes in stock prices have led to the change of GDP of most countries. Girardin and Joyeux tried to account for the effects of macrofundamentals on the long-run volatility of the Chinese stock market [17]. They found that macroeconomic fundamentals and their volatility played an increasing role in the A-share market after 2001, when China entered the WTO, using the GARCH-MIDAS approach. Pan et al. developed a new GARCH-Jump-MIDAS model to capture the effect of macroeconomic variables and jump dynamics on the stock volatility, which helped to improve the portfolio performance [18]. However, some researchers have come to different conclusions. Binswanger used the sample rolling regression method to find that there is no significant relationship between stock returns and real economic variables [19]. Quadir studied the impact of national treasury bond interest rates and industrial production volume on stock returns [20].

Bayesian network was first introduced as a tool to deal with multivariate probability models, and inferences can be made based on these models [6]. Kita et al. use dynamic Bayesian networks to establish a macroeconomic system model and theoretically analyze the correctness and feasibility of the method [21]. Friedman and Koller constructed a credit risk measurement model based on the Bayesian method [22]. Based on the behavioral factors of stock price fluctuations and the theory of stock price mean regression, a dynamic Bayesian network model describing stock price fluctuations is constructed [23]. Zhang et al. build a monetary network based on the Bayesian network, K2, and MCMC to find the main factors that influence monetary structure [24]. Khorram et al. constructed Bayesian networks for 100 Malaysian stock securities (FBM100) to model the relationships between stocks [25]. A continuous-time Bayesian network classifier (CTBNC) was developed and used to predict the foreign exchange rates by Villa and Stella [26]. Wang et al. used different levels of data to construct a Bayesian network of macroeconomic level, company level, and stock market returns [27]. In [28], Wang et al. used the stock market and macroeconomic indicators of China and the United States to construct a dynamic Bayesian network and made a comparative analysis of the differences between the two countries. Hidden Markov model (HMM) is a special dynamic Bayesian network. Hassan and Nath proposed a stock price prediction method based on the continuous HMM by selecting a set of four-dimensional data sets, looking for patterns similar to the current data patterns in history to predict stock prices [29]. Thomas et al. used HMM to link the bond term structure with credit risk and used HMM to describe the dependence of the bond credit rating changes and interest rate changes on two random processes [30]. In [31], Aragon used the Bayesian networks to investigate the probability of prevalence of financial stability of households in Mexico. Chai et al. quantified the causality between the water-energy-food-economy-society-environment nexus in China [32]. From the above researches, we find that the Bayesian network can be adopted to investigate the causality path between factors, and it could be useful in the area of economic research.

This paper constructs a dynamic Bayesian network based on the stock market index and macroeconomy factors. On this basis, we use the Bayesian factor graph to track the dynamic relationship between them. The innovation of this research lies in the use of macroeconomy and stock market factors to build the Bayesian network. The research results are conducive to in-depth understanding and identification of the possible macroeconomy factors that influenced the stock market.

#### 3. Methods and Datasets

##### 3.1. Bayesian Network

Bayesian networks are a class of graphical models. The nodes in the graph represent random variables , and the edges represent probabilistic dependencies between variables [33, 34].

A Bayesian network’s graphical structure is a directed acyclic graph (DAG), , where is the node set and is the edge set. Each node corresponds to a random variable . In this work, will be one of the selected macroeconomic and stock market factors. The DAG defines factorization of the global probability distribution of into a set of local probability distributions for each variable. The Markov property of Bayesian networks gives the form of factorization [34], stating that every variable depends only on its parents . The parents of are vertices pointing directly to via a single edge.

Based on the d-separation (direction-dependent separation) [35], the correspondence between conditional independence and graphical separation has been extended to an arbitrary triplet of disjoint subsets of by Pearl [33, 36]. Therefore, the task of fitting a Bayesian network can be performed in two different steps: first, try to learn the graphical structure of the Bayesian network and then estimate the parameters of the local distribution functions conditional on the structure learned in the first step.

Although there are many possible choices for both the global and the local distribution functions, we choose multivariate normal distribution considering the continuity of the macroeconomic indicators. Since there are two types of Bayesian networks based on the difference of event equivalence, the Bayesian network in this paper specifically refers to the Gaussian belief network [37].

##### 3.2. Structure Learning Algorithms

In this paper, we adopt a score-based structure learning algorithm, Hill-Climbing [38], a type of greedy search algorithm. Each candidate network is assigned a network score reflecting its goodness of fit, which the heuristic algorithm then attempts to maximize. The Hill-Climbing algorithm is shown in Table 1 [35].

A commonly used network score is the Bayesian Gaussian equivalent (BGe) score, the Wishart posterior density of the network associated with a uniform prior over both spaces of the network structure and of the parameters of the local distributions [35, 37].

##### 3.3. BGe Score

Throughout this discussion, we use to denote the joint probability density function (pdf) over of background knowledge . The background knowledge can be a priori hypotheses that we found in earlier researches. Then, equation (1) can be rewritten as

A Gaussian belief network is a pair , where is a belief-network structure that encodes the assertions of conditional independence in , and is a set of pdfs corresponding to that structure. We suppose that the joint probability density function for is a multivariate normal distribution and the local distributions are univariate normal random variables linked by linear constraints. As for the factors we adopted in this paper, we made a normal test for the individual factors to guarantee the assumptions. In this case, the conditional distribution can be written aswhere is the unconditional mean of , is the conditional variance of given values for , and is a linear coefficient reflecting the strength of the relationship between and [37, 39].

Given a set of cases , a Bayesian measure of the goodness of a network structure is its posterior probability:where is a normalization constant. Since there are too many network structures to sum over even for a small scale of , we consider and use as the score [37].

After taking several assumptions and derivations, which was first described by Geiger and Heckerman in [37], the BGe score can be written aswhere is the database restricted to the variables in . is an event that corresponds to structure (“e” stands for the event). holds true if the database is a random sample from a minimal belief network with structure . is a complete Gaussian belief network with no missing edges.

##### 3.4. Incorporating Dynamics in Bayesian Network

There are some ways to incorporate dynamics into the Bayesian network. Inspired by the “sliding window algorithm” introduced in Wang et al.’s article in [28], dynamics can be incorporated into the model structure of the Bayesian network.

Suppose that we want to model the dynamics of factors for a time scale of with an observed database over the same time period: . For each time in the scale , we construct one Bayesian network based on the database . For a discrete time of which and , we will get a time series of Bayesian networks: , where . will be termed dynamical Bayesian networks that incorporate dynamics using “sliding window algorithm.” In order to ensure that the network structure can not only reflect the changes in relationships between variables but also eliminate the edges with less significant or less weight, we use the method of automatically selecting the optimal Markov blanket to select the appropriate threshold and only show the edges with intensity greater than the threshold in the Bayesian network diagram.

##### 3.5. Economic and Stock Market Factors

This paper establishes a dynamical Bayesian network model utilizing the monthly data of some macroeconomic indexes and return rates of industrial stock indexes from the Wind database. In order to make the selected factors have qualified data during the time interval, we selected January 2007 as the beginning and July 2020 as the endpoint. This period of time included periods of severe major events in the stock market such as the 2008 global financial crisis, 2015 China’s stock market turmoil, and the reform of China’s stock market. There are enormous factors about the macroeconomy. And dealing with a huge scale of variables is an advantage of the Bayesian network. The details of these macroeconomic factors are shown in Table 2.

The rapid growth rate of IAV usually indicates that the economy is increasing rapidly. This factor shows that the companies in the society are in good operating condition, which may give people a good expectation of return of stocks. As for FAI, it is a comprehensive factor that reflects the relationship between the scale, speed, and proportion of investment in fixed assets. And the reason for choosing CPI and PPI is that some former researchers found that inflation has a huge influence on the stock market. EV and RSCG are widely used factors for assessing macroeconomic conditions. SF refers to the volume of funds provided by China’s domestic financial system to the private sector of the real economy within a given timeframe. M2, ER, and IR are indicators to measure the money supply and the condition of the money market.

As for the stock market, different from former studies, we use the index of different industries. And the stock market factors are shown in Table 3.

We choose six different industries, and for each industry, we use the return rate of the industrial stock index in the Wind database. In order to test the relationship between these industries and the Shanghai Composite Index, we add SH. All return rates have been converted into exponential logarithmic return rates.

All of these data come from the Wind database except for the interest rate, which is from the official website of Shibor.

#### 4. Computational Experiments and Results

##### 4.1. Computational Experiments

We downloaded the 12 macroeconomic indicators and 7 stock market indicators introduced in the former sector through the Wind database for a range of 163 months of data from January 2007 to July 2020. Since we will use Gaussian BNs for the analysis, all the data are the logarithmic rate of return. Depending on the interval to be analyzed, the set of cases will be different. For example, suppose that we want to learn the structure of BN in a time window [2007-01, 2007-12]; the set of cases will contain the data during the time window. According to the HC algorithm, we will choose a random network structure for the nodes . For the convenience of writing, we take the V structure as the beginning network structure. The set of the observed database is . Then, we can calculate the precision matrix . From [39], we know that is Wishart distribution, and we can get the precision matrix of . Since we have 12-month data in , we can get recursively. Then, we will obtainwhere . Through equation (5), we can obtain the final density.

So far, we have calculated the network score of the beginning structure. According to the HC algorithm, we will repeat step 4 in Table 1 by adding a new edge between the nodes, deleting an existing edge, or reversing the direction of an existing edge to obtain the structure which has the highest score. It must be noted that the computational complexity increases exponentially as the number of nodes increases. In order to be able to complete the calculation in a limited time, we adopted a heuristic algorithm which can be referred to [33]. Since the network is generated from empty, we decided to learn a set of networks and then average them to get a robust structure. In the rest of this paper, all of the Bayesian networks are averaged networks with a threshold to cut off the weak edges. Since the calculation process has involved both directions of an edge, the final result gives the stronger direction of each edge.

##### 4.2. Full Sample Interval Analysis

To start, we use the macroeconomic and stock market factors to build our model. In order to reduce the interference of expert knowledge on structure learning, we generated the Bayesian networks from a uniform distribution over the space of connected graphs. A Bayesian network constructed from the entire data [2007-01, 2020-07] is shown in Figure 1. The edges with a posterior probability greater than threshold 0.85 are presented in Figure 1. The stock market variables and macroeconomic variables are formed in two separate clusters, which conveys such an implication: the stock market and macroeconomy in China operate independently. In general, the “barometer” effect of China’s stock market on macroeconomic performance is missing. From the long-term performance of the real macroeconomy, the growth range and trend of China’s stock market are not consistent with the macroeconomic output; from the short-term perspective, the trend of stock market change even deviates from the macroeconomic situation, a phenomenon commonly attributed to the countercyclical adjustment of monetary policy. However, from the results of this paper, the impact of monetary policy indicator M2 on the stock market is not significant for most of the time, and there is no direct link to the stock market except in July 2010. In 2011, after taking office in Securities Regulatory Commission, Shuqing Guo began to rectify the chaotic and disordered operation mechanism of China’s stock market: the implementation of delisting system and mandatory dividend distribution system, the introduction of long-term institutional investors, the crackdown on insider trading, the relaxation of trading control, and the acceleration of the improvement of a series of institutional change environments such as mergers and acquisitions and tax relief measures. The links between the stock market and the macroeconomy were then gradually established more often, as can be seen from the empirical part of our sliding window.

There are two commonly accepted factors that can explain the irrelevance of China’s stock market to the overall macroeconomic sample range. First of all, it is the proportion of investors who conduct irrational trading. Retail investors occupy the mainstream in the Chinese stock market. According to *the Statistical Yearbook of Shanghai Stock Exchange*, the number of retail investors in China reached 80% from 2008 to 2016. Their trading behavior does not respond to marginal changes in economic information and overreacts to changes in stock prices. In addition, China’s economic information disclosure is incomplete, which also leads to the failure of the efficient market hypothesis in China. In addition, the trading system of China’s stock market also has big defects: asymmetric margin trading (even lack of margin trading channels for most stocks), lack of market makers, and the *T* + 1 trading system have greatly reduced the liquidity of the secondary market, making the cost of stock prices rapidly reflecting macroeconomic information rise. Another factor is that the size of the stock market is relatively small compared with the macroeconomic variables, and a change in a whole does not necessarily have a significant influence on parts of it. From the aspect of financing scale, nearly 80% of financing in China is provided by credit. From the aspect of market scale, the market value of financial products such as commodities, bonds, and precious metals is comparable to the stock market, and the real estate market occupies a large proportion of financial products for a considerable part of time [40]. Even though there is a transmission relationship between the macroeconomy and the stock market in theory, because the marginal changes in macroeconomy are generally changes in whole, it does not necessarily lead to the change of the stock market, which is only a part of the whole. By contrast, the structural change—irrational trading, leverage status of financial institutions, shadow banking, and so on—could affect the stock market more significantly [41].

Taking the longest conduction path within the macroeconomic system as an example, FAI-RSCG-M2-EV-IAV-KI-PMI-IR-ER, the fixed asset investment is located at the initial node in the whole network. The currency variables such as exchange rate and interest rate are located at the tail of the network. The export, social financing, industrial added value, CPI, and other factors characterizing the national macroeconomic and inflation play a conduction role. As an important part of the troika of China’s economy, fixed asset investment instruments have a significant impact on the fundamentals of macroeconomic. The internal transmission path of the stock market is simpler; the hierarchical structure of the yield among the various industries is shorter than that of the macroeconomic system. As the initial point of the network driving the whole stock market, the Shanghai Composite Index and the financial industry yield index have a large impact on the whole system.

Figure 1 is a general result of the full sample interval. The green factors are selected macroeconomic index as we introduced in the former part; the yellow factors are stock market factors. As shown in the picture, these two systems are separate from the full sample interval. In order to detect whether this result is stable in each time period or not, we adopt the “sliding window” method trying to capture the dynamical change of the topological structure of the system.

##### 4.3. Sliding Window Analysis

As we mentioned in Section 3.5, we averaged the networks learned in the structure learning step to produce a more robust model. The averaged network was learned by a set time, 2000 (compared to the default number 200). The time periods for these factors are from : 2007-01 to : 2020-07. Regarding the setting of the sliding window, if the interval is too short, it will be difficult to form a regularity, and if it is too long, it will be unable to capture the dynamic change. We take the first 12 months [, ] (: 2008-01) as the out-of-sample period and [, ] as the in-sample period. On this basis, we slide forward one month at a time, which means that the rolling step is set as 1 month. For each month *t* in [, ], we use the data during [t-12, t-1] to build the factor graph.

Our computational results show that the correlation between the stock market and macroeconomic factors does not appear at every time point. Considering the heuristic method of the Bayesian network structure learning algorithm used in this paper, the network structure shows the characteristics of probability distribution. We use the Shanghai Composite Index as a backdrop and use the red box to mark a period where there is a stable correlation (the length of correlated periods larger than 6 months) between the stock market and macroeconomy, as shown in Figure 2. The grey background line is the Shanghai Composite Index from 2008-01 to 2020-06, and the lines with other colors are the industry indices. The orange columns represent the linking edges between the macroeconomy and the stock market. Although the unrelated periods are more commonly seen, we still find several consecutive stages of linking periods. We define system relevance degree as , to measure the strength of the connection between the macroeconomy and the stock market at each time. The red box marks five stable correlated periods: period 1: [2010-03, 2010-08]; period 2: [2012-07, 2013-02]; period 3: [2013-12, 2014-06]; period 4: [2016-02, 2017-04]; period 5: [2017-06, 2018-01].

It can be found that these stable correlation stages between the macroeconomy and the stock market occurred in the stable period of the stock market. In [2008-01, 2008-10] and [2014-8, 2015-08], when the stock market in China was volatile, there was a lack of bridges between macroeconomy nodes and stock market nodes in the Bayesian network at this time. From 2007 to 2008, the global financial crisis broke out. The Chinese stock market experienced a transition from a bull market to a bear market. After the crisis was basically over in 2009, the Shanghai Composite Index rebounded significantly. From 2014 to 2015, the Chinese stock market also experienced a transition from a bull market to a bear market. These two large-scale market volatilities have similarities. First, the investor sentiment has undergone procyclical changes. The large rises and falls are often accompanied, respectively, by excessive optimism and excessive panic in investor sentiment and are not based on marginal economic information. Secondly, the leverage ratio has also undergone procyclical changes: during the bull market, investors increase leverage based on optimistic expectations, the incremental funds brought by high leverage further push up stock prices, and higher stock prices stimulate irrational investment and the accumulation of leverage further until the entire stock market maintains an extremely high price level with extremely high leverage. Once the price drops a little, it will trigger a chain collapse of leverage and the spread of panic. This suggests that, in a period of the unstable stock market, the macroeconomic fundamentals are no longer the dominators of the stock price. Besides, the proactive macroeconomic policy—a countercyclical monetary policy aimed at asset price stability—is basically ineffective at this stage: during the period from January to October 2007, the People’s Bank of China increased deposit and loan interest rates five times and deposit reserve ratio rates eight times. Of these 13 policy adjustments, the price fell only once on the first trading day after the increase was announced. The Shanghai Composite Index rose sharply from 2675 points to 6124 points. In the May-to-October fall in 2015, four RRR cuts were carried out to supply liquidity, but the final effect was not good. The Shanghai Composite Index fell from 5178 points to 3052 points. A principal element that dominates the change of the stock market is investor sentiment. Considering the large proportion of individual investors in China, “herd behavior” is more significant compared with developed countries, which increases the volatility of the stock price in the bear market.

During [2011-01, 2014-06] and [2016-03, 2017-12], the stock prices were generally stable with small fluctuations, and the correlation between the macroeconomic system and various industry indexes increased (4 stable correlation stages). There are fewer irrational trades during these periods. The stock market tends to be rational, and the stock price reflects the internal value of the enterprises more accurately. At this period, corporate profits are mainly affected by macroeconomics, and changes in macroeconomic factors can be reflected in the stock prices.

##### 4.4. The Influence Path in Stable Periods

In each stable period, the nodes which link the stock market factors and macroeconomy factors are not the same, so as the edge strength. Here, we take one network from each stable period to show the evolution of the correlation between these two systems. In Figure 3, all the directions of the linking edges are from macroeconomy to stock market except in Figure 3(c).

**(a)**

**(b)**

**(c)**

**(d)**

**(e)**

The detail of posterior probabilities and the arc strength of the linking edges in Figure 3 are listed in Table 4. From the probabilities in Table 4, we can see that they are all above 0.50 and some of them are above 0.60, which means that if we have the decided evidence for the father node, we can give inference to the child node.

From Figure 3, the third stable period [2013-12, 2014-06] has a different structure compared with the other four periods. The Bayesian network contains an arrow from the stock market indicator to the macroeconomic variables. In 2014, the United States reduced the scale of QE, and the Chinese government proposed “Likonomics” at the same time, which attempted to transform China’s economy from export-driven to consumption-driven. Figure 3(c) shows that the return rate of the industrial index has a certain impact on the total export value. In 2014, multiple reform policies had been promoted in the capital market in China, including an experiment on preferred shares in March, Shanghai-Hong Kong stock market trading interconnection mechanism in November. Especially, the Shanghai-Hong Kong Stock Connect provided foreign investors with access to buy stocks listed in mainland China. All these policies had laid a policy foundation for the prosperity of the stock market in late 2014.

As we focused on the monetary factors, “M2,” for example, we could find that the length of the path from monetary factor “M2” to stock market factors has been extended. In period 1 [2010-07], “M2” has a direct edge to node “WI_Fin,” which means the changing policy in the money supply has a sudden influence on the return rate of the financial sector. In period 5 [2017-07], there are no direct edges between “M2” and the stock market, which indicates that investors could not forecast a rise of the stock market simply depending on the monetary policies. In 2010, there were edges where M2 and RSCG point to the stock market. The characteristics of M2 growth after the global financial crisis are different from those before the financial crisis. Before the financial crisis, China had accumulated a large trade surplus. At this time, M2 was mainly derived from foreign exchange funds, which belonged to the passive release of currency. In 2010, the global financial crisis ended, but international trade suffered serious damage. At this time, China’s money supply is mainly used to stimulate economic recovery and cooperate with proactive fiscal and industrial policies. This is reflected in the increase in the proportion of securities and national debt held by the central bank’s balance sheet, which is relatively stable. In a rational market environment, loose monetary environment and active finance are finally reflected in the mechanism of the stock market through the boosting effect of consumption. In addition, compared with 2009, the growth rate of M2 in 2010 has experienced a marginal slowdown. To a certain extent, it also led to a correction in the stock market at a higher price. In the process of economic recovery, China’s industrial structure has been continuously optimized, and the proportion of the tertiary industry has continued to increase. At the stage of 2010 to 2012, RSCG acted on the financial sector, the consumer sector, and the Shanghai Stock Exchange Index, respectively.

Both of these five structures contain the bridge from node “PMI” in the macroeconomy system to the stock market, which implies that “PMI” may have a direct connection with the stock market. In order to explore the relationship in a bull market, we use the data from the start of a bull market in 2014 (2014-04) to the end of this period of time (2015-05). The Bayesian network from this period of time is shown in Figure 4(a).

**(a)**

**(b)**

We have noticed that the bridges between the macroeconomy to stock markets are nodes: Keqiang Index (KI), Purchasing Manager Index (PMI), and healthcare industry return rates.

PMI is a comprehensive economic indicator that summarizes China’s overall manufacturing situation, employment, and price performance. As we can see in Figure 4(a), PMI has been influenced directly by node CPI, an indicator that is closely related to the inflation rate. There are few related works on the relationship between PMI and the stock market in China. In [42], Liu et al. analyzed the relationship between PMI and the CSI 300 index using methods like ACCA. They found that the degree to which the stock market and the economy affect each other is related not only to the trend of the two but also to the magnitude of the change.

Another stable period, period 5 [2018-06, 2019-01], covers a bear market compared to the bull market we mentioned in the former part. Again we adopt the data from the beginning time of the bear market (2018-01) to the end (2018-12) to study the Bayesian network. The result is shown in Figure 4(b). The shortest path from PMI to the node of the stock market is 4 edges compared to 1 in Figure 4(a), which means that the correlation between PMI and the stock market is weaker compared to the bull market. Our result confirmed half of the conclusion made in [42], and we showed the relationship between PMI and the stock market, but we could not find any proof that the relationship is influenced by the magnitude of their change. During this period, a huge continuous exogenous uncertainty occurred. The global economic recovery has slowed marginally, and with the long-term implementation of economic recovery and quantitative easing, expectations about stagflation have risen. In addition, affected by the long-term loose currency, the gap between the rich and the poor in the developed economies represented by the United States expanded further. Against this background, populism is on the rise. Trump came to power in 2017, the United Kingdom initiated the Brexit procedure, Trump officially launched a trade war against China in 2018, and the process of world economic integration suffered a severe blow. During this period, the political uncertainty represented by Trump became the main factor affecting the stock market, which greatly increased the risk aversion of investors [43]. Even if the macroeconomic conditions improved, investors could not be sure of whether the improvement can be sustained. So they would not react to the marginal changes in the macroeconomy, and the macroeconomy and the stock market are also decoupled at this stage. Until the outbreak of the COVID-19 at the end of 2019 and the end of Trump’s term, worries about the uncertainty of international politics turned into worries about the uncertainty of the impact of COVID-19 [44, 45]. Exogenous uncertainty greatly cuts off the connection between the stock market and the macroeconomy by changing investors’ risk appetite and undermining investors’ stable expectations of economic information.

#### 5. Conclusions

Since Bayesian networks have not been widely used in the field of socioeconomic and financial analysis, there are many meaningful research topics to be taken further. Different from the traditional econometric methods, the Bayesian network is more intuitionistic to reveal the relationship between the variables in the economy and the stock market returns. On the basis of Chinese macroeconomic and stock market factors, this paper constructs a dynamic Bayesian network. Although, owing to the use of the “sliding window” method, the Bayesian network at a certain time presents the average structure in the past periods, it also reveals some useful messages about the macroeconomy system. The separate networks shown in Figure 1 declare that the attempt to use macroeconomy information to invest in the stock market will not bring the investors excess earnings.

The general Bayesian network indicates that the macroeconomy and the stock market operate independently. We believe that the main factors contributing to this phenomenon are the irrational trading and the relatively small scale of Chinese stock markets. According to the statistical yearbook from China Securities Depository and Clearing Corporation, the number of institutional investors accounts for only 0.238% of the total number of investors in 2019. Due to the large proportion of retail investors who usually conduct irrational trading behavior and to the small scale of China’s stock market, the impact of changes in macroeconomic fundamentals on the stock market is not significant in most periods. Additionally, we find five stable periods when there appeared direct linkage between the two systems. During these five periods, the volatility of the stock market was relatively small, and there was a less irrational investment. By studying some certain periods in the stable correlation phase, we find that PMI is a bridge between macroeconomic systems and stock markets for most of the time. In stable periods, PMI has an effect on the stock market, though this effect would change with the trend of the stock market. Besides, the linking path from M2 to the stock market has been expanding as the stock market developed in China. After 2018, huge exogenous shocks represented by political uncertainty and COVID-19 have increased investors’ risk aversion and worsened investors’ expectations for economic stability. As a result, the connection between the stock market and the macroeconomy could not be reflected in Bayesian networks.

#### Data Availability

The macroeconomic and stock market data used to support the findings of this study are included within the article.

#### Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

#### Acknowledgments

This research was funded by the University of Chinese Academy of Sciences and the Fundamental Research Funds for the Central Universities.