An Agent Based Model for Election Buffs

Michael Laver of New York University has written a truly geek-tastic computer program in NetLogo that invites you to experiment with the 2012 US presidential election campaign, using the agent-based model of party competition set out in his new book cowritten with Ernest Sergenti, Party Competition: An Agent Based Model.

  • Does increasing voter alienation keep the two candidates apart in the presidential election as they fear alienating their “base”?
  • Does increasing the number of independents in the primaries help Romney?
  • What happens if Ron Paul becomes a rampant vote seeker who doesn’t care at all about policy?

Experiment with the sliders to see how they affect the result. For those who want to get technical, roll up your sleeves and reprogram the model, or use NetLogo’s built-in “Behavior Space “ feature to have 1000 reruns of the presidential election under subtly different conditions. Fun stuff!

Check out the details after the jump.

Download the code for this model here: Presidential Election Model from Michael Laver (this is a zipped .nlogo file)



Presidential Election Model

Michael Laver



The election has two phases. First, there is a primary contest between the four Republican challengers still standing on 1 February 2012. Second, the winner of the Republican primary fights a general election against Democratic incumbent President Barack Obama.

CANDIDATES in each election compete with each other by setting out the policy positions they hope will appeal to as many voters as possible. Different VOTERS have preferences for different policy positions and are divided into three distinct groups: Republicans, Democrats, and Independents.

Voting in the primary is confined to Republicans plus a proportion of the Independents that can be set by the user. Obviously, all three groups of voters may vote in the general election. A successful Republican challenger must first set policy positions that win the primary, then must set policy positions that win the general election.

The winning candidate at the end of the general election is the one with the most popular votes – there is no electoral college to contend with.



Key policy positions in the election, both for voters and for candidates, are described using two dimensions of ideology.  The horizontal dimension describes economic policy positions on a left-right scale; the vertical dimension liberal vs conservative positions on “social” issues such as abortion and gay rights.

VOTERS in each group (Democrats, Republicans, Independent) tend to have distinctive distributions of opinion on these important matters. Each group of voters is characterized by: its size relative to the other two groups; the policy preferences if its average member; the diversity of opinion within the group.

These key population parameters all have default values that you see in the “Population Designer” panel on the interface when you fire up the program. You can change any of these using the sliders to design a voting population you find more realistic or interesting.  Indeed one thing you should definitely explore is the effect of different assumptions about, to take just one example, how left- or right-wing are the views of typical Republican voters on economic policy.

You can set the proportion of Independents voting in the Republican primary using the “indeps-in-primary” slider on the interface. This is something else to play with.

CANDIDATES, as we have seen, compete with each other by offering policies to potential supporters – so we expect their policy positions to change over the course of the election. The default starting policy position of each candidate can be seen on the interface, but you can change these using the sliders to any setting you find realistic and/or interesting.  This is something else you should definitely play with.

CANDIDATES use one of two decision rules to choose which policy position to offer voters. Some candidates never change policy position no matter how few votes this attracts; their main objective is to state their case. They are using what the model calls a Sticker rule. Other candidates continuously adapt their policy positions in search of more votes; their main objective is to win the election, whatever policy will help them do this. They are using what the model calls a Hunter rule. The decision rule used by each candidate also has a default setting, but you can also change this on the interface to play with the effect of different candidates different decision rules. (For example you might decide that the incumbent President is “stuck” with his record in office and cannot change position at all, in the eyes of voters, during an election campaign.

VOTER ALIENATION.  Many people do not vote. There are many reasons for this, but the model lumps all of these together under the heading “voter alienation”.  The electorate is divided into some who are so “alienated” they do not vote, and others who do indeed vote. Electors become alienated if there is no candidate with a policy position “close enough” to them in the election – where “close enough” is a parameter set using the “voter-alienation” slider on the interface. This has a default value, but you can slide it to any value you find interesting or realistic, and once more are encouraged to play with this. Alienated voters are colored brown on the interface; the shading of other areas reflects the density of voters with ideal policies in the area in question; white-hot areas have the most voters.



SETUP sets up candidates, supporters and system parameters as specified above.

GO starts the simulation using current parameters. It first runs a 100-day primary, waits a couple seconds for you to look at the result of the primary and get over the excitement, then kills off the losing primary candidates and runs a general election.



Experiment with the sliders to see how they affect the result as described above, or use NetLogo’s built-in “Behavior Space “ feature to have 1000 reruns of the presidential election under subtly different conditions.



Download the model here: Presidential Election Model from Michael Laver (this is a zipped .nlogo file)

As with all the models in the Laver-Sergenti book, this model is programmed in Netogo. To run it you will need to download and install the excellent NetLogo agent-based modeling environment. This is free for personal use from:

You can run the model with defaults simply by hitting “setup” and then “go” but the point is obviously to play with the effects of  the various parameters set by sliders in the interface.

There is a brief description of everything, mostly repeating what is set out above, on the “information” tab. The model’s code, should you want to play with this, is on the “procedures