Dynamic modelling and optimal control of herd behaviour with time delay and media

ABSTRACT A dynamic model of herd behaviour with delay time and media is established and analysed to discover the latent mechanism that represents how capital flows in the stock market. We prove that solutions of the model are uniformly bounded, and the contagion threshold is obtained. The stability of positive equilibrium points of the model with zero and nonzero delay is discussed. An optimal control problem with media is formulated, and Pontryagin's maximum principle is applied to find an optimal strategy to control herding. Several numerical simulations show the effect of media and delay on herd behaviour. Finally, the practical meaning of the presented model is briefly discussed.


Introduction
Many academic research on traditional finance has been done under the assumption of complete markets. Every investor can receive all information about the markets. However, psychology and cognition play a major influence on transactions of investors and institutions. The vast majority of investors show irrational tendencies in the stock markets, and herding can easily occur given the lack of certainty regarding information and extreme market conditions. Herd behaviour not only caused serious losses to investors, but also brought huge shocks to the financial market. Research on herd behaviour has attracted many scholars in the field of behavioural finance.
Modern media and communication technology have greatly improved the speed and breadth of information transmission. Media coverage plays an increasingly significant role, particularly in the stock market, which is exceedingly sensitive to information (Frijns & Huynh, 2018;Meng et al., 2020). As the main source of information for investors, the media alleviates informational friction, thereby affecting the stock market (Fang & Peress, 2009;Shyu et al., 2020;Zhang et al., 2017). Based on a survey of the relation between media coverage and expected stock returns, Fang and Peress (2009) proposed that stocks with low exposure have higher yields than those with high exposure. Tetlock (2010) proposed that reporting related to corporate information CONTACT Ting Li l.ting@nxu.edu.cn helps reduce information friction in the market. Frijns and Huynh (2018) documented that analysts herding behaviour decreases as media coverage of stocks increases. Broadstock and Zhang (2019) claimed that stock prices are affected by social media. In this context, considering that the media is the primary source of stock information for individual investors, my paper suggests that investors behaviour can be controlled through the media to weaken the abnormal market volatility caused by irrational herding or behavioural contagion.
In view of its influence on the stock market, herding is an important topic in behavioural finance. This is the abandonment of one's judgment and the mimicking of the trading decisions of others, even if one has doubts about that mode of thinking (Spyrou, 2013;Youssef & Mokni, 2018). Two classical methods exist to study this problem: to establish behavioural financial models or analyse detailed transaction data to detect herding; or to investigate price vs. earnings through econometric models to reveal its existence (Fu & Wu, 2020).
The first kind of literature analyses herd behaviour from the perspective of specific investors. Scharfstein and Stein (1990) exploited a theoretical model of herd behaviour to analyse corporate investment, the stock market, and decision-making within firms. They held that fund managers herd because they are worried that their reputations will be lost if they run counter to the crowd. Lakonishok et al. (1992) proposed a pioneering LSV model in 1992 and utilized it to examine the herding of 769 tax-exempt funds. The results indicated weak herding of small-sized stocks, and little or no herding of large stocks. Grinblatt et al. (1995) then examined the herding of mutual funds, considering the sell-and buy-side on the basis of the LSV model. It is documented that mutual funds are inclined to purchase stocks with high past returns. Wermers (1999) found little herding by mutual funds in average stocks, while small-cap stocks and trading by growth-oriented mutual funds showed much higher levels of herding. Much recent work on herding has been based on the LSV model. Jiao and Ye (2014) researched whether mutual funds and hedge funds mimic each other by employing their model, suggesting that mutual funds mimic the trading behaviour of hedge funds, while the reverse does not hold. Based on trading data for institutional and individual investors in Taiwan's stock market, Hsieh (2013) stated that the herding of institutional investors tends to be driven by correlated enterprise information, while the herding of individual investors is more easily affected by behaviour and emotions. See Y. J. Li et al. (2020), Kremer and Nautz (2013), for further work on the LSV method. Christie and Huang (1995) took the lead in the research of the second kind of method. They used CSSD to capture herding behaviour in the U.S. stock market for the first time, arguing that stock returns will converge on the average level of the market if most investors follow the bellwether trading strategy and ignore their own information. This method failed to detect prominent herding during periods of market stress. Chang et al. (2000) followed up by introducing the cross-sectional absolute deviation (CSAD) to detect herding behaviour based on the theory of the capital asset pricing model (Black, 1972). They found that the herding effect was not notable in mature capital markets, such as the United States, Hong Kong, and Japan, whether the market was up or down. Herding was found to be significant in South Korea and Taiwan, which are still emerging capital markets. Fang et al. (2017) used regime-switching-based and static CSAD models to detect herding behaviour by U.S. equity fund managers in the global stock market. They found no evidence based on the static model, while the regime-switchingbased model captured a salient tendency to herd. Duygun et al. (2021) surveyed herding toward a market consensus in the main financial industries of the U.S. and Eurozone equity markets, and found it more conspicuous in turbulent periods (financial crisis, asymmetric volatility, credit deterioration, or illiquid funding).
Contagion phenomena in behavioural finance could be analysed by using epidemiological models (Kar et al., 2019;Kuniya & Nakata, 2012;Qi & Cui, 2013;Rajasekar & Pitchaimani, 2020), which was noted by some researchers. Based on the SIR epidemic model, Wang et al. (2019) established a network model considering investor behaviour and information disclosure strategy and investigated its network topology. They emphasized that through the adjustment of investor behaviour and information disclosure strategy, the prevention and control of counterparty credit risk contagion can be realized in a credit asset network. Fanelli and Maddalena (2020) built an SIR model with temporary immunity and nonlinear time-delay immunity to describe the dynamics of a credit risk transfer market. Based on the SEIR model, Zhao et al. (2020) constructed an evolutionary model of credit risk contagion among P2P lending platforms. Q. Zhou et al. (2019) combined behavioural finance and the SEIRS epidemic model with double delays to construct a dynamic flow model in China's stock market funds and discussed the model's stability. They declared that the size of delay could be controlled through policy, so as to achieve the purpose of macro-control regulation. However, the dynamic model to investigate the influence of media on herd behaviour still remains comparatively unexposed.
Media reporting on company information, industry fundamentals, and currency liquidity may have a positive impact on the control of herd behaviour. The theory related to the epidemic model is mature, and it is worth noting that herd behaviour, in essence, is also a type of contagion. Based on the above ideas, we study the impact of media on the herd behaviour and the role of media to control herd behaviour. First, a herd behaviour model with media and delay is used to mathematically describe the infection process. It is to understand the flow of money in the stock market from perspective of behavioural contagion. Second, we use optimal control theory to find an optimal strategy to reduce herd behaviour and the cost of media. The purpose is to influence the behaviour of investors through the media and weaken the herding behaviour, so as to reduce the economic losses caused by investors abandonment of one's judgment and the mimicking of the trading decisions of others. Institutional investors are more rational, and they prefer to invest in value stocks, but individual investors suffer frequent losses because they tend to sell into corrections. Therefore, the assumptions made in this paper are based on individual investors.
The rest of this paper is organized as follows. In Section 2, we construct dynamic model of herd behaviour with media and delay and give the economic meaning of the correlative parameters. Sections 3 and 4 discuss the stability of the positive equilibrium for a model with fixed media parameters when τ = 0 and τ > 0, respectively. Section 5 formulates an optimal control problem with media and solves for the optimal strategy. Section 6 presents the results of numerical simulation. A brief discussion and our conclusions are given in Section 7.

Model formulation
In this section, we formulate a herd behaviour model with media and time delay. Firstly, as herd behaviour impacts on the flow direction of capital in the stock market, this paper uses the flow of funds to depict the change process of investor behaviour. According to the status of capital at time t, we consider that the total capital size N(t) is divided into four subclasses: Money of retail investors keeping on the sidelines S(t). Money of retail investors in securities accounts A(t), bought shares must first pass through securities account. Money of retail investors in the stock market E(t). Money of retail investors temporarily out of the stock market R(t). The flow of capital is depicted in Figure 1.
Considering the economic significance of the model, we make the following assumptions: (1) A is the recruitment of capital, assuming newly inflowing capital is initially on the sidelines.
is the probability of an investor being affected by the media and α is a parameter related to the saturation factor. When an investor who has been sitting on the sidelines interacts with an active investor, like conversation, social media or news, the investor who has been sitting on the sidelines may become an active investor with probability β.
(3) Money of retail investors in securities accounts will enter the stock market for exchange with probability γ . (4) For convenience of calculation, we assume a constant risk-free interest rate at any time t, assuming that investors will lose money at a risk-free rate regardless of whether their money buys stocks.
is the effect of media on individual investors selling stocks. η is the probability that investors sell stocks. ε is related to the saturation factor. (6) Investors obtain money by selling stocks, this money flows out of the market after one day (Shanghai Stock Exchange and Shenzhen Stock Exchange T + 1 trading system). Meanwhile, most investors need a period of time after selling stocks to vacillate whether to continue buying stocks. In view of the above reasons, we introduce the delay term τ , and the time of the money that flows out of the stock market is at least t > τ. (7) It is assumed that investors purchase stocks from a securities account and they can be exchanged immediately. ν is the probability that an investor who has been sitting on the sidelines does not wish for investment due to same reason. (8) λ is the capital ratio that investors out of the stock market choose to continue to invest. μ and δ (δ > μ) are the average rate of returns and loss on equities, respectively.
Based on the above assumptions, a dynamic model of herd behaviour with delay time and media is presented by with initial conditions

Stability of positive equilibrium when τ = 0
We discuss the steady states of the positive equilibrium when τ is zero. We first must ascertain that the solution of system (1) is economically available for all t ∈ [0, +∞) .
Here, we assume that the media control parameter M is fixed. (1) with initial conditions (2) are uniformly bounded.

Lemma 3.1: The solutions S(t), A(t), E(t), R(t) of system
then dN(t) dt + N(t) A . Based on the theory of differential inequality by Birkoff and Rota (1982), we get Thus we conclude that solutions of system (1) with initial conditions (2) will be confined to the region The lemma is proved.
Before analysing stability, we define the contagion threshold of system (1) by the method of Driessche and Watmough (2002), as follows: . (3) This is important for our research because system (1) is economically meaningful if and only if R 0 > 1. Herd behaviour exists in the stock market. Next, we discuss the dynamic stability of the system. The equilibria points satisfy: Calculation shows that if R 0 > 1, system (1) has two equilibria: Let the positive root and the corresponding positive equilibria point be respectively. To examine the local asymptotic stability of Φ 1 when τ = 0, we propose Theorem 3.1.

Stability of positive equilibrium when τ > 0
We proved above that the positive equilibrium point Φ 1 is steady for τ = 0 when certain conditions are satisfied. We next investigate whether the system can be stable when τ > 0 by seeking a pair of complex conjugate eigenvalues. Near equilibrium Φ 1 , system (1) has a Jacobi matrix when τ > 0, where j 0 = e −ξτ ,j 33 = k (1+εME * 1 (t)) 2 . Then the characteristic equation is given bỹ Letξ = iω (i is imaginary) be the root of Equation (5).
Therefore, we can obtain the following Lemma 4.1. (8) has least one positive root if the coefficients of f (σ ) satisfy one of the conditions as follows:

Proof:
The proof is similar to X. L. Li and Wei (2005).
To determine whether system (1) undergoes a Hopf bifurcation at τ = τ 0 , one has to compute the sign of dτ .we differentiate Equation (5) with respect to τ .

Optimal control
We apply optimal control theory as a mathematical tool to solve complex economic intervention problems. From the form of contagion threshold, it is evident that media coverage could control herd behaviour. The objective of control in our model is to find the optimal strategy to reduce behaviour contagion and the cost of media. In our optimization problem, we suppose that the policies of securities regulators can positively guide investors to invest rationally, so control investors' herd behaviour by control function u(t), u(t) is the effect of policies on the media. The optimization problem will consist in minimizing the cost function: where t f is the period of control, the positive constants A 1 and A 2 are the average loss of hold stocks and market exit due to herd behaviour, respectively, and the costs corresponding to media control are denoted by Mu 2 (t). B is a positive weight parameter, 0 < B A . We do not consider the delay. Assumption α = ε, system (1) can be written as where We set R(t) and all variables are less than or equal to A .

Numerical simulation
The numerical simulation is an important step to verify whether the model of herd behaviour is reasonable in economics. It is necessary to estimate model parameters to verify theoretical results. The risk-free interest rate is that obtained when funds are invested in a specific riskfree investment project. In general, investors believe that long-term treasury bonds can approximate the risk-free rate in the Chinese stock market. Based on the previous work of Q. Zhou et al. (2019), we assume that the effective contagion rate of herd behaviour is β = 0.005 and the risk-free rate is = 5%. We perform some numerical simulations to verify the above theoretical results by the Runge-Kutta fourth-order method. The other simulation analysis parameters are shown in Table 1. We start with numerical simulations from initial conditions 24,43,17,16). Figure 2 shows that when something unexpected happens, the capital on the sidelines S(t) will decline sharply in a short period of time, and capital in securities accounts A(t) and flowing into the stock market E(t) have large volatility. A few investors take a profit and decrease shareholdings, which makes capital flow out of the stock market. With the slow repair of market emotion, capital flowing into the market gradually becomes stable. We notice that media information plays a crucial role in restraining herd behaviour. When media factor M = 0.2, S(t) will gradually decline within a short time. After reaching the lowest point, it will increase steadily, and finally reach a stable value. When media factor M 0.5, its sensitivity to system (1) is reduced significantly, perhaps because the influence of information on investors reaches a saturation state, and excessive information cannot help them make more rational decisions.
We must think about the delay phenomenon in China's securities market, such as the Shanghai Stock Exchange and Shenzhen Stock Exchange T + 1 trading system (bought or sold stocks will not be exchanged until the next trading day). In addition, after selling shares, investors will take some time to decide whether to continue to invest in stocks. These time delays may affect capital flow. The differences of solution curves of system (1) with τ = 0 and τ = 6 are illustrated in Figure 3. The presence of delay in the market will lengthen the time it takes for the system to reach stability and intensify the volatility of capital flow. It is noteworthy that the frequent fluctuation of capital flow will cause the fluctuation of stock prices in the real market. Therefore, the delay differential system can describe the real capital flow. Figure 4 shows that tendency of R 0 with M and τ , R 0 can be effectively reduced by means of media, so as to prevent the extend of herding behaviour. However, the effect of time delay on the R 0 is not significant.
Based on the results in Figure 2, we consider M = 0.6, the set of admissible controls of cost function (11) is given   by We performed simulations using the forward-backward fourth-order Runge-Kutta iterative method (Allali, 2021;Lenhart & Workman, 2007) (see Appendix 1) to research the role of media on herd behaviour. The weights were taken as A 1 = 2, A 2 = 3, and B = 14. Figure 5(a) shows the variation of capital on the sidelines when a control strategy is applied. Figure 5(b,c) show the variation of capital in securities accounts and the stock market, respectively. This illustrates that with media control, the funds of those investing in the stock market during the initial days were significantly reduced, while without media coverage, capital in the stock market rose rapidly in a short time until it reached a higher peak, and then it quickly fell back. We can conclude that giving practicable media information to investors can effectively reduce their behavioural contagion and control herd behaviour. The last result concerns capital that is temporarily out of the stock market during days of observation (see Figure 5(d)). The time variation of the optimal control is illustrated in Figure 6. Our numerical results are interpreted as a reference that the importance of media should be noted by regulators during the first days of the herd behaviour. As soon as media information is obtained by investors, control of herd behaviour is quickly achieved.

Discussion
This paper is a model constructed to study the effect of media on herd behaviour in the stock markets. Meanwhile, a control problem that the media used to control herd behaviour was proposed and investigated. We investigated a dynamic model with time delay and media to describe the herd behaviour in China's stock market. A crucial result, the contagion threshold R 0 of the system, was described. The model had real significance if and only if R 0 > 1, in which case the system has two equilibrium points, one a positive equilibrium Φ 1 . that is locally asymptotically stable when τ = 0. On the other hand, when τ > 0, we proved that delay τ 0 exists such  that the positive equilibrium point Φ 1 of the system is locally asymptotically stable if and only if τ ∈ (0, τ 0 ], and the system undergoes a Hopf bifurcation near the positive equilibrium point Φ 1 when τ = τ 0 . It is worth noting that the stock market fluctuates frequently, so the model with time delay and media is closer to reality. Based on numerical simulation, we found that the delay in the market will lengthen the time it takes for the system to reach stability.
In addition, we found that the media can effectively reduce herd behaviour. When the media parameter is smaller, capital on the sidelines, stock account funds, and stock market funds will be more stable. Based on the above results, to reduce the loss due to herd behaviour and the cost of media coverage for individual investors, we formulated an optimal control problem and the optimal control strategy is be given. Several numerical simulations were performed to study the impact of media control. Our results showed that to apply a suitable optimal control strategy in the preliminary stage can reduce herd behaviour and minimize the cost of media.
Adapting the dimensional-reduction modelling idea proposed in Zheng et al. (2021), Yu and Li (2020), Yu (2018) and considering that R(t) is controllable, it can be regarded as a given non-negative continuous function rather than an independent variable satisfying a dynamic equation, then model (1) becomes the following three dimensional system which gives us a new question for the future study. In addition, we note that the age and experience of investors also have a certain impact on herding behaviour. In the future, we will use the age-structured model to study it , Soufiane and Touaoula (2016), , Bentout et al. (2020), Djilali and Bentout (2020), Bentout (2020).