Memory and Asset Pricing Models with Heterogeneous Beliefs

The paper discusses the role of memory in asset pricing models with heterogeneous beliefs. In particular, we were interested in how memory in the fitness measure affects stability of evolutionary adaptive systems and survival of technical trading. In order to obtain an insight into this matter two cases were analyzed; a two-type case of fundamentalists versus contrarians and a three-type case of fundamentalists versus opposite biases. It has been established that increasing memory strength has a stabilizing effect on dynamics, though it is not able to eliminate speculative traders’ short-run profit seeking behaviour from the market. Furthermore, opposite biases do not seem to lead to chaotic dynamics, even when there are no costs for fundamentalists. Apparently some (strong) trend extrapolator beliefs are needed in order to trigger chaotic asset price fluctuations.


Introduction
Heterogeneous agent models are present in various fields of economic analysis, such as market maker models, exchange rate models, monetary policy models, overlapping generations models and models of socio-economic behaviour. Yet the field with the most systematic and perhaps most promising nonlinear dynamic approach seems to be asset price modelling. Contributions by Brock and Hommes (1998), LeBaron (2000), Hommes et al. (2002), Chiarella and He (2002), Chiarella et al. (2003), Gaunersdorfer et al. (2003), Brock et al. (2005), Hommes et al. (2005), and Hommes (2006) thoroughly demonstrate how a simple standard pricing model is able to lead to complex dynamics that makes it extremely hard to predict the evolution of prices in asset markets. The main framework of analysis of such asset pricing models constitutes a financial market application for the evolutionary selection of expectation rules, introduced by Brock and Hommes (1997a) and is called the adaptive belief system. As a model in which different agents have the ability to switch beliefs, the adaptive belief system in a standard discounted value asset pricing set-up is derived from mean-variance maximization and extended to the case of heterogeneous beliefs (Hommes, 2006, p. 47). It can be formulated in terms of deviations from a benchmark fundamental and therefore used in experimental and empirical testing of deviations from the rational expectations benchmark. Agents are boundedly rational, act independently of each other and select a forecasting or investment strategy based upon its recent relative performance. The key feature of such systems, which often incorporate active learning and adaptation, is endogenous heterogeneity (cf. LeBaron, 2002), which means that markets can move through periods that support a diverse population of beliefs, and others in which these beliefs and strategies might collapse down to a very small set.
The mixture of different trader types leads to diverse dynamics exhibiting some stylized, qualitative features observed in practice on financial markets (cf. Campbell et al., 1997;Johnson et al., 2003), e.g. persistence in asset prices, unpredictability of returns at daily horizon, mean reversion at long horizons, excess volatility, clustered volatility, and leptokurtosis of asset returns. An important finding so far was that irregular and chaotic behaviour is caused by rational choice of prediction strategies in the bounded-rationality framework, and that this also exhibits quantitative features of asset price fluctuations, observed in financial markets. Namely, due to differences in beliefs these models generate a high and persistent trading volume, which is in sharp contrast to no trade theorems in rational expectations models. Fractions of different trading strategies fluctuate over time and simple technical trading rules can survive evolutionary competition. On average, technical analysts may even earn profits comparable to the profits earned by fundamentalists or value traders.
While recent literature on asset price modelling focuses mainly on impacts of heterogeneity of beliefs in the standard adaptive belief system as set up by Brock and Hommes (1997a) on market dynamics and stability on one hand, and the possibility of the survival of such 'irrational' and speculative traders in the market on the other, several crucial issues regarding the foundations of asset price modelling and its underlying theoretical findings remain open and indeterminate. One of those issues is related to heterogeneity in investors' time horizon; both their planning and their evaluation perspective. Namely, it has been scarcely addressed so far how memory in the fitness measure, i.e. the share of past information that boundedly rational economic agents take into account as decision makers, affects stability of evolutionary adaptive systems and survival of technical trading. LeBaron (2002) was using simulated agent-based financial markets of individuals following relatively simple behavioural rules that are updated over time. Actually, time was an essential and critical feature of the model. It has been argued that someone believing that the world is stationary should use all available information in forming his or her beliefs, while if one views the world as constantly in a state of change, then it will be better to use time series reaching a shorter length into the past. The dilemma is thus seen as an evolutionary challenge where long-memory agents, using lots of past data, are pitted against shortmemory agents to see who takes over the market. Agents with a short-term perspective appear to both influence the market in terms of increasing volatility and create an evolutionary space where they are able to prosper. Changing the population to more longmemory types has led to a reliable convergence in strategies. Memory or perhaps the lack of it therefore appeared to be an important aspect of the market that is likely to keep it from converging and prevent the elimination of 'irrational', speculative strategies from the market. Honkapohja and Mitra (2003) provided basic analytical results for dynamics of adaptive learning when the learning rule had finite memory and the presence of random shocks precluded exact convergence to the rational expectations equilibrium. The authors focused on the case of learning a stochastic steady state. Even though their work is not done in the heterogeneous agent setting, the results they obtained are interesting for our analysis. Their fundamental outcome was that the expectational stability principle, which plays a central role in situations of complete learning, as discussed e.g. in Evans and Honkapohja (2001), retains its importance in the analysis of incomplete learning, though it takes a new form. In the models that were analyzed, expectational stability guaranteed stationary dynamics in the learning economy and unbiased forecasts. Chiarella et al. (2006) proposed a dynamic financial market model in which demand for traded assets had both a fundamentalist and a chartist component in the boundedly rational framework. The chartist demand was governed by the difference between current price and a (long-run) moving average. By examining the price dynamics of the moving average rule they found out that an increase of the window length of the moving average rule can destabilize an otherwise stable system, leading to more complicated, even chaotic behaviour. The analysis of the corresponding stochastic model was able to explain various market price phenomena, including temporary bubbles, sudden market crashes, price resistance and price switching between different levels.
The objective of this chapter is to lay the foundations for a competent and critical theoretical analysis setting the memory assumption in a simple, analytically tractable asset pricing model with heterogeneous beliefs. We shall thus analyze the effects of additional memory in the fitness measure on evolutionary adaptive systems and the nature of consequences for survival of technical trading. In order to examine our research hypothesis adequately, both analytical and numerical analysis will have to be employed and complemented. Therefore, we shall first expand the asset pricing model to include more memory, and then solve it both analytically and numerically. Two cases are going to be analyzed, hopefully sufficiently general to cover some main aspects of financial markets; (1) a two-type case of fundamentalists versus contrarians and (2) a three-type case of fundamentalists versus opposite biased beliefs. Complementing the stability analysis with local bifurcation theory (cf. Awrejcewicz, 1991;Palis and Takens, 1993;Kuznetsov, 1995;Awrejcewicz and Lamarque, 2003), we will also be able to analyze numerically the effects of adding different amounts of additional memory to fitness measure on stability of the standard asset pricing model and survival of technical trading. Thus the analysis of both local and global stability can be performed for different combinations of trader types in the market.

The heterogeneous agents model
The adaptive belief system employs a mechanism dealing with interaction between fractions of market traders of different types, and the distance between the fundamental and the actual price. Financial markets are thus viewed as an evolutionary system, where price fluctuations are driven by an evolutionary dynamics between different expectation schemes. Pioneering work in this field has been done by Brock and Hommes (1997a), who attempted to conciliate the two main perspectives concerning economic fluctuations, i.e. the new classical and the Keynesian view (cf. Hommes, 2006, pp. 1-5), and the underlying rules relating to the formation of expectations. In order to get some insight into possible ways of theoretical analysis to follow, we shall describe a simple, analytically tractable version of the asset pricing model as constructed by Brock and Hommes (1998). The model can be viewed as composed of two simultaneous parts; present value asset pricing and the evolutionary selection of strategies, resulting in equilibrium pricing equation and fractions of belief types equation. We shall also make an indication of where memory in the fitness measure (and in expectation rules) enters the model and how it might affect the analysis.

Present value asset pricing
The model incorporates one risky asset and one risk free asset. The latter is perfectly elastically supplied at given gross return R, where R = 1 + r. Investors of different types h have different beliefs about the conditional expectation and the conditional variance of modelling variables based on a publicly available information set consisting of past prices and dividends. The present value asset pricing part of the adaptive demand system is used to model each investor type as a myopic mean variance maximizer of expected wealth demand, Eh,tWt, for the risky asset: where pt is the price (ex dividend) at time t per share of risky asset, yt is an IID dividend process at time t of the risky asset, zh,t is number of shares purchased at date t by agent of type h, and In order to perform myopic mean variance maximization of expected wealth demand for risky asset of type h, we seek for zh,t that solves: and thus: , where the belief about expected value of wealth at time t + 1, conditional on all publicly available information at time t, for a trader of type h is , . All traders are assumed to be equally risk averse with a given risk aversion parameter a, which is constant over time 1 .
Solving this optimization problem produces quantities of shares purchased by agents of different types, which enables us to seek for the equilibrium between the constant supply of the risky asset per trader z s and the sum of demands: where the fraction of traders of type h out of altogether H types at time t is denoted by nh,t, where , 1 The price of the risky asset is determined by market clearing, which can be seen by rewriting expression (4) in the form: where 2 s a z  is the risk premium. The latter is an extra amount of money that traders get for holding the risky asset. Traders will only purchase the risky asset if its expected value is equal or higher than the expected value of the risk-free asset. Since the outcome of the risky asset is uncertain, a risk premium is associated with it.
In the simplest case of IID dividends with mean y and with traders having correct beliefs about dividends, i.e.
, the market price of the risky asset pt at time t is determined by: where a noise term t is included, which represents random fluctuations in the supply of risky shares. Considering a special case with a constant zero supply of outside shares, i.e. z s = 0, we obtain: If we instead consider for a moment the case of homogeneous beliefs with no noise and all traders being rational, the pricing equation simplifies to: In equilibrium the expectations of the price will be the same and equal to the fundamental price. The constant fundamental value of the price of the risky asset p* in the case of homogeneous beliefs is derived from the expression: By imposing a transversality condition on expression (7) with infinitely many solutions we exclude bubble solutions (cf. Cuthbertson, 1996) and expression (8) now has only one solution. We are thus able to derive the fundamental price as the discounted sum of expected future dividends: By simplification of the fundamental price equation for the case of the IID dividend process with constant conditional expectation we thus obtain the standard benchmark notion of the 'fundamental', i.e. * t y p r  , to be used in the model hereinafter.
Taking into account the appropriate form of heterogeneous beliefs of future prices, i.e. including some deterministic function fh,t, which can differ across trader types: we restrict beliefs about the next deviation of the actual from the fundamental price, xt, to deterministic functions of past deviations from the fundamental: where L is the number of lags of past information, taken into account. Since the deterministic function in the expectation rule depends on preceding price deviations, it can also be seen as including memory. However, due to rapidly increasing analytical complexity, viz. including more preceding price deviations rapidly increases the dimension of the system, this issue has so far mainly been neglected. In this chapter we are focusing on the memory in the fitness measure and will thus include only one lag in the memory in the expectation rule, i.e.
Taking into account that * t y p r  , the equilibrium pricing equation (5) can thus finally be rewritten in terms of deviations from the fundamental price, xt = pt -p*: The particular form of deterministic function in the forecasting or expectation rule is thus what determines different types of heterogeneous agents in an adaptive belief system. In general, we distinguish between two typical investor types; fundamentalists and 'noise traders' or technical analysts. Fundamentalists believe that the price of an asset is defined solely by its efficient market hypothesis fundamental value (Fama, 1991)

Evolutionary selection of strategies
In order to be able to understand the dynamics of fractions of different trader types, we consider the appropriate formulations of realized excess return Rt from expression (1) where Ch represents the costs traders have to pay to use strategy h. Albeit introducing additional analytical complexity, we usually take into account the costs for predictor of particular trader type, since more information-intense predictors are evidently more costly. It is of course convenient to rewrite profits of different types of traders in terms of deviations from the benchmark fundamental: The fitness function or performance measure of each trader type can now be defined in terms of its realized profits. In fact, it can be expressed as the weighted sum of realized profits, i.e. as the sum of current realized profits and a share of past fitness, which is in turn defined as past realized profits: where current realized profits are defined in the following final form: The fitness function can for Uh,0 = 0 also be rewritten in the following expanded form with exponentially declining weights: In case of the equilibrium pricing equation, herein formulated as the sum over trader types of products of a fraction of particular trader type and its deterministic function, the fitnesses enter the adaptive belief system before the equilibrium price is observed. This is suitable for analyzing the asset pricing model as an explicit nonlinear difference equation. Even though nonlinear asset pricing dynamics can be modelled either as a deterministic or a stochastic process, only the latter enables investigation of the effects of noise upon the asset pricing dynamics.
The share of past fitness in the performance measure is expressed by the parameter w; 0  w  1, called memory strength. When the value of this parameter is zero (w = 0), the fitness is given by most recent net realized profit. Due to analytical tractability this is at present, y for the most part, the case in the existing literature on asset pricing models with heterogeneous agents, though not in this chapter. The main contribution of this chapter is that it analyzes the case of nonzero memory in the fitness measure. When the memory strength parameter takes a positive value, some share of current realized profits in any given period is taken into account when calculating the performance measure in the next time period. If the value of memory strength parameter amounts to one then of course the entire accumulated wealth is taken into account.
The expression (14) for the fitness function is somewhat different that the one used in Brock and Hommes (1998), where the coefficient of the current realized profits was fixed to 1.
Namely, if we rewrite the memory strength parameter as to be a specific number of time periods, we obtain the following expression for the fitness function: which is equivalent to taking the last T observations into account with equal weight (as benchmark). When T approaches infinity, the memory parameter approaches 1 and the entire accumulated wealth is taken into account. We thus believe the expression (14) to be a more suitable formulation of the fitness measure than the one used in Brock and Hommes (1998), and in several other contributions.
Finally, we can express fractions of belief types, nh,t, which are updated in each period, as a discrete choice probability by a multinomial logit model: by using parameter , determining the intensity of choice. The latter measures how fast economic agents switch between different prediction strategies; if the value of intensity of choice is zero, then all trader types have equal weight and the mass of traders distributes itself evenly across the set of available strategies, while on the other hand the entire mass of traders tends to use the best predictor, i.e. the strategy with the highest fitness, when the intensity of choice approaches infinity (the neoclassical limit).
Trader fractions are therefore determined by fitness and intensity of choice. Rationality in the asset pricing model is evidently bounded, since fractions are ranked according to fitness, but not all agents choose the best predictor. To ensure that fractions of belief types depend only upon observable deviations from the fundamental at any given time period, fitness function in the fractions of belief types equation may only depend on past fitness and past return. This indeed ensures that past realized profits are observable quantities that can be used in predictor selection.
One might wonder whether the traders' myopic mean-variance maximization is a reasonable assumption, especially when we allow for traders with a longer memory span. This assumption is widely used in modelling in economics and finance, though it would certainly be interesting to let traders plan longer ahead, even with an infinite planning horizon, as in the Lucas (1978) asset pricing model. However, in this kind of model one usually assumes perfect rationality to keep the analysis tractable. So far very little work has been done on infinite horizon models with bounded rationality and heterogeneous beliefs. Furthermore, one can also discuss whether individuals are really able to plan over a long horizon, or whether they might use simple heuristics over a short horizon and occasionally adapt them. After all, memory in the fitness measure is not equivalent to the planning horizon, but rather an "evaluation horizon" used to decide whether or not to switch strategies. There is empirical and experimental evidence that humans give more weight to the recent past than the far distant past, and this is formalized in our model.

Fundamentalists versus Contrarians
The first case we are going to examine is a two-type heterogeneous agents model with fundamentalists and contrarians as market participants. Fundamentalists exhibit deterministic function of the form: and have some positive information gathering costs C, i.e. C > 0. Contrarians exhibit a deterministic function: 2, and zero information gathering costs. It is thus a case of fundamentalists versus pure contrarians. We have the following fractions of belief types equation: For convenience we shall also introduce a difference in fractions mt: Finally, we have the fitness measure equation of each type: In order to analyze memory in our heterogeneous asset pricing model, we shall first determine the position and stability of the steady state and the period two-cycle in relation to the memory strength parameter. We will also examine the possible qualitative changes in dynamics. Then we will perform some numerical simulations to combine global stability analysis with local stability analysis.

Position of the steady state
In our two-type heterogeneous agents model of fundamentalists versus contrarians the equilibrium pricing equation has the following form: A steady state price deviation x is a fixed point of the system, if it satisfies x = f(x) for mapping f(x). In our two-type heterogeneous agents model of fundamentalists versus contrarians we have: where either 0 eq x  , or * 1 2 In the former case we get the fundamental steady state, where the price is equal to its fundamental value and the difference in fractions is: Since it follows from expressions (22) and (23) that 1 eq U C   and 2 0 eq U  when w  1, the steady state difference in fractions simplifies: Since it can be derived that Therefore we can state the following lemma.  (27) and thus also in expression (26), memory does not affect the position of this steady state.

Stability of the steady state
In order to analyze stability of the steady state we shall rewrite our system as a difference equation: is a vector of new variables, which are defined as: 1, 1 We therefore obtain the following 5-dimensional first-order difference equation: The local stability of a steady state is determined by the eigenvalues of the Jacobian matrix, which we do not present here due to the spatial limitations. We then compute the Jacobian matrix of the 5-dimensional map. At the fundamental steady state X eq = (0, 0, 0, -C, 0) we obtain the new Jacobian matrix. A straightforward computation shows that the characteristic equation is in our case given by:

Bifurcations and the Period Two-cycle
A bifurcation is a qualitative change of the dynamical behaviour that occurs when parameters are varied (Brock and Hommes, 1998). A specific type of bifurcation that occurs when one parameter is varied is called a co-dimension one bifurcation. There are several types of such bifurcations, viz. period doubling, saddle-node and Hopf bifurcations. The first type has eigenvalue -1 of the Jacobian matrix, the second type has eigenvalue 1 and the third type has complex eigenvalues on the unit circle.
If we take a look at the eigenvalue 1, which we are in our case interested in, we can observe that a saddle-node bifurcation can never occur. Namely, the expression: can never hold, since the left-hand side is a positive constant and the right-hand side is always negative for g < 0, R > 0 and 2 0 eq n  . On the other hand, the expression: may be satisfied for 2 0 eq n  , since both sides of the expression are then negative. Thus a (primary) period doubling bifurcation may occur in our model for the following -value: Therefore we can state the following lemma. As in the paper of Brock and Hommes (1998), very strong contrarians with g < -2R may lead to the existence of a period two-cycle, even when there are no costs for fundamentalists (C = 0). When the fundamentalists' costs are positive (C > 0), strong contrarians with -2R < g < -R may lead to a period two-cycle. As the intensity of choice increases to  = *, a period doubling bifurcation occurs in which the fundamental steady state becomes unstable and a (stable) period two-cycle is created, with one point above and the other one below the fundamental.
When the intensity of choice further increases, we are likely to find a value  = **, for which the period two-cycle becomes unstable and a Hopf bifurcation of this period two-cycle occurs, as in Brock and Hommes (1998). The model would then get an attractor consisting of two invariant circles around each of the two (unstable) period two-points, one lying above and the other one below the fundamental. Immediately after such a Hopf bifurcation, the price dynamics is either periodic or quasi-periodic, jumping back and forth between the two circles. The proof of this phenomenon is not straightforward due to the non-zero period points, although the 5-dimensional system (31) -(35) is still symmetric with respect to the origin. We shall thus demonstrate the occurrence of the Hopf bifurcation and the emergence of the attractor numerically in the next section.

Numerical analysis
Our numerical analysis in the case of fundamentalists and contrarians will be conducted for fixed values of parameters R = 1.1, k = 1.0, C = 1.0 and g = -1.5. We shall thus vary the intensity of choice parameter  and of course the memory strength parameter w. Four analytical tools will be used 2 ; bifurcation diagrams, largest Lyapunov characteristic exponent (LCE) plots, phase plots, and time series plots.
The dynamic behaviour of the system can first and foremost be determined by investigating bifurcation diagrams. In Figure 1 the bifurcation diagrams for two different values of the memory strength parameter are presented. We can observe that for low values of  we have a stable steady state, i.e. the fundamental steady state. As has been proven in Lemma 1, the position of this steady state, i.e. x eq = 0, is independent of the memory, which is clearly demonstrated by the simulations. For increasing  a (primary) period doubling bifurcation occurs at  = *; the steady state becomes unstable and a stable period two-cycle appears, as proven in Lemma 3. As can be seen from the simulations, this bifurcation value is also independent of the memory. The stability of the steady state is thus unaffected by the memory, as proven in Lemma 2.
If  increases further, indeed a (secondary) Hopf bifurcation occurs at  = **, as has been claimed in Section 3.3; the period two-cycle becomes unstable and an attractor appears consisting of two invariant circles around each of the two (unstable) period two-points, one lying above and the other one below the fundamental. It is a supercritical Hopf bifurcation, where the steady state gradually changes either into an unstable equilibrium or into an attractor (cf. Guckenheimer and Holmes, 1983;Frøyland, 1992;Kuznetsov, 1995). The position of the period two-cycle is independent of the memory, but it is not independent of the intensity of choice, as can be seen from expression (40). Numerical simulations suggest that the secondary bifurcation value also does not vary with changing memory strength parameter w. For  > ** chaotic dynamic behaviour appears, which is interspersed with many (mostly higher order) stable cycles. Such a bifurcation route to chaos was also called the rational route to randomness (Brock and Hommes, 1997a), while the last part of it has been referred to as the breaking of an invariant circle.
Notes: Horizontal axis represents the intensity of choice (). Vertical axis represents deviations of the price from the fundamental value (x) in the upper two diagrams and the value of the largest LCE in the lower two diagrams, respectively. The diagrams differ with respect to the memory strength parameter w; the left one corresponds to w = 0.3, while the right one corresponds to w = 0.9.

Figure 1. Bifurcation diagrams and Largest LCE plots of  in case of fundamentalists versus contrarians
By examining largest Lyapunov characteristic exponent (LCE) plots of  we arrive at the same conclusions about the dynamic behaviour of the system. It can be seen from Figure 1 that the largest LCE is smaller than 0 and the system is thus stable until the primary bifurcation, which is independent of memory. At the bifurcation value, a qualitative change in dynamics occurs, i.e. a period doubling bifurcation and we obtain a stable period twocycle. Largest LCE is again smaller than 0 and the system is thus stable until the secondary bifurcation. At this bifurcation value, again a qualitative change in dynamics occurs, i.e. a Hopf bifurcation, but the dynamics is more complicated.
For lower values of w the largest LCE after ** is non-positive, but close to 0, which implies quasi-periodic dynamics. After some transient period the largest LCE becomes mainly positive with exceptions, which implies chaotic dynamics, interspersed with stable cycles. In fact, the largest LCE plot has a fractal structure (cf. Hommes, 1998, p. 1258). In the case of w = 0.9 the global dynamics after ** immediately becomes chaotic. Memory thus certainly affects the dynamics after the secondary bifurcation. Since the latter is a period doubling bifurcation, we are talking about period doubling routes to chaos.
Next, we shall examine plots of the attractors in the (xt, xt-1) plane and in the (xt, n1,t) plane 3 without noise and with IID noise added to the supply of risky shares. In the upper left plot of each of the four parts of Figures 2 and 3 we can first observe the appearance of an attractor for the intensity of choice beyond the secondary bifurcation value. The orbits converge on such an attractor consisting of two invariant 'circles' around each of the two (unstable) period two-points 4 , one lying above and the other one below the fundamental value. As the intensity of choice increases, the circles 'move' closer to each other. In the upper right and lower left plot of each of the four parts of Figures 2 and 3 we can observe that the system seems already to be close to having a homoclinic orbit. The stable manifold of the fundamental steady state, (0, ) eq s W m , contains the vertical segment, x eq = 0, whereas the unstable manifold, (0, ) eq u W m , has two branches, one moving to the right and one to the left. Both of them are then 'folding back' close to the stable manifold.
For as Hommes (1998, p. 1254) have proven for the asset pricing model without additional memory, at infinite intensity of choice and strong contrarians, g < -R, that unstable manifold (0, 1) u W  is bounded and all orbits converge on the saddle point (0, -1).
In particular, all points of the unstable manifold converge on (0, -1) and are thus also on the stable manifold. Consequently, the system has homoclinic orbits for infinite intensity of choice. In the case of strong contrarians and high intensity of choice it is therefore reasonable to expect that we will obtain a system close to having a homoclinic intersection between the stable and unstable manifolds of the fundamental steady state. This is indeed what can be observed from the lower left plot of each of the two parts of Figures 2 and 3 and it suggests the occurrence of chaos for high intensity of choice. As can be seen from the lower right plot of each of the two parts of Figures 2 and 3, the addition of small dynamic noise to the system does not alter our findings.
Notes: Horizontal axis represents deviations of the price from the fundamental value (xt). Vertical axis represents lagged deviations of the price from the fundamental value (xt-1). The groups of four diagrams differ with respect to the memory strength parameter w; the left group corresponds to w = 0.3, while the right group corresponds to w = 0.9.

Figure 2. Phase plots of (xt, xt-1) in case of fundamentalists versus contrarians
Notes: Horizontal axis represents deviations of the price from the fundamental value (xt). Vertical axis represents the fraction of fundamentalists (n1,t). The groups of four diagrams differ with respect to the memory strength parameter w; the left group corresponds to w = 0.3, while the right group corresponds to w = 0.9. Again, we can observe that memory has an impact on the global dynamics of the system. That is, both the convergence of the system on an attractor consisting of two invariant 'circles' around each of the two unstable period two-points and the 'moving' of the circles closer to each other seem to be happening faster (at lower intensity of choice) when more memory is present in the model. Moreover, at the same intensity of choice we seem to be closer to obtaining a system that has a homoclinic intersection between the stable and unstable manifolds of the fundamental steady state when the memory strength is higher.
Finally, we shall examine time series plots of deviations of the price from the fundamental value and of the fraction of fundamentalists 5 . Figure 4 shows some time series corresponding to the attractors in Figures 2 and 3, with and without noise added to the supply of risky shares. Similarly to the findings of Brock and Hommes (1998), we can observe that the asset prices are characterized by an irregular switching between a stable phase with prices close to their (unstable) fundamental value and an unstable phase of up and down price fluctuations with increasing amplitude.
This irregular switching is of course reflected in the fractions of fundamentalists and contrarians in the market. Namely, when the oscillations of the price around the unstable steady state gain sufficient momentum, it becomes profitable for the trader to follow efficient market hypothesis fundamental value despite the costs that are involved in this strategy. The fraction of fundamentalists approaches unity and the asset price stabilizes. But then the nonzero costs of fundamentalists bring them into position where they are unable to compete in the market; the fraction of fundamentalists rapidly decreases to zero, while the fraction of contrarians with no costs approaches unity with equal speed. The higher the intensity of choice, ceteris paribus, the faster this transition is complete; when  approaches the neoclassical limit, the entire mass of traders tends to use the best predictor with respect to costs, i.e. the strategy with the highest fitness.\ Additional memory does not change the pattern of asset prices per se, but it does affect its period. Namely, at the same intensity of choice and higher memory strength the period of this irregular cycle appears to be elongated on average, in such a way that the stable phase with prices close to their fundamental value lasts longer, while the duration of the unstable phase of up and down price fluctuations does not change significantly. The effect of including more memory thus mainly appears to be stabilizing with regard to asset prices. With regard to fractions of different trader types we could say that including additional memory affects the transition from the short period of fundamentalists' dominance to the longer period of contrarians' dominance in the market. This transition takes more time to complete at the same intensity of choice. More memory thus causes the traders to stick longer to the strategy that has been profitable in the past, but might not be so profitable in the recent periods.
Notes: Horizontal axis represents the time (t). Vertical axis in each pair of time series plots first represents deviations of the price from the fundamental value (xt), and then the fraction of fundamentalists (n1,t). The plots on the left-hand side and the right-hand side of the figure differ with respect to the memory strength parameter w; the ones on the left correspond to w = 0.3, while the ones on the right to w = 0.9.  We therefore obtain the following 5-dimensional first-order difference equation:   2, 1 3, 1 1, 2, 2 3, 3 2 3 3 3 , 1 , 1 1 1   1, 1, 1 1, 1 2, 1 1, 1 2, 1 (1 ) Our three-type heterogeneous agents model of fundamentalists versus biased beliefs in general can have the following steady state price deviations: We obtain the fundamental steady state for 2 x  . This is implied by 1 2 3 0 eq eq eq u u u    when w  1 and consequently by 1 2 3 1 3 eq eq eq n n n    , originating from the rewritten expression (44).
By performing a generalization we can state the following lemma.

Proof of Lemma 4:
We will prove a more general result for the case with h = 1, …, H purely biased types bh (including fundamentalists with b1 = 0). Proceeding from the non-transformed variables the system is: , steady states of expressions (55) and (57) or expression (58) are determined by: where r = R -1. Since a steady state has to satisfy expression (60), following Hommes (1998, p. 1271), a straightforward computation shows that: where the inequality follows from the fact that the term between square brackets can be interpreted as the variance of the stochastic process, where each bh is drawn with probability nh. Therefore,

Stability of the steady state and bifurcations
The local stability of a steady state is again determined by the eigenvalues of the Jacobian matrix. At the fundamental steady state X eq = (0, 0, 0, 0, 0) the Jacobian matrix exhibits the characteristic equation that is in our case given by: which has the following three solutions, two of them being double: 1 0 The fundamental steady state is stable for 1   , which in our case is limited to the product of eigenvalues 4,5  being smaller than one, i.e. Thus we can state the following lemma. . Memory affects the stability of this steady state by restricting it to the given interval of the parameter value.

Proof of Lemma 5:
From the characteristic equation (62) we can observe five eigenvalues. The first three eigenvalues always assure stability, while the last two eigenvalues limit stability. Given k > 0, b > 0,   0, R > 1 and 0  w  1, the condition for stability in terms of  implies . Similarly, the condition for stability in terms of w indicates Memory therefore affects the stability of the steady state as shown.
If we now take a look at the eigenvalues 4,5 of the characteristic equation (62), which are of interest in our case, we can observe that a saddle-node bifurcation would occur for: This can never hold, since 0   and the left-hand side is always non-negative, while 1 R  and the right-hand side is always negative. On the other hand, a period doubling bifurcation would occur for: This can never hold either, since 0   and the left-hand side is again always non-negative, while 0 1 w   and the right-hand side is either negative or not defined.
The remaining qualitative change of the three discussed in Section 4.3 is the Hopf bifurcation. For this to occur, a complex conjugate pair of eigenvalues has to cross the unit circle. Eigenvalues 4,5 are complex for   produces the following interval of values: We therefore state the following lemma. the system exhibits a Hopf bifurcation. Memory affects the emergence of this bifurcation, viz. with more memory the bifurcation occurs later.
As we have just established, in the case of fundamentalists versus opposite biased beliefs increasing intensity of choice to switch predictors destabilizes the fundamental steady state. This happens through a Hopf bifurcation. We can thus conclude, as did Brock and Hommes (1998) for the simpler version of the model, that in the presence of biased agents the first step towards complicated price fluctuations is different from that in the presence of contrarians. This fact does not change when we take memory into account.

Proof of Lemma 6:
When  increases, terms with  in the expressions for the eigenvalues 4,5 increase as well, and one of the eigenvalues has to cross the unit circle at some critical * Since the memory strength parameter is present in the expression for *, memory affects the emergence of this bifurcation; the higher the value of this parameter, the higher the bifurcation value.

Numerical analysis
Our numerical analysis in the case of fundamentalists and opposite biased beliefs will be conducted for fixed values of parameters R = 1.1, k = 1.0, b2 = 0.2 and b3 = -0.2. We shall thus vary the memory strength parameter w and the intensity of choice parameter . The same four analytical tools will be used than in Section 3.4.
Dynamic behaviour of the system can again first and foremost be determined by investigating bifurcation diagrams. From Figure 5 we can observe that for low values of  we have a stable steady state, i.e. the fundamental steady state. As has been proven in Lemma 4, the position of this steady state, i.e. x eq = 0, is independent of the memory, which is clearly demonstrated by the simulations. For increasing  a bifurcation occurs at  = *, which is a Hopf bifurcation; the steady state becomes unstable and an attractor appears, consisting of an invariant circle around the (unstable) steady state. It is again a supercritical Hopf bifurcation, where the steady state gradually changes either into an unstable equilibrium or into an attractor.
The bifurcation value varies with changing memory strength parameter, as given by expression in Lemma 6. As can also be seen from Figure 5 at higher memory strength the bifurcation occurs later. For  > * complex dynamical behaviour appears, which is interspersed with stable cycles. As we have already discovered in Section 4.2, irrespective of the amount of additional memory that is taken into account such a (bifurcation) route to complicated dynamics is different from that in the presence of contrarians, where we observed period doubling route to chaos (rational route to randomness).
By examining largest Lyapunov characteristic exponent (LCE) plots of  we arrive at more precise conclusions about the dynamic behaviour of the system. It can be seen from Figure 5 that the largest LCE is smaller than 0 and the system is thus stable until the bifurcation. At the bifurcation value a qualitative change in dynamics occurs, i.e. a Hopf bifurcation. The dynamics is somewhat more complicated. Namely, we can observe that the largest LCE after  = * is non-positive, but mainly close to 0, which implies periodic and quasi-periodic dynamics, i.e. for high values of the intensity of choice only regular (quasi-)periodic fluctuations around the unstable fundamental steady state occur. An important finding is that the predominating quasi-periodic dynamics does not seem to evolve to chaotic dynamics and the route to complex dynamics is indeed different from the routes examined so far.
Notes: Horizontal axis represents the intensity of choice (). Vertical axis represents deviations of the price from the fundamental value (x) in the upper two diagrams and the value of the largest LCE in the lower two diagrams, respectively. The diagrams differ with respect to the memory strength parameter w; the left one corresponds to w = 0.3, while the right one corresponds to w = 0.9. Next, we shall examine plots of the attractors in the planes, determined by (xt, xt-1) and (xt, n1,t).
In the upper left plot of each of the two parts of Figure 6 we can first observe the appearance of an attractor for the intensity of choice beyond the bifurcation value. The orbits converge to such an attractor consisting of an invariant 'circle' around the (unstable) fundamental steady state. The attractor obtained in the (xt, n1,t) plane is somewhat different. Namely, the unstable steady state dissipates into numerous points and evolves into a 'loop' shape, as shown in Figure 7.
As the intensity of choice increases, the dynamics remains periodic or quasi-periodic; in case of past deviations of prices from the fundamental value and fractions of biased beliefs the invariant circle slowly changes its shape into a '(full) square' (see Figure 6), while in case of fractions of fundamentalists the loop slowly changes into a 'three-sided square' (see Figure 7).
For high values of intensity of choice we seem to obtain (stable) higher period cycles; in the case of past deviations of prices from the fundamental value and fractions of biased beliefs we seem to attain a stable period four-cycle, while in the case of fractions of fundamentalists it is difficult to obtain any solid indications based solely on numerical simulations due to Notes: Horizontal axis represents deviations of the price from the fundamental value (xt). Vertical axis represents lagged deviations of the price from the fundamental value (xt-1). The groups of four diagrams differ with respect to the memory strength parameter w; the left group corresponds to w = 0.3, while the right group corresponds to w = 0.9. Figure 6. Phase plots of (xt, xt-1) in case of fundamentalists versus opposite biases Notes: Horizontal axis represents deviations of the price from the fundamental value (xt). Vertical axis represents the fraction of fundamentalists (n1,t). The groups of four diagrams differ with respect to the memory strength parameter w; the left group corresponds to w = 0.3, while the right group corresponds to w = 0.9. convergence problems for very high values of intensity of choice. In the latter case we can observe stable period four-and six-cycles, however (see lower right plot of each of the two parts of Figure 7). Indeed, Brock and Hommes (1998) proved for the case of exactly opposite biased beliefs and infinite intensity of choice in their simpler version of the model without additional memory that the system has a stable four-cycle attracting all orbits, except for hairline cases converging on the unstable fundamental steady state. Additionally, they discovered that for all three trader types average profits along the four-cycle equal b 2 .
Again, we can observe that the memory has an impact on the dynamics of the system. Namely, both the convergence of the system on an attractor and the further development of such an attractor seem to be dependent on the value of the memory strength parameter. The precise impact of memory is somewhat more difficult to establish due to the dependence of the bifurcation value on memory strength and the subsequent need to choose higher intensities of choice with higher memory strength in order to demonstrate different nature of attractors of the system. However, we can still establish that at the same intensity of choice (after the bifurcation value) the system apparently needs less additional memory in order to develop a specific stage of an attractor or even a (stable) higher period cycle.
Finally, we shall examine time series plots of deviations of the price from the fundamental value and of the fractions of all three types of traders. Figure 8 shows some time series corresponding to the attractors in Figures 6 and 7. We can observe that opposite biases may cause perpetual oscillations around the fundamental, even when there are no costs for fundamentalists, but can not lead to chaotic movements. Furthermore, as has already been indicated by the appearance of stable higher period cycles for high intensities of choice, in a three-type world, even when there are no costs and memory is infinite, fundamentalist beliefs can not drive out opposite purely biased beliefs, when the intensity of choice to switch strategies is high.
Hence, according to the argumentation of Hommes (1998, p. 1260), the market can protect a biased trader from his own folly if he is part of a group of traders whose biases are 'balanced' in the sense that they average out to zero over the set of types. Centralized market institutions can make it difficult for unbiased traders to prey on a set of biased traders provided they remain 'balanced' at zero. On the other hand, in a pit trading situation unbiased traders could learn which types are balanced and simply take the opposite side of the trade. In such situations biased traders would be eliminated, whereas a centralized trading institution could 'protect' them.
Additional memory does not change the pattern of asset prices and trader fractions per se, but it does affect its period. Namely, at the same intensity of choice and higher memory strength the period of these cycles appears to be elongated on average, in a way that both the negative and the positive deviation of the price from the fundamental value last longer. The same is valid for fractions ob biased traders, while in the case of fractions of fundamentalists the prolongation of the period of the irregular cycle appears in the form of less frequent 'spikes', which is understandable, since more persistent deviations of prices from the fundamental imply more space for biased traders and less chance for appearance of the fundamentalists. More memory causes the traders to stick longer to the strategy that has been profitable in the past, but might not be so profitable in the recent periods; therefore the system approaches purely quasiperiodic dynamics when the memory strength increases at given intensity of choice.
Notes: Horizontal axis represents the time (t). Vertical axis in each set of time series plots represents deviations of the price from the fundamental value (xt), and the fractions of fundamentalists (n1,t), optimistic biased beliefs (n2,t) and pessimistic biased beliefs (n3,t). The plots on the left-hand side and the right-hand side of the figure differ with respect to the memory strength parameter w; the ones on the left correspond to w = 0.3, while the ones on the right to w = 0.9.

Concluding remarks
In a market with fundamentalists and contrarians the fundamental steady state is the unique steady state of the system, which arises for low values of intensity of choice. Memory affects neither the position of this steady state nor its stability. For increasing intensity of choice a primary bifurcation, i.e. a period doubling bifurcation occurs; the steady state becomes unstable and a stable period two-cycle appears. Both the primary bifurcation value and the position of the period two-cycle are independent of the memory. For further increasing intensity of choice a secondary bifurcation, i.e. a supercritical Hopf bifurcation, occurs; the period two-cycle becomes unstable and an attractor appears consisting of two invariant circles around each of the two (unstable) period two-points, one lying above and the other one below the fundamental. For high intensity of choice chaotic asset price dynamics occurs, interspersed with many stable period cycles. Such a bifurcation route to chaos is often called the rational route to randomness.
In case of strong contrarians and high intensity of choice it is reasonable to expect that we will obtain a system that is close to having a homoclinic intersection between the stable and unstable manifolds of the fundamental steady state, which indicates the occurrence of chaos. There exists a certain limited interval of memory strength values, for which at a given intensity of choice we are more likely to obtain such a system with more additional memory in the model. A rational choice between fundamentalists' and contrarians' beliefs triggers situations that do not reach fruition due to practical considerations and are thus unattainable, 'castles in the air', as Brock and Hommes (1998, p. 1258) would put it. As a consequence we obtain market instability, characterized by irregular up and down oscillations around the unstable efficient market hypothesis fundamental price. Additional memory lengthens on average the period of this irregular cycle and mainly appears to be stabilizing with regard to asset prices.
In a market with fundamentalists and opposite biases the fundamental steady state is also the unique steady state of the system, arising for low values of intensity of choice. Memory does not affect the position of this steady state, but does affect its stability. For increasing intensity of choice a supercritical Hopf bifurcation occurs; the steady state becomes unstable and an attractor appears. Memory affects the emergence of this bifurcation; the higher the memory strength, the higher the bifurcation value. More memory thus has a stabilizing effect on dynamics. For high intensity of choice the dynamic behaviour is more complex. However, irrespective of the amount of additional memory such a route to complicated dynamics is different from that in the presence of contrarians, for after the bifurcation value only regular (quasi-)periodic fluctuations around the unstable fundamental steady state occur. Consequently, an important finding is that the predominating quasi-periodic dynamics does not seem to evolve to chaotic dynamics.
After the incidence of the bifurcation the higher value of the memory strength parameter causes the dynamics to be less periodic and more quasi-periodic; the dynamics therefore converges on purely quasi-periodic behaviour with increasing memory strength. Opposite biases may cause perpetual oscillations around the fundamental, even without costs for fundamentalists, but can not lead to chaotic movements. Furthermore, in a three-type world, even when there are no costs and memory is infinite, fundamentalist beliefs can not drive out opposite purely biased beliefs, when the intensity of choice to switch strategies is high. Hence, following the argumentation of Hommes (1998, p. 1260), the market can protect a biased trader from his own folly if he is part of a group of traders whose biases are balanced.
In conclusion, both our analytical work and our numerical simulations suggest that biases alone do not trigger chaotic asset price fluctuations. Sensitivity to initial states and irregular switching between different phases seem to be triggered by trend extrapolators; in our case by contrarians. Apparently, some (strong) trend extrapolator beliefs are needed, such as strong trend followers or strong contrarians, in order to trigger chaotic asset price fluctuations. A key feature of our heterogeneous beliefs model is that the irregular fluctuations in asset prices are triggered by a rational choice in prediction strategies, based upon realized profits, viz. the observed deviations from the fundamentals are driven by short-run profit seeking. We can also talk about rational animal spirits that, according to Brock and Hommes (1997b), exhibit some qualitative features of asset price fluctuations in the actual financial markets, such as the autocorrelation structure of prices and returns.

Author details
Miroslav