{'fraction_non_alphanumeric': 0.0368798625846216, 'fraction_numerical': 0.012225927048600586, 'mean_word_length': 4.61241848596541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Three-state herding model of the financial markets

We propose a Markov jump process with the three-state herding interaction. We see our approach as an agent-based model for the financial markets. Under certain assumptions this agent-based model can be related to the stochastic description exhibiting sophisticated statistical features. Along with power-law probability density function of the absolute returns we are able to reproduce the fractured power spectral density, which is observed in the high-frequency financial market data. Given example of consistent agent-based and stochastic modeling will provide background for the further developments in the research of complex social systems.


Introduction
Following the recent financial crisis a vast number of papers suggesting what could be improved in the financial policy making and Economics itself were published. In these papers agentbased modeling was seen as one of the key tools, which could improve the understanding of the financial markets as well as lead to the potential applications [1,2,3]. The idea is not so new, see a paper by Axelrod published back in the 1997, ref. [4], but it has been actively developed only in the last few years and is seen as one of the potential future prospects [5].
Currently there are many differing agent-based approaches in the modeling of the financial markets [6,7]. Reference [6] suggests that the ideal financial market model should be both realistic, namely include realistic individual trader behavior (with the best example being [8]), and tractable, namely have an analytical solution (ex. see an analytical solution of the Minority Game by Challet et al. [9]). This raises an interesting point -one has to build bridges between microscopic and macroscopic modeling, because doing so might lead to the ideal model. And this actually currently being done. In the recent paper Krause et al. [10] proposed a macroscopic stochastic model analogous to the Ising model interpretation for the financial markets, introduced in [11]. Another interesting approach was made by Feng et al. [12] who have used empirical observations and trader survey data to construct agent-based and stochastic models for the financial markets.
Our approach is based on the integration of two alternatives. One of them is a very simple, yet very relevant and highly applicable [13,14], Markov jump process based on the Kirman's agent-based herding model, introduced in [15]. And the other one is a very general stochastic model [16,17,18], which was built for the modeling of return and trading activity in the financial markets [19,20,21].
In the previous articles [22,23] we have used the Kirman's herding transition rates to derive a stochastic model for the absolute returns. In this approach we generalized and extended the work by Alfarano et al. [24,25]. By doing so we have established the relations between the Markov jump process and a very general class of stochastic equations, generating power-law statistics. Namely the time series obtained by solving eq. (1) posses power-law stationary probability density and power spectral density as follows: . (2) Stochastic differential equation (1) was previously derived from the point processes and its ability to reproduce power-law statistics was grounded in [16,17,18]. Many physical, physiological, and social systems are characterized by complex interactions among different components and power-law correlations in the output of these systems [26,27,28,29,30,31]. The applications of such stochastic model might include varying complex systems possessing power-law statistical features.
In this paper we considerably extend agent-based herding model introducing the Markov jumps between three-states available to agents (these states may be alternatively seen as agent groups). This approach lets us reproduce the fractured power spectral density, which is an important statistical feature of the high-frequency empirical financial market data [19,20,21,32]. First we introduce a possible relation between the Markov jump process and power-law stochastic processes, define herding interaction between three agent groups, introduce possible application for the financial markets. Next we give a stochastic treatment for the new approach and finally we discuss results in the context of microscopic and macroscopic modeling.

The Markov jump process in the background of the power-law stochastic processes
We choose the Markov jump process as a basic stochastic process, which enables the reproduction of the agent dynamics on the microscopic scale. This approach is already in use in restructuring Macroeconomics [13] and building microscopic models for the financial markets [14]. The method works as a more detailed reasoning for the microscopic behavior is irrelevant in determining the macroscopic description. Let us start from the model with N agents facing binary choice (0 or 1). The state variable X can be considered as a number of agents making choice 1. In this case the state space is then {0, 1, 2, ..., N }. One can interpret this model as a random walk, or a birth-death process, because X changes at most by ±1 in sufficiently small time interval ∆t. The transition probabilities from state X to the states X ± 1 may be specified by where µ 1 (X, N ) and µ 2 (X, N ) are positive transition rate functions. The transition probabilities (3) and (4) appear general enough to provide wide opportunities. The most simple one, when the functions µ 1,2 are constant, represents well-known birth-death or entry-exit process.
One can obtain the power-law statistics starting from the ref. [15], where Kirman has noticed that a very similar patterns are observed in a relatively different systems. Apparently statistically similar herding behavior is observed in a very different fields -economics, see, e. g., a paper by Becker [33], and entomology, the credits goes to Deneubourg and Pastels (see [34] for the most recent work). The entomological observations concluded that even if the ant colony has two identical food sources available ants still prefer to use only one of them at a given time. The other food source is not completely neglected as the ants after some time switch to it. The economists observe similar behavior -people tend to choose more popular product, than less popular, despite both being of a similar quality. Taking the discussed empirical observations into account Kirman has proposed to model the herding behavior as a Markovian chain with the following one step transition rates: here h parameter defines herding behavior, as a property of the agents describing the strength of imitation tendencies. While σ i parameters describe an asymmetric individual transitions of the agents made independently of the other agents' behavior. We will demonstrate that this simple model of herding interaction of agents can be considered as the background of pretty complex power-law behavior of financial variables. In order to reproduce the sophisticated power-law behavior of the absolute returns in the financial markets we generalized the herding model by assuming that the meeting rates of the agents are not constant, but depend on the system state, 1 τ (X,N ) , [22]. This strengthens a feedback of the macroscopic state on the agent transition rates as follows: Note that σ 1 is not divided by τ (X, N ). The reason behind this is a very simple one -we have previously assumed that a modeled market contains N − X rational and long term fundamentalist traders, whose individual behavior should not depend on the temporary fads and moods. It is possible to use other assumptions as the model is rather flexible. The further stochastic treatments of the model, mainly relying on the van Kampen birthdeath process formalism [35] and the Ito rules for variable substitution [36], leads to the following stochastic differential equation for new stochastic variable, y = X N −X , introduced as a measure of the absolute return [22]: here t s = ht. This stochastic differential equation in the limit of large y, y 1, can be considered to include only the highest powers of y. In such case, and by assuming that τ (y) = y −α , one obtains: which is identical to eq. (1). The direct comparison of eqs. (1) and (9) yields the relation between the models' parameters: The direct consequence of the comparison is the ability to control the power-law exponents, λ and β, of the y statistical features obtained from the agent-based model, eqs. (6) and (7), and its stochastic treatment, eq. (8). This can be used to reproduce 1/f β noise with 0.5 < β < 2 (see fig. 1). Yet the most important result is the agent-based reasoning being provided for a very general class of power-law stochastic processes, reproducible by stochastic differential equations (1), derived from the point processes [16,37,17,18].

Three-state model with herding interaction
In this section we extend the herding model by introducing the three-state agent dynamics. One can easily extend the model by assuming that the original Kirman's transition probabilities describe the transitions between each pair of the agent states in the system. Thus in threestate case with numbers of agents in each group X 1 , X 2 , X 3 we will have six one step transition probabilities of a general form given by: The above holds for non-equal i, j and k each taking a value from the set {1, 2, 3}. Note that herding behavior is assumed to be symmetrical, thus we have h ij = h ji . The schematic representation of the extended model is given in fig. 2. Note that due to conservation of total number of agents N , which is given by N = X 1 + X 2 + X 3 , one can fully describe the three-state system by the two dimensional state vector, X = {X 1 , X 2 }. We assume that N is large enough to secure the continuity of x i = X i /N and introduce the definition of the transition probability densities, π i,j (x 1 , x 2 ) : Here the indexes i, j and k stand for the corresponding change of the number of agents in the corresponding populations. The indexes i, j and k must take different values from the set {−1, 0, 1}. Consequently, i + j + k = 0 and vector {i, j, k} can be fully described by its two components {i, j}.
The transition probabilities imply the Master equation for the probability ω(x 1 , x 2 , t) to find the system in the state {x 1 , x 2 } at given time t: here i and j are two non-equal indexes, which take values from the set {−1, 0, 1}. In the above E i,j is the two variables one step operator, which is a convenient generalization of the one variable one step operator used by van Kampen in [35]. The form of the two variables one step operator is given by: here i = j ∈ {−1, 0, 1}, ∆x and ∆y are the smallest possible increments of x and y respectively. Note that the operator acts on all functions on its right side. We expand this one step operator, using the Tailor series in the limit of small increments, ∆x and ∆y, up to the second order terms. By recalling that in our case ∆x = ∆y = N −1 (it follows from the definition of the almost continuous x i ) we obtain a Fokker-Plank equation, where i and j belong to the set {1, 2}, and The obtained Fokker-Plank equation appears to be complex, but it can be simplified after some additional assumptions. The financial market interpretation based on the three-state model also enables us to make smooth transition to the system of stochastic differential, Langevin, equations.

Financial market model with the three agent groups
Let us start by assuming that the three-states available to the agents in the aforementioned setup correspond to the three types of traders: fundamentalists, chartists optimists and chartists pessimists. In the current agent-based modeling it is one of the most common choices [6,12].
Fundamentalists are the traders who have fundamental understanding of the true value of the traded stock. This understanding is quantified as the stocks fundamental price, P f (t). For a mathematical convenience and without loosing generality one can assume that the fundamental price does not vary with time. In other words, we are interested in the price fluctuations according to its fundamental value. Having this knowledge available to them the fundamentalists make rational long term expectations. Thus their excess demand, ED f (t), is given by [24]: where N f (t) is a number of the fundamentalists inside the market and P (t) is a current market price. The mathematical expression for the excess demand of the fundamentalist traders can be read as follows: if P f < P (t), the fundamentalist will sell the stock as he expects a decrease of price, while in the opposite case, P f > P (t), he will buy stock expecting price growth. This behavior is based on the assumption that P (t) should converge towards P f given enough time.
The other two types, pessimistic and optimistic chartists, are short term traders, who estimate the future price based on its recent movements. Namely these traders rely on the technical trading strategies and short term opinion fluctuations. As there is a wide selection of such strategies and opinions, one can simply generalize by assuming that some strategies and opinions at a given moment are optimistic, i.e. suggesting to buy, while the others are pessimistic, i.e. suggesting to sell. In such case the excess demand of the chartist traders, ED c (t), is given by: where r 0 is a relative impact factor of the chartist trader, N o and N p are the total numbers of optimists and pessimists respectively. In the previous approaches [22,24] chartist traders were considered to be a single group, opinion switching in which was assumed to be purely random, thus over-simplifying the endogenous mood dynamics. Price and later returns can be introduce into the model by applying the Walrasian scenario. As a fair price is assumed to reflect the current supply and demand, the Walrasian scenario in its contemporary form may be expressed as: here β is a speed of the price adjustment, N a total number of traders in the market, p(t) = ln P (t) P f and n i (t) = N i (t) N . By assuming that the number of traders in the market is large, N → ∞, one obtains: Consequently the expression of the return in the selected time window T is given by In the previous approaches [22,24] the expression for the returns, eq. (21), was simplified by assuming that the chartist traders change their opinion significantly faster than the fundamentalist traders. Further in this work we will use this assumption as well as regarding eq. (21) as a definition for the return. Note that in the above discussion we introduced some assumptions about the three agent states, which ought to be considered in the financial market scenario. We can further develop these ideas and simplify the Fokker-Planck equation obtained in the previous section for the general case of the three-state model. First of all let us link the states with actual agent types: Next let us point out the lack of qualitative difference between optimism and pessimism: Finally let us use the assumption that chartists change opinion significantly faster than fundamentalists: where H is a speed ratio.
Under the financial market scenario the terms of the Fokker-Plank equation derived in previous section, eq. (16), can now be re-expressed as: The system of stochastic differential equations for the three-state model It is useful to derive the stochastic differential equations analogous to the Fokker-Plank equation (15). The general form of a stochastic differential equation in the case of two variables can be written as After substituting the D 2 ij for the expressions from eqs. (25) we obtain a system of a three linearly independent equations for the four elements of S. It is convenient to additionally assume that S f p = S pf . Then by solving eqs. (27) we obtain all of the diffusion functions. Consequently we obtain the system of the stochastic differential equations: Interestingly enough similar equations are obtained for the evolutionary three strategy games in the series of papers by Traulsen et al. [39,40,41]. The above stochastic differential equations are inter-dependent, while it would be more convenient to have a system of independent stochastic differential equations. Taking into account the previous approaches [22,24] one can expect that the introduction of the mood, ξ(t) = no(t)−np(t) no(t)+np(t) , as a new variable instead of n p would solve this problem. This can be done either via Ito rules for variable substitution in Langevin equation [35] or via variable substitution in the Fokker-Plank equation [38].
At this point let us scale the time, t s = h 1 t, and appropriately redefine the model parameters: ε cf = σ cf /h 1 , ε f c = σ f c /h 1 , ε cc = σ cc /(Hh 1 ). Let us also recall our generalization of the herding model, eqs. (6) and (7), by introducing the additional variability of the event rate, τ (. . . ). The same assumptions can be used to introduce the variability into the three-state model. In such a case one can get: τ (n f , ξ) = 1 + Note that in previous approach [22] we have defined τ (. . . ) as an inverse function of y, namely This form was selected for the sake of simplicity and also considering the limit of large absolute returns, y 1. In the three agent group approach we choose to move further away from this simplification and introduce an inverse dependence on the logprice, p = 1−n f ξ , thus arriving at the eq. (32). Similar approach was used in [8], where the utility functions of the agents, and consequently their opinion switching, are dependent on the log-price.
In fig. 3 we show that this model possesses a fractured spectral density similar to the one obtained in the sophisticated stochastic models considered in [20,21]. The probability density function is a q-Gaussian like and has a power-law tail with the close-to-empirical exponent. Though the spectral density is fitted by the power-law functions with larger exponents than the empirical ones. The same behavior was also observed in the stochastic model for the absolute returns. In case of [20,21] the model's spectral density was reconciled with the empirical data by applying the additional q-Gaussian noise driven by the resulting time series. In a sense of the proposed stochastic model derived as endogenous fluctuations of three agent groups we can expect that the system's response to the exogenous fluctuations of information flow is defined by endogenous macroscopic state.

Conclusions
In this work we derived the system of stochastic equations (29) modulating dynamics of three agent groups with herding interaction. Proposed approach can be valuable in the modeling of the complex social systems with similar composition of the agents. We demonstrate how sophisticated statistical features of the absolute returns in financial markets can be reproduced by extending the herding interaction of the agents and introducing the third agent state. Fortunately, the model retains its macroscopic treatment by the stochastic differential equations (30) and (31). Faster transitions between optimism and pessimism introduce two time scales of the model reflected in the fractured power spectral density fig. 3 (b). This is in qualitative agreement with the high-frequency empirical data, which exhibits a similar behavior with lower exponents of the spectral density of the absolute returns [32,21]. Agent-based model in the present form considers only the endogenous fluctuations, while the exogenous fluctuations are related to the information flow and would be considered as additional noise. Earlier we proposed a double stochastic model, which demonstrates the influence of additional noise reducing exponents of power spectrum [20,21].