Agent Based Modelling Working Party
Agent Based Modelling Working Party
At each lattice position, sugar grows back at a rate of units per time interval
up to the capacity at that position
Agent movement rule M
Look out as far as vision permits in the four principal lattice directions and
identify the unoccupied site(s) having the most sugar
If the greatest sugar value appears on multiple sites then select the nearest one
(If it appears at multiple sites the same distance away, the first site
encountered is selected, the site search order being random)
Move to this site
Collect all the sugar at this new position
Multi-commodity agent movement rule M
Look out as far as vision permits in each of the four lattice direction
Considering only unoccupied lattice positions, find the nearest position
producing maximum welfare
Move to the new position
Collect all the resources at that location
Agent replacement rule R
[a,b]
When an agent dies it is replaced by an agent of age zero having random
genetic attributes, random position in the sugarscape, random initial
endowment, and a maximum age randomly selected in the range [a,b]
Agent trade rule T
Agent and neighbour compute their marginal rate of substitution (MRS); if
these are equal then end, else continue
The geometric mean of the two MRS is calculated this will serve as the price
p [more elaborate bargaining could be constructed]
The quantities to be exchanged are if p>1 then p units of spice for 1 unit of
sugar; if p<1 then 1/p units of sugar for 1 unit of spice
If this trade will (a) make both agents better off (increase their welfares) and
(b) not cause the agents MRS to cross over then the trade is made and return
to start, else end
With these rules we first look at simulation ({G
1
}, {M, R
[60,100]
}) applied when there
is just sugar (no spice). The sugarscape grows back at 1 unit per time period (recall
that agents harvest all sugar at a site when they move to it). Agents move as per the
single-commodity rule and die when they reach their maximum age which is set at
birth randomly between 60 and 100 time periods (or die of starvation).
Readers can run the simulation at by selecting experiment 3 at:
http://complexityworkshop.com/models/sugarscape.html
Agents swarm around the two sugar mountains, with some moving between the two.
Those agents with metabolism equal to 1 can survive without moving on the
lowland of sugarscape where the maximum capacity is 1 and regenerates each time
period.
4.3. Wealth Distributions
The chart below is taken from the simulation after about 100 time units, it is an
emergent structure, a stable macroscopic pattern, that statistical in nature. It shows
the distribution of wealth: along the horizontal axis there is the range of wealth of all
the agents split by decile; the vertical axis shows the number of agents in each decile.
(The complexity workshop website has NetLogo embedded as the ABM software;
NetLogo uses turtle as the label for agent.)
The distribution is Pareto: majority of agents have little wealth and a few have great
riches. Recall that all agents are created equally with random variation of their
genetic characteristics; no agents were favoured. It is the wealth distribution that is
observed in the real world. Its growth in a simple model like Sugarscape is a
powerful statement of what ABM can achieve.
4.4. Sugarscape with trade
The second simulation is ({G
1
}, {M, T}) in the sugarscape with both and spice. The
movement rule is modified as above and a trade rule has been added. The death by
old age rule has been dropped for simplicity as the focus is on trade as agents seek to
better their welfare. We can observe each trade (volume transacted and price) in a
time period and hence calculate averages for what actually happened at that time
period. We can also ask each agent its situation regarding supply and demand for
sugar or spice and corresponding price, eg how much sugar would it want to buy at
what price if there was unlimited supply. This gives the aggregate supply and
demand by price: the supply and demand curves of neo-classical economics with the
intersection being the equilibrium volume of trade and price.
A snapshot of the supply/demand vs price, actual and equilibrium, that results is given
below. We see the shape of the supply and demand is textbook, but remember that it
is an emergent feature, not an assumed structure. We also see that equilibrium is
never attained we have a model to explore the dynamics of non-equilibrium.
A movie showing a longer time evolution is available at
http://www.brook.edu/es/dynamics/sugarscape/animations/AnimationIV.mov
The charts below show the development of the equilibrium and actual price and
quantity for the first 150 time units. The key observations are:
The volume traded is always below equilibrium level (not surprising as agents
can only trade with immediate neighbours and not on a wider scale basis)
The average equilibrium quantity is 906.6, the average actual quantity is
212.5
The equilibrium price or quantity is not stable
Nor is the actual price or quantity
The actual price can be either above or below the equilibrium price (it is above
56% of the time).
The average prices are similar: for equilibrium it is 0.895 and for actual it is
0.911
The actual price or quantity exhibits greater volatility than equilibrium
The standard deviation for actual price is 0.0762 (8.4% of the mean) whereas
the standard deviation for equilibrium price is 0.032 (3.6% of the mean)
The standard deviation for actual quantity is 146.9 (69.2% of the mean)
whereas the standard deviation for equilibrium quantity is 89.4 (9.9% of the
mean)
The distribution of price is visibly non-Gaussian with evidence of fat tails.
Quantity: equilibrium & actual
0.0
200.0
400.0
600.0
800.0
1000.0
1200.0
1400.0
1600.0
1 11 21 31 41 51 61 71 81 91 101 111 121 131 141
Time
Q
u
a
n
t
i
t
y
Equilibrium
Actual
Price: equilibrium & actual
0.600
0.700
0.800
0.900
1.000
1.100
1.200
1 11 21 31 41 51 61 71 81 91 101 111 121 131 141
Time
P
r
i
c
e
Equilibrium
Actual
Distribution of actual price return
0
5
10
15
20
25
-40% -30% -20% -10% 0% 10% 20% 30% 40%
Return
C
o
u
n
t
The movement of agents is also more complicated. Agents can no longer swarm on a
single mountain top as agents need both sugar and spice to survive and these
mountains are not coincident. Movements of agents which resemble trade routes
emerge.
5. Agent-Based Stock Market Models
This section is largely a summary of an earlier and much more detailed paper (Palin,
2003, http://citeseer.ist.psu.edu/palin02agentbased.html) which contains a
mathematical specification of the model and further results and commentary.
5.1. Motivation
Stockmarkets and other financial markets share many stylised features. These include
a distribution of returns that is more peaked and fat-tailed than the Gaussian
distribution; periods of persistent high volatility; periods of persistent high trading
volume; and correlation between volatility and trading volume.
Traditional economic models have tended either to use a simple distribution of returns
such as the Gaussian and treat extreme events as outliers, or to construct a statistical
process which reproduces some of these features. But such an approach is purely
descriptive and offers no understanding of why these characteristic properties should
be seen and persist across so many markets.
To demonstrate a true understanding of the origins of these properties we would like
to build a model which (i) produces these features without them being hard-coded
into the model; and (ii) allows us to turn these features on and off by changing
parameters of the model.
5.2. Description of Le Barons model
Well focus on a model by Blake Le Baron. While there are a number of models with
broadly similar features, Le Barons model is attractive because it is makes uses of
many features of classical economics.
The model has just two assets: cash, with a constant rate of return; and an equity
which pays a random dividend in each monthly time-step. For the equity only the
dividend is specified (by a lognormal process); the price of the equity is an emergent
property of the model which arises through the interactions of the agents.
The model also has a large number of agents. Unlike the earlier Sugarscape model
there is no geographic distribution of agents: instead they all compete equally in the
same market. Agents have an initial wealth and must decide at at each time-step how
much wealth to consume, and how to invest their wealth. The agents make their
decisions in order to maximise lifetime utility. This framework allows the agents to
draw on standard results from lifecycle finance (due to Samuelson and Merton) in
order to make their decisions; but in order to do so the agents must take a view on the
distribution of equity returns over the next time-step.
The agents form their views on future equity returns by drawing on a pool of trading
strategies. Each agent has several hundred rules which turn historic market
information into a prediction. The rules are in the form of a neural network, which
allows great flexibility in potential rules and can encompass rules which we might
describe as value, growth, and momentum, as well as complex combinations of
these. The agents monitor the success of each of their rules over previous time-steps
and act upon the rule which has proved most successful. Different agents have
different lengths of memory over which they assess their rules. Some may only look
at the last ten time-steps while others may use hundreds of time-steps.
The market price is determined using a Walrasian auction Under this method each
agent says how many shares he would like to buy or sell at any given price, and the
auctioneer chooses the price so that total supply and demand are equal. This method
has been used in real stockmarkets in the past but is not in common use currently.
The model also contains elements of adaptation and evolution. If a rule has proved
unsuccessful over a number of time-steps then it well be replaced by another rule.
And agents which are unsuccessful in their trading will also be replaced.
5.3. Rational expectations price
A consequence of the grounding of Le Barons model in economic theory is that we
can calculate the rational expectations price. This is the share price that would hold
if all agents held the same rational views of the market. We find that the rational
expectations price is equal to a constant multiple of the dividend; ie that the dividend
yield is constant.
Pensions actuaries may recall that a decade ago it was common in a pension scheme
valuation to use an actuarial value of assets rather than the market value. The
discounted dividend method of assigning an actuarial value to equities is similar to
using the rational expectations price. The agent-based model allows us to consider
under which conditions the rational expectations price would or would not be seen in
practice.
5.4. Results from the model
Well look at a few different settings of the model. In each case the model is run for
many time periods to avoid any artefacts caused by the initial conditions.
We first look at the case where all agents have a long memory: they choose which
rule to use based on performance over a period of around twenty years (240 monthly
time-steps). In this case (Figure 1) we find that the share price does converge to the
rational-expectations price, and the share price in the chart below is lognormal (since
it just a multiple of the dividend which is itself lognormal). We also find in this case
that there is no trading, since each agent is happy to maintain the same constant mix
of cash and equity.
Figure 1: The long memory case. The rational expectations price is observed.
We can contrast this with the all memory case where agents memories vary from
six months to over twenty years. In this case (Figure 2) we see significant deviations
from the rational expectations price with bubbles and crashes. We also find that in
contrast to the long memory case there is significant trading volume as agents
change their views in response to the changing market. The trading volume is
correlated with changes in share price, with trading volume being particularly high
during the instability around time 10000 and 10200.
Figure 2: The all memory case. Significant deviation from the rational expectations
price.
We would like to know whether the deviation from the rational expectations price in
the all memory comes from the diversity of agents memory lengths or just from the
presence of short memory agents. To address this we consider the short memory
case where all agents have memories that range from six months to three years. This
shows rapid cycles of bubbles and crashes.
Figure 3: The short memory case. Very rapid cycles of bubbles and crashes.
5.5. Cautions and criticisms
Le Barons model is a partial success. It allows us to investigate how a share price can
emerge from the actions of individual agents, and it shows how changing a parameter
of the model (agents memory length) can move from lognormal share prices to
stylised features of markets with fat tails, bubbles and crashes, and persistent
volatility.
But while we can get a good qualitative result it is difficult to find a calibration which
gives a good quantitative calibration. Changing memory length gives a sudden shift
from rational expectations price to a wild caricature of the real world (the kurtosis of
returns is an order of magnitude too high).
Also different models give different apparent reasons for features of real markets. One
model claims that a calibration with fast evolution of agents and strategies is
necessary to see fat tails; another shows fat tails without any evolution.
Although agent-based stockmarket models as they currently stand do not seem ready
as an investment tool they remain a very useful tool for investigation. The processes
which drive stock returns are not well understood with much commentary,
particularly in the popular media, being glib and applied only after the event. The
complex dynamics seen in LeBarons model are valuable in showing that simple
explanations of stock prices in terms of a single event are probably wrong.
6. Agent Based Models and Finance
When the authors of this paper were setting out on our careers, actuarial valuation
methods were typically deterministic, based on expected outcomes minus implicit or
explicit margins for prudence. On the pensions side, this is the funding approach to
liability valuation (Exley et al (1997)), while in insurance liabilities were valued by
reference to reliable yields (a calculation still required). The underlying
methodology was challenged in the 1990s by a series of papers arguing in favour of
market valuations
2
. These were backed up on strong modern financial economic
foundations, a discipline which hitherto had had little impact on actuarial practice.
These papers were highly influential in convincing the profession to alter practice, for
example the adoption of market based valuations, which are now generally common
practice in actuarial valuations and for accounting purposes in pensions and insurance.
Alongside this move to market valuation was the growth of computing power which
allowed the deterministic approach to be replaced with a stochastic one.
Agent-based modelling is not a mere tweak to neo-classical finance theory, but an
alternative world view which matches many participants intuition of what real
markets look like not necessarily a guarantee of their veracity. For example, agnet
based models are inherently lumpy, while much of classical finance makes
assumptions about infinitely divisible agents and investment markets in order to apply
differntial calculus. Some agent based models consider market and intrinsic values
separately, and explain how these two numbers diverge for significant periods of time.
The agent-based model generates bubbles, crashes and high volatility endogenously,
rather than exogenously as in the efficient market hypothesis (Farmer (2001)). For
anyone who works with real markets, they are intuitively appealing.
6.1. Financial Uses of ABM
The use of agent based models so far has been dominated by aspects of explanation
rather than prediction. Consideration of explanation and prediction need to
differentiate between qualitative and quantitative, issues of calibration being more
important for the latter. For example a model (agent based or otherwise) of financial
2
For example Exley et al (1997) and Sheldon and Smith (2004)
markets needs to generate bubbles as they have been observed. A model which does
not is clearly defective in either explanative or predictive capability. Having
generates bubble behaviour it is for calibration techniques (which may not currently
exist) to achieve a realist scaling between model and observation. Models which have
passed the qualitative test may fail the subsequent quantitative test.
6.2. Modigliani, Miller and Agents
A series of papers 1990s laid the foundations of what we now call market consistet
modelling. These papers applied the emerging discipline of finance economics to
actuarial theory. For example, a seminal paper was Exley et al (1997) which applies
the Modigliani Miller theorem (that the value of two firms is the same irrespective
of their financial structures (Modigliani Miller (1958))) to defined benefit pension
scheme valuation and investment strategy.
The paper argues that a shareholder of a company with a defined benefit pension
scheme has three equivalent ways of changing his asset mix:
1. Altering his directly held assets
2. Changing the balance sheet of the company
3. To modify pension fund asset strategy (assuming the shareholder has power to do
this)
The implications of this equivalence are profound as they imply that it is impossible
to achieve an optimal investment portfolio, as the shareholder can alter his own
investments instead of the pension funds.
The paper is now going to look at how we might take an agent based approach to
modelling a pension fund. The aim of this exercise is not to describe a realistic model,
but to question whether ABM could give rise to a different outlook to Modigliani-
Miller.
Doyne Farmer of the Sante Fe Institute constructs two kinds of traders, a seasonal
trader and a technical trader. There is no movement in the underlying value of the
commodity in the market. The seasonal traders buy and sell in a predictable pattern
they could represent, for example, farmers or even companies who need to meet
emissions targets. The technical traders are purely in it for the money and are allowed
to develop a variety of trading strategies; the more successful a strategy is, the more
capital the trader gets and the more they influence the market. The result is shown in
Figure 4. What happens is that the market becomes efficient after about 5,000
iterations when the technical traders make money off the seasonal traders and iron
out the predictable seasonal fluctuations. But after that, as you see, the model
suddenly goes mad. This is because the technical traders, who have now acquired
practically all the capital (as shown in graph B), start trading against each other,
devising ever more sophisticated trading strategies which work for a while until
another trader develops a better strategy (Farmer (2001)).
6.3. Pension fund as agent?
To answer this question let us imagine a scenario in which an equity and bond
portfolio both gave the same performance over a 5 year period, but equities increased
by 50% over the 1
st
3 years and then declined to meet the level of the gilts after 5
years i.e. one not unlike our current experience.
At the end of this period, the shareholder is equally well off if he invested directly in
bonds or equities. However, the outcome of shareholder value if the pension fund
invested in equity or gilts might be quite different. If the pension fund invested in
equity, at some point there would be an actuarial valuation, which would show a
surplus this could give rise to a reduced contribution rate and possible change to a
more aggressive investment approach. The reduction in contributions would mean
that the company has more cash available to invest in other activities. The positive
balance sheet may boost the companies share price, making capital cheaper which it
then might invest favourably. The subsequent drop in equity value (exacerbated by
the more aggressive investment policy) may put the scheme into deficit, causing the
Figure 4 Behaviour of market with 2 types of trader (Farmer 2001)
company to close the scheme, maybe boosting share value but also alienating the
workforce.
This is the potential action of the pensions fund we could in theory build up
predictable investment rules for the pension fund, which could then be modelled as an
agent. However, many pension funds tend to face the same issues at the same time. If
we model pension funds as agents we could introduce them into the a Farmer or
LeBaron type model, which are likely to challenge the Modigliani-Miller
equivalence.
This scenario above is oversimplified the aim is to demonstrates that the pension
schemes decision to invest in equity or gilts could have an effect on the pension
scheme, the value of the company and shareholder value quite different to his decision
to change his personal investments.
7. Implications for Actuarial Practice
7.1. Early Stages
Agent-Based Modelling is still at an early stage. What we have now is a collection of
example computer models. The inputs are a collection of agents with assumed
behaviour patterns, and ways of interacting. The outputs include simulated paths of
financial variables, which in most cases share prices.
The models we have, and future we may build, allow us to conduct many
experiments. With a combination of carefully controlled experiments and the growing
mathematical insights from the field of dynamical systems, we can aspire to a better
understanding of what in the model is most important at driving the outcomes. For
example, is the absolute number of agents critical, or is there some point beyond
which the model is large and adding extra agents does little to change behaviour.
How could we measure the diversity of behaviour among agents? Is it the absolute
level of irrationality or the difference between rationality of different agents that
matters most? To what extent do different forms of irrational behaviour cancel out in
observed market behaviour? Does the behaviour of all agents contribute equally to the
modelled behaviour, or does a cadre of leaders emerge whose behaviour is more
influential on the market as a whole?
7.2. The Need for Calibrations
We are far from understanding these issues at the current state of knowledge. But this
is likely to improve as experimentation and analysis proceeds. An ability to rank
inputs in order of importance is a pre-requisite for empirical calibration. The ranking
tells us what aspects of real trader behaviour should be captured in order to build a
useful model of the economy. Having determined the most important inputs,
calibration might proceed by surveys, interviews and trading on market simulators.
All this provides a way to calibrate the behavioural aspect of the models.
Without a calibration, the model tells us nothing concrete about the real world.
Models of efficient markets have existed for some time. ABM provides us, in
addition, with many alternative models of different ways markets could be inefficient.
Building an abstract computer model of inefficient markets cannot prove that markets
are inefficient. Efficiency, or otherwise, is an empirical question for which disciplined
observation of the real world is critical. That is why calibration is so important. A
fully calibrated and tested ABM, with demonstrable predictive power, can add to our
knowledge about real markets, not just to our knowledge of computer models. We are
not there yet, so a view that ABM will one day provide insight into market efficiency
remains, for now, a hunch, albeit a widely held hunch among ABM enthusiasts.
7.3. Rigour in testing Goodness of Fit
Informal model tests involve checking that the model accounts for observed data
patterns. A more rigorous process takes account of the number of parameters
estimated. The argument is that, with a large enough parameter count, a model can
reproduce any data set. The trick in classical statistics is to find a parsimonious model
than explains as much as possible of the observed data with a small number of
parameters. Neo-classical optimising agents fit well into this framework; a
parsimonious objective function is specified, and all aspects of behaviour are in
single-minded pursuit of the chosen objective. Specifying the behaviour of a non-
optimising agent requires an exhaustive list of responses to any eventuality. Without
any over-arching optimisation at work, the potential number of rules is vast. As a
result, ABM can generate many thousands or millions of parameters. In a statistical
sense, such high parameter counts imply a high threshold for the models ability to
explain real world outcomes.
7.4. Forecasting Ability
Let us now conduct a thought experiment, and imagine we have a calibrated and
tested ABM. What could we do with it?
The most obvious use is market prediction. A rejection of market efficiency is a
rejection of the notion that returns are unpredictable. So an ABM that consistently
predicts market prices (more accurately than a random walk) would pose a substantial
challenge to theories of efficient markets. Orthodoxy might fight back, for example by
rationalising observed biases as a reward for risk, but if the rewards are large enough
then a latent risk is a less plausible explanation. The implications for portfolio
construction and investment strategy are profound. We do not know how many of
these are in use already; the owner of such money-making machine may be reluctant
to publicise the fact. Conversely, if ABMs do not ultimately give better forecasts
than a random walk, then the ABM has instead illustrated how irrational agents can
nevertheless contribute to market pricing a result that would also be of considerable
interest albeit less lucrative.
It is less clear how other financial theories would need adapting. The Black-Scholes
model for option pricing does not rely on market efficiency. It does rely on being able
to trade continuously, without transaction costs, and on having accurate volatility
forecasts. These conditions do not fully hold in real markets, yet the Black-Scholes
and related models are still widely used. In our view, it is unlikely that the increasing
use of ABM would dent the use of Black-Scholes model, but it could well provide
new insights into the elements driving an appropriate choice of volatility parameter.
7.5. Adapting Modigliani and Miller
The work of Modigliani and Miller on capital structure has had a profound impact on
recent actuarial thought, particularly in pensions. The underlying arguments are based
on arbitrage and do not require markets to be efficient. However, to exploit the
arbitrage of a violation of Modigliani and Miller, would require an arbitrageur to take
offsetting long ands short positions in two shares with equal core businesses but
different capital structures or different pension plan investments. Such trades are in
practice impossible to execute, because companies do not come in such convenient
pairings. We can instead turn to equilibrium arguments to imply the same (M&M)
conclusions, but now we have introduced the additional hypothesis that economic
agents are trying to optimise something. Take away optimising agents, and the
arguments become much more delicate. Everything becomes very model dependent;
for example under Modiglinai and Miller (and excluding tax, bankruptcy or benefit
leaage) an extra 1000 pension fund contribution should have no effect on a
companys share price. The usual lesson taken from this argument is that optimal
contributions much therefore take account of tax, bankruptcy and leakage effects.
However, in an agent based model, we cannot easily unpick the effect of contributions
on share prices. ABM might suggest we need to know a great deal more in depth
about the investor community in order to recommend pension contribution rates.
7.6. Feedback Loops
Some ideas of market inefficiency are already embedded in regulatory thinking. If
markets are efficient, and prices reflect best information, then there can be little
market benefit from regulatory interference in trading volumes. If a regulator prevents
an institution from selling a risky asset, then the share price of the institution itself
falls, so the fall in aggregate value of the economys assets is unchanged by the
regulation. One could even argue that a regime discouraging fire sale of assets expose
policyholders or pension plan members to further risk, because in a default event it is
policyholders or plan members who have to scrape around the remaining assets to
recover some of their promised benefits.
Under agent based models, however, positive feedback loops may operate to
exacerbate the effect of crashes. Relaxation in solvency regulation, and corresponding
easing of the pressure on institutions to sell risky assets, could mitigate the market fall
itself. This increases aggregate economic wealth and reduces some of the refinancing
costs that otherwise might have applied. As calibration technology develops, we may
well see a day when ABM provides meaningful support to regulators searching for the
best way to protect plan members or policyholders in turbulent financial times.
References
Beinhocker, E (2007) The origin of wealth Business Books
Bonabeau, E (2002) Agent-based modelling: Methods and techniques for simulating
human systems Icosystems Corporation
Brealy, R and Myers, S (2007) Principles of corporate finance McGraw-Hill
Education
Copeland, T and Weston, F (2004) Financial theory and corporate policy (4th
Edition) Addison-Wesley
Exley, C Mehta, S and Smith A (1997) The financial theory of defined benefit pension
schemes British Actuarial Journal 3, IV 835-966
Fama, E and French, K (1992) The cross section of expected stock returns The journal
of finance Vol XLVII, No 2.
Farmer, D (2001) Toward agent-based models for investment Association for
Investment Management and Research
Holland, J (1998) Emergence Oxford University Press
Mandelbbrot, B and Hudson R (2006) The (mis)behaviour of markets Profile Books
Mandelbrot, B (1963) The variation of certain speculative prices The Journal of
Business, 36(4):394419
Mandelbrot, B (1967) The variation of some other speculative prices The Journal of
Business, 40(4):393413
Miller, J and Page, S (2007) Complex adaptive systems Princeton Paperbacks
Modigliani, F and Miller M (1958) The cost of capital, corporation finance and the
theory of investment American Economic Review, 48, 261-297
Palin, J (2002) Agent-based stockmarket models: calibration issues and applications
University of Sussex
Ralfe, J Speed, C and Palin, J (2003) Pension and capital structure: why hold equities
in the pension fund? Society of Actuaries
Sharpe, W Alexander, G and Bailey, J (1995) Investments Prentice Hall Fifth Edition
Sheldon, T and Smith, A (2004) Market consistent valuation of life assurance
business Institute of Actuaries
Taleb, N (2007) The black swan Random House
Varian, H (1999) Intermediate microeconomics Norton 5th Edition