Confidence and self-attribution bias in an artificial stock market

Using an agent-based model we examine the dynamics of stock price fluctuations and their rates of return in an artificial financial market composed of fundamentalist and chartist agents with and without confidence. We find that chartist agents who are confident generate higher price and rate of return volatilities than those who are not. We also find that kurtosis and skewness are lower in our simulation study of agents who are not confident. We show that the stock price and confidence index—both generated by our model—are cointegrated and that stock price affects confidence index but confidence index does not affect stock price. We next compare the results of our model with the S&P 500 index and its respective stock market confidence index using cointegration and Granger tests. As in our model, we find that stock prices drive their respective confidence indices, but that the opposite relationship, i.e., the assumption that confidence indices drive stock prices, is not significant.


Introduction
In recent decades the efficient market hypothesis (EMH) has been generally assumed to be true in finance [1]. In his classic paper, Fama [2] defined an efficient financial market as one in which asset prices always fully reflect available information. The EMH is based on three arguments, (i) that investors are rational, perfectly consistent and coherent as they critically examine their options, and possess enormous computational power, (ii) that some investors are irrational but because their actions are random they cancel themselves out and do not affect asset prices, and (iii) that when irrational investors begin to act in concert they are stopped by rational arbitrageurs who eliminate their influence on asset prices [1].
In the first decade after its development in the 1960s, the EMH became unanimously accepted, both among theoreticians and those working empirically. Jensen, one of the creators of the EMH, stated "there is no other proposition in economics which has more solid empirical evidence supporting it than the efficient market hypothesis" [3]. a1111111111 a1111111111 a1111111111 a1111111111 a1111111111 In the years that followed, this hypothesis began to be questioned not only from a theoretical but also from an empirical point of view. First, to bluntly state that people in general and investors in particular are totally rational is problematic. According to Fisher Black [4], investors trade on noise instead of on information, but this statement is overly general because investor behavior is often simultaneously irrational and highly systematic.
Tversky and Kahneman [5] point out that trader actions can indicate a departure from the conventional rational decision model in several fundamental areas, including their attitudes towards risk, their mental accounting, and when they exhibit overconfidence. Awareness of these psychological factors and of the reality that arbitrage is limited has produced a new approach to the study of financial markets: behavioral finance (BF).
Although conventional financial market models based on such hypotheses as rational selection and market efficiency are elegant, none has been able to explain such basic empirical characteristics or "anomalies" in real-world financial markets as excessive transaction volume or price volatility. Thus financial markets have become one of the most active areas within which researchers using agent-based models attempt to understand regularities found in financial data. One of the first studies of this type was conducted by Arthur et al. [6], who developed a dynamic theory of asset pricing that was based on heterogeneous investors who update their price expectations individually and inductively using classification systems.
Agent-based computational models treat economies as systems made up of independent agents who interact with each other according to a set of rules. The initial market conditions are specified and the economy is allowed to evolve over time as the constituent agents repeatedly interact. The goal is to investigate the relationship between market prices and information.
With respect to price formation, which is critical, such models can be classified under four categories according to LeBaron [7]. The first type uses a slow price adjustment, in which the market is always in fact in disequilibrium. An example of this category of models is Day and Huang [8]. A second market mechanism is to set the equilibrium at each period of time numerically or analytically (the latter method assuming simplifying hypotheses). Examples of this kind of market adjustment are Arthur et al. [6], Brock and Hommes [9], and more recently Xu et al. [10], among others. A more realistic and perhaps a more important mechanism is the simulation of an order book, in which the agents define offers to buy and sell stock. The orders are then crossed in conformity with some defined procedure, like in Farmer et al. [11], and Zhou et al. [12]. In Farmer et al. [11], a model is tested in which the agent's rationality is eliminated almost completely. The model assumes the agents place buy and sell orders randomly, subject to constraints imposed by the prices. The authors demonstrate that such approach is able to replicate many characteristics of the price history dataset, that is, this paper helps to understand which empirical regularities may be the fruit of only the institutions, and which may be the result of the agents' learning. On the other hand, Zhou et al. [12] study the order flow of Shenzhen (China) Stock Exchange for the year 2003. Among other important results, it is observed that random strategies showed a much better performance than real strategies both for winners and losers, what seems to corroborate the model by Farmer et al. [11]. Matching is another kind of adjustment mechanism, where the agents meet at random and if it is convenient for them, they trade with one another. This mechanism may be suitable for situations where formal trading markets have not been established yet. An example of this type of model can be found in Beltratti and Margarita [13].
Agent-based models can contribute significantly to the study of financial behavior by computationally analyzing these psychological characteristics. Note that agent-based models applied to finance are behavioral models themselves because the agents are limited rationally and usually follow rules that are either preset or learned through experience. Most of the models created thus far depart from the behavioral finance approach, however, in that they assume that the agents exhibit conventional preferences.
Our goal here is to create an agent-based model in which the agents exhibit confidence in their decision making, in accordance with the behavioral finance approach, and we assume that the level of agent confidence evolves during the simulation time. According to Odean [14], the overconfidence of successful agents can be reinforced by a self-attribution bias, i.e., when they believe their trading success is the result of their own ability. A small number of papers in the literature incorporate psychological biases into the agents, among them the studies by Takahashi and Terano [15], Lovric [16], and Bertella et al. [17]. Takahashi and Terano [15] use the Bayes error correction model, Lovric [16] the model by Levy, Levy, and Solomon [18], and Bertella et al. [17] a study by Arthur et al. [6]. Our study is similar to that by Bertella et al. [17], but it differs in the way we model confidence and how we verify the robustness of our model.
The study is organized as follows: section one describes the model framework, section two how agent expectation is determined, section three the behavioral bias that affects agent decisionmaking, section four the econometric analysis of our model, comparing it with the data from the S&P 500 index and its confidence levels and section five presents some final considerations.

Model
Our model is based on a study by Bertella et al. [17], and is composed of N agents who decide whether to invest in a risky asset (e.g., a stock) or in one that is risk-free (e.g., a US Treasury security).
The dividend paid by the stock per time unit, based on studies by Arthur et al. [6] and LeBaron et al. [19], is where " d is the dividend base, t has a normal distribution with mean 0 and finite variance σ 2 , and 0 < ρ < 1. The utility function is where W i,t is the wealth of agent i at time t and λ is the level of risk aversion. The maximization of the expected utility is subject to the budget constraint where W i,t represents the wealth of agent i at time t, x i,t represents the quantity of stocks ordered by agent i, p t and d t are the price and stock dividend respectively at time t, and r corresponds to the interest rate for the risk-free asset, considered constant over time.
The optimal quantity of stocks ordered by each agent x i,t is where s 2 i;t;pþd is the perceived variance of the returns, described by in which parameter θ determines the weight placed on the most recent square error as opposed to the weight placed on past square errors.
The market price is determined by the difference between the quantity of stocks ordered by agent i at t and the quantity at a previous time t − 1. If this difference is positive or zero, the number of stocks that agent i will buy at t (b i,t ) will be the difference itself, and the number of stocks that the agent will sell at the same time t (o i,t ) will be zero. This situation will reverse when the difference is negative. By adding the contribution of b i,t and o i,t together for all agents, we can determine the total quantity demanded, B t , and supplied, O t . Thus, according to Farmer and Joshi [20], the stock price at time t is where parameter β eases price fluctuations in the market. The rate of return at time t can then be calculated using

Formation of expectations and trading strategies
For the formation of expectations regarding the price and future dividend of the stock traded, E i,t (p t+1 + d t+1 ), the fundamentalists assume certain rules based on the dividend at time t and therefore estimate that growth will be at a constant rate g, i.e., and in which k refers to the discount rate of the flow of future dividends. On the other hand, the chartists estimate that prices are inertial, that is, if the recent price has increased the future price will also increase, and vice-versa. Thus based on a study by Takahashi and Terano [15], our expectations of price and future dividends will be and in which term a tÀ m ¼ 1 is associated with memory length, which can be of one, five, or ten units of time (m = 1, 5, and 10, respectively). Fundamentalists believe stock price converges to fundamental value and they use a dividend discount model to estimate it.
Chartists or technical traders are trend predictors which use past information to predict future prices. We carry our simulation for 100 agents, arbitrarily distributed between chartists and fundamentalists, who can-at each period of time-order and sell (short) up to a maximum of five stocks.

Confidence and self-attribution bias
According to Barberis and Thaler [21], behavioral finance studies can be divided into two categories: 1. those that show that arbitrage operations are usually unable to keep stock prices attached to their fundamental values; and 2. those that demonstrate that agents commit systematic errors when facing uncertainty and deviate from conventional assumptions.
The first category of study demonstrates that arbitrage operations are not perfect. The second makes it clear that psychology influences a family's decisions about consumption and investment. According to Kahneman and Riepe [22], financial decisions in uncertain environments are based on established rules and intuition. Thus either an excess or deficit of confidence can affect the actions of an economic agent and lead to irrational trading decisions.
In our study we use the perceived variance of stock returns described by Eq (5) and create a confidence coefficient that, when multiplied by the perceived variance of returns, characterizes its under-or over-estimation,ŝ where coefficient oc represents the level of agent confidence. When oc = 1, the agent has a neutral level of confidence and the variance of the stock return is not underestimated. When oc > 1, the agent lacks confidence and the variance of the stock return is overestimated. When 0 ⩽ oc < 1, the agent is overconfident and the variance of the stock return is underestimated, i.e., agents strongly believe in the validity of their stock return predictions.
We assume that the level of agent confidence evolves during the simulation time. As mentioned above, the overconfidence of successful agents can be further strengthened by a selfattribution bias. The level of agent confidence is updated based on the success of their predictions. We carry out this updating by first mapping confidence coefficient oc from interval oc 2 [0, 1[ into a more convenient interval, C 2 [0, 1]. Thus, as described by Lovric [16], we use a transformation function T, The transformation function T(. . .) is defined so that the neutral level of confidence (oc i,t = 1) can be mapped at the mean point of the transformation function (C i,t = 0.5). After the level of agent confidence is transformed into interval C 2 [0, 1], the levels are updated according to where σ i,t,p+d corresponds to the perceived standard deviation of the stock return. If the difference between the expected stock return and the actual return is within the interval of confidence defined by the agents, then the level of confidence will be decreased by parameter " a. If it is not, the agents are less confident and C i,t is multiplied by parameter " b. Note that " b > 1 and 0 < " a < 1. It is possible that the updating of the level of agent confidence is biased. For example, the increase in confidence level for good predictions can be greater than the decrease in confidence level for bad predictions. An example of a non-biased self-attribution bias occurs when 1 À " After the level of agent confidence is updated, C i,t+1 it is mapped at the original interval [0, 1[ using the inverse transformation function as described by Lovric [16],

Results and discussion
This section describes the computer simulations and discusses the results. The simulations are carried out as follows: 1. In the first simulation we focus on the behavioral heterogeneity of agents with a neutral level of confidence in a market composed of 25 fundamentalist agents, 25 chartist agents with m = 1, 25 chartist agents with m = 5, and 25 chartist agents with m = 10.
2. In the second simulation we use the same market configuration but vary the levels of chartist agent confidence. The simulation and its descriptive statistics in which all agents are fundamentalists (reference case) are shown in the S1 Appendix file (A1 Table, A2 Table,  Note that there are periods when the stock price is sustainably higher than the reference price, periods when the market is volatile, and periods of extreme volatility, which are characteristic of market crashes. Fig 2 shows the evolution of the stock rate of return during the simulation time, which confirms the presence of excess volatility in the market. Excess volatility occurs at periods when the dividend value generated by the stock breaks the trend heretofore maintained. The chartist agents do not expect this break because they do not know the value of the dividend generated in the prior period. The greater the number of chartist agents in the market, the greater the impact of their actions and the higher the market volatility. Statistics for this simulation, as well as the normality test for the rate of return, are shown in Table 1 and Fig 3, respectively. Note that the mean and median values of the return rate are lower than the values in the reference case, but the standard deviation and kurtosis values are higher, which indicates a substantial increase in volatility, the presence of heavy tails, and a considerable discrepancy in the normal distribution (see Fig 3). All of these characteristics are commonly found in financial series and may be the result of behavioral heterogeneity in the financial market.

Heterogeneous agents with different levels of confidence
The next simulation focuses on the interaction between different types of agents in the market and allows their confidence levels to evolve during the simulation. The market is composed of 25 fundamentalist agents not influenced by confidence and 75 chartist agents influenced by confidence and divided equally according to their memory of analysis. Figs 4-6 show the results. This simulation takes into account behavioral heterogeneity, but also the effect of the changing levels of agent confidence. This additional factor allows us to analyze and explain additional characteristics. Figs 4-6 show that the periods when assets are sharply overvalued coincide with those when agent confidence level is high, and the periods when prices fall coincide with those when agent confidence level is low. Note that in this case the volatility is also much higher than when agents have a "neutral" confidence level. Table 2 shows the descriptive statistics and the Fig 7 reveals the normality test for the stock rate of return for this simulation. Note how the standard deviation of the return rate is higher than in the previous case, indicating an increase in volatility. An excess of confidence intensifies volatility, and kurtosis and skewness are less than in the previous case (which had heterogeneous agents with a neutral confidence level), but the distribution of the rates of return remains far from normal.

Econometric analysis
We next measure the robustness of our model by comparing its results with actual data. We first analyze two variables produced by the model, confidence and price, to determine whether confidence determines price or price determines confidence. We then compare the results with actual S&P 500 index data and with confidence indices calculated for this stock market to determine whether real-world confidence levels determine stock prices or stock prices determine confidence levels.

Unit root tests
The hypotheses were first tested for the time series describing random walks: (i) the confidence index C t and (ii) the stock price P t , using the following unit root tests:  [27].
The adopted econometric procedure tested the following modified pair of hypotheses: 1. H 0 0 : series C t and P t are nonstationary 2. H 0 1 : series C t and P t are stationary Fig 8 shows the time evolution containing a sub-set of 500 values for the confidence index C t and the stock price P t , and their respective growth rate, suggesting a non-stationarity behavior in all cases.
All four unit root tests corroborate the results shown in Fig 8 and use as a base a significance level of 5% (p-value < 0.05), as shown by the values in Table 3.
Thus the results for stock price, its growth rate, confidence index and its growth rate show that we cannot reject the null hypothesis and thus all the series have a unit root and are nonstationary.

Cointegration and Granger tests
The random walk analyses carried out in the previous section confirm the non-stationarity of the series analyzed individually. We now test the series for cointegration in order to determine whether there is a long-range temporal relationship between the two variables, price and confidence, and their growth rates. We test two hypotheses: 1. H 0 : series C t and P t are not cointegrated 2. H 1 : series C t and P t are cointegrated Confidence and self-attribution bias in an artificial stock market Following Engle and Granger (1987) [28], we test whether the series cointegrate by first conducting an ordinary least squares (OLS) regression to estimate a time series. Fig 9 shows the residuals obtained through this regression for the data used, which in this case are stock prices.
First, to test the cointegration for the price index with respect to confidence index, we use the most negative Dickey-Fuller (DF) value to select which regression formula we will apply. When we test the residuals of the regression "confidence vs price" for the existence of a unit root we get a value of −27.366 for statistic t, with p < 2.2e-16 (and a value of -15.812 for the formula "price vs confidence"), and find that we can reject the null hypothesis. Thus we assume  Confidence and self-attribution bias in an artificial stock market that the residual is stationary, and that we cannot reject the hypothesis that the series are cointegrated, suggesting that there is a relationship between confidence and the price index. We obtain a similar result for the growth rate of the indices. Since the DF value for the regression formula "growth of confidence vs growth of price" is −62.2409, and −42.0239 for its opposite, we choose "growth of confidence vs growth of price" to be the dependent variable and find that we can also, at a 90% confidence level (p-value is 10%), reject the null hypotesis. Fig 10 shows the autocorrelation function (ACF) of residuals for the test by Ljung-Box (1978), and Table 4 shows the results of autocorrelation tests for residuals, revealing a  Confidence and self-attribution bias in an artificial stock market correlation between confidence and price, thus supporting the hypothesis that the series are cointegrated.
To confirm the cointegration among the series we use the Johansen test [29] to estimate the confidence level rank of a series or a set of series to test for the null hypothesis of r = 0 (without any cointegration) and the null hypothesis of r 1 (with cointegration). In the Johansen test, when the value for r 1 is greater than the confidence level value, there is cointegration. Table 4 shows the test results, which confirm that there is cointegration in both the regression of the indices and their respective growth rate regression.
According to Alexander [30], when there is cointegration between two time series a causal Granger-type relationship will also exist. Although cointegration is not required to indicate the presence of this relationship-which may reflect common characteristics between the series-the inverse is true, i.e., the presence of a causal relationship suggests that there is cointegration between the two time series.
To identify a causality relationship between the confidence index and the stock price, we conduct the Granger causality test with up to three discrepancies, for two hypotheses:  Table 5 shows the Granger test results for both hypotheses. Note that there is a causality relationship from the stock price to the confidence index but not from the confidence index to the stock price. In addition, there is a strong causality relationship (R 2 close to 1) between both hypotheses, and the causality relationship remains in all of the discrepancies tested. A similar result can also be found in the analysis of the causality relationship from the growth rate of the stock price to the growth rate of the confidence index, as can be seen in Table 6.

Comparing our model with the S&P 500 and its respective confidence index
To estimate the robustness of our model, we compare its results in two cases: (i) the S&P 500 index and the stock market confidence indexes calculated by the Yale School of Management , and (ii) the growth rate of both the S&P 500 and its confidence index. Fig 11 shows the time evolution with the confidence index (C t ) and values for the S&P 500 index on the left and its respective growth rate data for the same variables on the right. First we check the stationarity of the confidence series for the Yale confidence index and apply the four unit root tests. Most of the tests indicate that we cannot reject the null hypothesis (see Table 7). We then apply similar stationarity tests to the S&P 500, and obtain very similar results, suggesting that there is non-stationarity in the S&P 500 and in its corresponding Yale confidence indices.
To test the results of our model, we next check the cointegration among the prices and their respective confidence indices. Once again we address the Engle-Granger approach (Engle & Granger, 1987) by analyzing the stationarity of the residuals of the regression between the S&P 500 index with its respective confidence levels.  Confidence and self-attribution bias in an artificial stock market To test the cointegration for the (i) S&P 500 price index with respect to its respective Yale confidence index, we use the most negative Dickey-Fuller (DF) value to select the regression formula. Because the DF value for the regression formula "confidence vs price" for the S&P 500 is −1.8234, and −1.9289 for the "price vs confidence", we choose "the confidence index" to be the dependent variable and find that we can reject the null hypothesis within a 90% confidence level (p-value is 10%). Thus we can assume that the residual is stationary, suggesting that there is a cointegration between confidence levels and the S&P 500 index.
In the (ii) S&P 500 growth rate with respect to its corresponding Yale confidence growth rate case (see Table 8), the DF value of the regression formula "growth confidence vs growth price" is −5.8269, and for "price vs confidence" it is −6.8574. We choose the "confidence index" as the dependent variable and find that we can reject the null hypotesis within a 90% confidence level (p-value is 10%), indicating that the residual is stationary, and that there is cointegration between the Yale confidence growth rate and the S&P 500 growth rate.
In an alternative approach, we apply the Johansen test to both indices and find that there is cointegration in all cases: (i) between the S&P 500 and the Yale confidence indexes, and also (ii) between the growth rates for both indices (see Table 9).
In order to determine causality relations, we apply the Granger tests to all of the series. Table 10 shows the Granger test result for these indices. The F-test values and p-value for "S&P 500 causes Confidence" indicate that there is a causality relationship, especially when two or three discrepancies are considered. In the reverse "Confidence causes S&P 500" case, the F-test values and p-value indicate that the relationship is nonexistent.  Confidence and self-attribution bias in an artificial stock market Table 11 shows the result of the Granger test for the growth rates of these indices. The F-test values and p-value for "S&P 500 causes Confidence" indicate that there is a causality relationship (with p value 0.1), especially when one or two discrepancies are considered. In the reverse "Confidence causes S&P 500" case, the F-test values and p-value indicate that the relationship is not significant. As far as we know, there are only two stock market confidence indexes: the one calculated by Yale University and the other by Prof. Tsutsui from Osaka University, Japan. Therefore, similarly to the S&P 500 and its confidence indices, we repeated the same procedure for the Japanese stock market Nikkei index and its confidence level. We find that the Nikkei index is non stationary. However, a stationary behavior was found in its corresponding Osaka confidence index for the period of time that we were interested in. So, this result did not allow us to proceed with a proper analysis with the methods we used to check the cointegration and the causality relation between the Japanese indices.

Final considerations
Using an agent based model, we first analyze the interactions between agents using different trading strategies. We find that behavioral heterogeneity causes asset prices to be significantly more volatile than fundamental stock values. Next, we use agent-based modeling to analyze how both excess trader confidence and low trader confidence affects stock market trader decision-making, stock price dynamics, and rates of return and how agent confidence levels change over time. We find that agent decisions are strongly affected by agent confidence level, and that agent overconfidence strongly contributes to bubble formation. We also find that the price series and confidence levels generated by our model, as well as their growth rates, are non-stationary and cointegrated. We use the Granger test to identify causality relationships between the two variables and find that price affects confidence level, but that confidence level does not affect price. The same results are obtained for their growth rates.
To compare our model with actual data, we examine the S&P 500 index and its respective confidence levels. As in our model, Engle-Granger and Johansen tests indicate that there is cointegration between stock prices and stock market confidence indices, and between price growth and confidence growth rate. Besides, the Granger causality test indicates that price or its growth rate affects confidence and its growth rate. Therefore, we can assume it supports the predictions of our agent model and we thus conclude that when we use our proposed agent model to analyze historic price indices we are able to usefully estimate future market behavior.