Forecasting elections---a challenging, high-stakes problem---is the subject of much uncertainty, subjectivity, and media scrutiny. To shed light on this process, we develop a method for forecasting elections from the perspective of dynamical systems. Our model borrows ideas from epidemiology, and we use polling data from United States elections to determine its parameters. Surprisingly, our model performs as well as popular forecasters for the 2012 and 2016 U.S. presidential, senatorial, and gubernatorial races. Although contagion and voting dynamics differ, our work suggests a valuable approach for elucidating how elections are related across states. It also illustrates the effect of accounting for uncertainty in different ways, provides an example of data-driven forecasting using dynamical systems, and suggests avenues for future research on political elections. We conclude with our forecasts for the senatorial and gubernatorial races on 6 November 2018 (which we posted on 5 November 2018).


  1. elections
  2. compartmental modeling
  3. polling data
  4. forecasting
  5. complex systems

MSC codes

  1. 34F05
  2. 37N99
  3. 60G10
  4. 91D10

Formats available

You can view the full content in the following formats:

Supplementary Material

Index of Supplementary Materials

Title of paper: Forecasting Elections using Compartmental Models of Infection

Authors: A. Volkening, D. F. Linder, M. A. Porter, and G. A. Rempala

File: SupplementaryText.pdf

Type: PDF

Contents: In section SM1 of the supplementary text, we include our original forecasts of the 2018 midterms that we posted on arXiv on 5 November 2018, prior to the elections. As noted in the main manuscript, after the election rush, we were able to use a smaller time step for our simulations. We also found a few data-handling errors in our original forecasts and we corrected these errors in the forecasts that we include in the main manuscript (importantly, our original forecasts and those in the main manuscript project the same candidates to win each race). We also provide a table (Table SM1) that summarizes our model treatment of each state race by election and year. In section SM2 of the supplementary text, we discuss alternative methods for judging forecast accuracy. In section SM3 of the supplementary text, we provide illustrations of our transmission and recovery parameters for the 2018 Senate election as examples; we also provide captions summarizing the code and data files that we include as supplementary materials.

File: datafile_Code_and_Demos.zip

Type: compressed file

Contents: This zipped folder contains all of the code that we developed to fit model parameters and simulate the model, as well as instructions for reproducing all of the quantitative measurements that we presented in the figures and tables in the main manuscript. In the zipped folder, the file readme.txt provides further details and instructions. In particular, the folder has 13 Excel documents with polling data that we collected for 2012, 2016, and 2018 from HuffPost Pollster (through the HuffPost Pollster API v2) and RealClearPolitics, as well as the demographic data from the U.S. Census Bureau and 247WallSt.com that we used to correlate state outcomes in our 2018 forecasts. We provide 3 main code files: (1) formattingPollData.m formats the poll data (averaging polls by month and combining state data into superstate data when appropriate); (2) parameterFitting.R fits parameters using the formatted poll data; and (3) electionModel.m simulates our models. For reproducibility, we also include code (reproduceTablesFigures.m) that produces all of the quantitative measurements in the manuscript and a text file (reproduceDataFiguresTables.txt) with instructions on how to use this code. Lastly, demo.txt and the subfolder DemoFiles provide details on how to run short code demonstrations and verify the output.

File: datafile_ModelParameters.xlsx

Type: Excel document

Contents: This is an Excel file with the the model parameters that we use in our final forecasts for the 2012, 2016, and 2018 races. We fit the parameters to polling data that we obtained from HuffPost Pollster (through the HuffPost Pollster API v2) and RealClearPolitics. Each page in the Excel worksheet has the parameters for a different election forecast. The pages appear in the following order: 2012 governor, 2012 Senate, 2012 president, 2016 governor, 2016 Senate, 2016 president, 2018 governor, and 2018 Senate. On a given page, each column has the transmission and turnover (i.e., loss) parameters for the indicated state. In all cases, the column first gives the parameters for Republican transmission, then gives the parameters for Democrat transmission, and finally gives the Republican and Democrat turnover parameters.


Election 2012 Senate Map, The New York Times, 2012, https://www.nytimes.com/elections/2012/results/senate.html (accessed 03-11-2018).
Estimates of the Voting Age Population for 2012. A Notice by the Commerce Department on 1/30/2013. Agency: Office of the Secretary, Commerce, Report 78 FR 6289, Federal Register Notices, 2013.
Annual Estimates of the Resident Population by Sex, Race, and Hispanic Origin for the United States, States, and Counties: April 1, 2010 to July 1, 2016, U.S. Census Bureau, Population Division, 2017, https://factfinder.census.gov/faces/tableservices/jsf/pages/productview.xhtml?pid=PEP_2015_PEPSR6H&prodType=table (accessed 22-01-2018).
Estimates of the Voting Age Population for 2016. A Notice by the Commerce Department on 1/30/2017. Agency: Office of the Secretary, Commerce, Report 82 FR 8720, Federal Register Notices, 2017.
2018 Midterm Election Results, The New York Times, 2018, https://www.nytimes.com/interactive/2018/us/elections/calendar-primary-results.html (last accessed 26-02-2019).
270toWin, https://www.270towin.com (last accessed 03-11-2018).
Estimates of the Voting Age Population for 2017. A Notice by the Commerce Department on 2/20/2018. Agency: Office of the Secretary, Commerce, Report 83 FR 7142, Federal Register Notices, 2018.
HuffPost Pollster, The Huffington Post, https://elections.huffingtonpost.com/pollster (last accessed 02-11-2018).
HuffPost Pollster API v2, The Huffington Post, https://elections.huffingtonpost.com/pollster/api/v2; data provided under a CC BY-NC-SA 3.0 license (https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US) (last accessed 02-11-2018).
RealClearPolitics: Polls, https://www.realclearpolitics.com/epolls/latest_polls/elections/ (last accessed 22-12-2018).
The Cook Political Report: Ratings, https://www.cookpolitical.com/ratings (accessed 03-11-2018).
Ballotpedia, https://ballotpedia.org/Main_Page (accessed 26-02-2019).
Annual Estimates of the Resident Population by Sex, Race, and Hispanic Origin: April 1, 2010 to July 1, 2019, U.S. Census Bureau, Population Division, 2020, https://www.census.gov/data/tables/time-series/demo/popest/2010s-state-detail.html\#par_textimage_673542126 (accessed 09-08-2020).
A. I. Abramowitz, Will time for change mean time for Trump?, PS: Political Sci. Politics, 49 (2016), pp. 659--660.
L. J. S. Allen, M. Langlais, and C. J. Phillips, The dynamics of two viral infections in a single host population with applications to hantavirus, Math. Biosci., 186 (2003), pp. 191--217.
S. Almukhtar, M. Andre, W. Andrews, M. Bloch, J. Bowers, L. Buchanan, N. Cohn, A. Coote, A. Daniel, T. Fehr, S. Jacoby, J. Katz, J. Keller, A. Krolik, J. C. Lee, R. Lieberman, B. Migliozzi, P. Murray, K. Quealy, J. Patel, A. Pearce, R. Shorey, M. Strickland, R. Taylor, I. White, M. Whitely, and J. Williams, Live Forecast: Who Will Win the Senate?, The New York Times, 2018, https://www.nytimes.com/interactive/2018/11/06/us/elections/results-senate-forecast.html (last accessed 06-10-2018).
L. M. A. Bettencourt, A. Cintrón-Arias, D. I. Kaiser, and C. Castillo-Chavéz, The power of a good idea: Quantitative modeling of the spread of ideas from epidemiological models, Phys. A, 364 (2006), pp. 513--536.
L. Bonnasse-Gahot, H. Berestycki, M.-A. Depuiset, M. B. Gordon, S. Roché, N. Rodriguez, and J.-P. Nadal, Epidemiological modelling of the 2005 French riots: A spreading wave and the role of contagion, Sci. Rep., 8 (2018), art. 107.
L. Bottcher, H. J. Herrmann, and H. Gersbach, Clout, activists and budget: The road to presidency, PLoS ONE, 13 (2018), art. e0193199.
D. Braha and M. A. M. de Aguiar, Voting contagion: Modeling and analysis of a century of U.S. presidential elections, PLoS ONE, 12 (2017), art. e0177970.
R. Brauer and C. Castillo-Chavez, Mathematical Models in Population Biology and Epidemiology, 2nd ed., Texts Appl. Math., Springer, Heidelberg, Germany, 2012.
S. Busenberg and C. Castillo-Chavez, A general solution of the problem of mixing of subpopulations and its application to risk- and age-structured epidemic models for the spread of AIDS, Math. Med. Biol., 8 (1991), pp. 1--29.
R. H. Byrd, P. Lu, J. Nocedal, and C. Zhu, A limited memory algorithm for bound constrained optimization, SIAM J. Sci. Comput., 16 (1995), pp. 1190--1208, https://doi.org/10.1137/0916069.
J. E. Campbell, Polls and votes: The trial-heat presidential election forecasting model, certainty, and political campaigns, Amer. Politics Res., 24 (1996), pp. 408--433.
C. Castellano, S. Fortunato, and V. Loreto, Statistical physics of social dynamics, Rev. Modern Phys., 81 (2009), pp. 591--646.
S. Chian, W. L. He, C. M. Lee, D. F. Linder, M. A. Porter, G. A. Rempala, and A. Volkening, 2020 U.S. Election Forecasts with a Compartmental Model, https://modelingelectiondynamics.gitlab.io/2020-forecasts/.
B. J. Coburn, B. G. Wagner, and S. Blower, Modeling influenza epidemics and pandemics: Insights into the future of swine flu (H1N1), BMC Med., 7 (2009), art. 30.
N. Cohen, Volume 24: The 2018 Election, Who Projected It Best?, https://www.lobbyseven.com/single-post/2018/12/17/Volume-24-The-2018-Election-Who-Projected-It-Best (accessed 22-12-2018).
E. Comen, T. C. Frohlich, and M. B. Sauter, America's Most and Least Educated States: A Survey of All 50, https://247wallst.com/special-report/2016/09/16/americas-most-and-least-educated-states-a-survey-of-all-50/2/ (last accessed 02-11-2018).
O. Diekmann and J. A. P. Heesterbeek, Mathematical Epidemiology of Infectious Diseases: Model Building, Analysis and Interpretation, John Wiley & Sons, New York, 2000.
A. Emamadjomeh and D. Lauter, Where the Presidential Race Stands Today, USC Dornsife/Los Angeles Times Daybreak Poll, 2016, http://graphics.latimes.com/usc-presidential-poll-dashboard/ (accessed 19-09-2018).
R. Epstein and R. E. Robertson, The search engine manipulation effect (SEME) and its possible impact on the outcomes of elections, Proc. Natl. Acad. Sci. USA, 112 (2015), art. e4512.
J. Fernández-Gracia, K. Suchecki, J. J. Ramasco, M. San Miguel, and V. M. Eguiluz, Is the voter model a model for voters?, Phys. Rev. Lett., 112 (2014), art. 158701.
S. Galam, The dynamics of minority opinions in democratic debate, Phys. A, 336 (2004), pp. 56--62.
S. Galam, The Trump phenomenon: An explanation from sociophysics, Internat. J. Modern Phys. B, 31 (2017), art. 1742015.
S. Galam, Unavowed abstention can overturn poll predictions, Frontiers Phys., 6 (2018), art. 24.
A. Gelman and G. King, Why are American presidential election campaign polls so variable when votes are so predictable?, British J. Political Sci., 23 (1993), pp. 409--451.
N. L. Gonzales, L. Askarinam, R. Matsumoto, R. Yoon, and S. Rothenberg, Inside Elections with Nathan L. Gonzales, Nonpartisan Analysis: Year Archive: 2018, https://insideelections.com/archive/year/2018 (last accessed 27-12-2018).
H. W. Hethcote, The mathematics of infectious diseases, SIAM Rev., 42 (2000), pp. 599--653, https://doi.org/10.1137/S0036144500371907.
D. J. Higham, An algorithmic introduction to numerical simulation of stochastic differential equations, SIAM Rev., 43 (2001), pp. 525--546, https://doi.org/10.1137/S0036144500378302.
P. Hummel and D. Rothschild, Fundamental models for forecasting elections at the state level, Elect. Stud., 35 (2014), pp. 123--139.
S. Jackman, Pooling the polls over an election campaign, Aust. J. Political Sci., 40 (2005), pp. 499--517.
N. Jackson and A. Hooper, Huffington Post Election 2016 Forecast: President, The Huffington Post, 2016, http://elections.huffingtonpost.com/2016/forecast/president (accessed 31-10-2018).
W. Jennings and C. Wlezien, Election polling errors across time and space, Nat. Hum. Behav., 2 (2018), pp. 276--283.
W. O. Kermack and A. G. McKendrick, A contribution to the mathematical theory of epidemics, Proc. R. Soc. London, 115 (1927), pp. 700--721.
W. O. Kermack and A. G. McKendrick, Contributions to the mathematical theory of epidemics. II. The problem of endemicity, Proc. R. Soc. London, 138 (1932), pp. 55--83.
W. O. Kermack and A. G. McKendrick, Contributions to the mathematical theory of epidemics. III. Further studies of the problem of endemicity, Proc. R. Soc. London, 141 (1933), pp. 94--122.
I. Z. Kiss, J. C. Miller, and P. L. Simon, Mathematics of Epidemics on Networks: From Exact to Approximate Models, Springer, Cham, Switzerland, 2017.
C. Klarner, Forecasting the 2008 U.S. House, Senate and presidential elections at the district and state level, PS: Political Sci. Politics, 41 (2008), pp. 723--728.
B. E. Lauderdale and D. Linzer, Under-performing, over-performing, or just performing? The limitations of fundamentals-based presidential election forecasting, Int. J. Forecast, 31 (2015), pp. 965--979.
K. Law, A. Stuart, and K. Zygalakis, Data Assimilation: A Mathematical Introduction, Texts Appl. Math. 63, Springer, Cham, Switzerland, 2015.
S. Lehmann and Y.-Y. Ahn, Complex Spreading Phenomena in Social Systems: Influence and Contagion in Real-World Social Networks, Springer, Cham, Switzerland, 2018.
D. Leip, Dave Leip's Atlas of U.S. Presidential Elections, http://uselectionatlas.org (accessed 26-02-2019).
M. S. Lewis-Beck, Election forecasting: Principles and practice, British J. Politics Int. Relat., 7 (2005), pp. 145--164.
D. A. Linzer, Dynamic Bayesian forecasting of presidential elections in the States, J. Amer. Stat. Assoc., 108 (2013), pp. 124--134.
S. A. Marvel, H. Hong, A. Papush, and S. H. Strogatz, Encouraging moderation: Clues from a simple model of ideological conflict, Phys. Rev. Lett., 109 (2012), art. 118702.
R. K. McCormack and L. J. S. Allen, Multi-patch deterministic and stochastic models for wildlife diseases, J. Biol. Dyn., 1 (2007), pp. 63--85.
L. A. Meyers, B. Pourbohloul, M. E. J. Newman, D. M. Skowronski, and R. C. Brunham, Network theory and SARS: Predicting outbreak diversity, J. Theoret. Biol., 232 (2005), pp. 71--81.
M. E. J. Newman, Networks, 2nd ed., Oxford University Press, Oxford, UK, 2018.
R. Pastor-Satorras, C. Castellano, P. Van Mieghem, and A. Vespignani, Epidemic processes in complex networks, Rev. Modern Phys., 87 (2015), pp. 925--979.
V. Pons, Will a five-minute discussion change your mind? A countrywide experiment on voter choice in France, Amer. Econ. Rev., 108 (2018), pp. 1322--1363.
M. A. Porter and J. P. Gleeson, Dynamical Systems on Networks: A Tutorial, Front. Appl. Dyn. Syst. Rev. Tutor. 4, Springer, Cham, Switzerland, 2016.
C. Prosser and J. Mellon, The twilight of the polls? A review of trends in polling accuracy and the causes of polling misses, Gov. Oppos., 53 (2018), pp. 757--709.
R Core Team, R: A Language and Environment for Statistical Computing, R Foundation for Statistical Computing, Vienna, Austria, 2018.
G. A. Rempala, Least squares estimation in stochastic biochemical networks, Bull. Math. Biol., 74 (2012), pp. 1938--1955.
A. Ripley, R. Tenjarla, and A. Y. He, The Geography of Partisan Prejudice, The Atlantic, 2019, https://www.theatlantic.com/politics/archive/2019/03/us-counties-vary-their-degree-partisan-prejudice/583072/ (accessed 14-03-2019).
L. J. Sabato and K. Kondik, Sabato's Crystal Ball, http://crystalball.centerforpolitics.org/crystalball/ (accessed 19-09-2018).
L. J. Sabato and K. Kondik, Sabato's Crystal Ball: 2018 Governor, http://www.centerforpolitics.org/crystalball/2018-governor/ (last accessed 22-12-2018).
L. J. Sabato and K. Kondik, Sabato's Crystal Ball: 2018 Senate, http://www.centerforpolitics.org/crystalball/2018-senate/ (last accessed 04-11-2018).
L. J. Sabato, K. Kondik, and G. Skelley, Sabato's Crystal Ball: Projection: Obama Will Likely Win Second Term, http://crystalball.centerforpolitics.org/crystalball/articles/projection-obama-will-likely-win-second-term/ (last accessed 03-11-2018).
J. Schleuss, J. Fox, and P. Krishnakumar, California 2016 Election Precinct Maps, https://github.com/datadesk/california-2016-election-precinct-maps (accessed 14-03-2019).
C. R. Shalizi and A. C. Thomas, Homophily and contagion are generically confounded in observational social network studies, Sociol. Methods Res., 40 (2011), pp. 211--239.
N. Silver, The Signal and the Noise: Why So Many Predictions Fail---But Some Don't, Penguin Press, New York, 2012.
N. Silver, FiveThirtyEight: A User's Guide to FiveThirtyEight's 2016 General Election Forecast, https://fivethirtyeight.com/features/a-users-guide-to-fivethirtyeights-2016-general-election-forecast/ (accessed 31-10-2018).
N. Silver, FiveThirtyEight: Politics. The Odds of an Electoral College-Popular Vote Split Are Increasing, https://fivethirtyeight.com/features/the-odds-of-an-electoral-college-popular-vote-split-are-increasing/ (accessed 02-11-2018).
N. Silver, FiveThirtyEight: How FiveThirtyEight's House, Senate and Governor Models Work, https://fivethirtyeight.com/methodology/how-fivethirtyeights-house-and-senate-models-work/ (last accessed 26-02-2019).
N. Silver, J. Boice, E. Brillhart, A. Bycoffe, R. Dottle, L. Eastridge, R. King, E. Koeze, A. Scheinkman, G. Wezerek, J. Wolfe, D. Dienhart, A. Jones-Rooy, D. Mehta, M. Nguyen, N. Rakich, D. Shan, and G. Skelley, FiveThirtyEight: Election 2018, https://projects.fivethirtyeight.com/2018-midterm-election-forecast/ (last accessed 20-12-2018).
N. Silver, A. Jones-Rooy, and D. Mehta, FiveThirtyEight: FiveThirtyEight's Pollster Ratings, Based on the Historical Accuracy and Methodology of Each Firm's Polls, https://projects.fivethirtyeight.com/pollster-ratings/.
N. Silver, J. Kanjana, D. Mehta, J. Boice, A Bycoffe, M. Conlen, R. Fischer-Baum, R. King, E. Koeze, A. McCann, A. Scheinkman, and G. Wezerek, FiveThirtyEight: 2016 Election Forecast. Who Will Win the Presidency?, https://projects.fivethirtyeight.com/2016-election-forecast/ (last accessed 02-11-2018).
A. Topîrceanu, Electoral Forecasting Using a Novel Temporal Attenuation Model: Predicting the US Presidential Elections, preprint, https://arxiv.org/abs/2005.01799, 2020.
A. Volkening, D. F. Linder, M. A. Porter, and G. A. Rempala, Forecasting Elections Using Compartmental Models of Infections, preprint, https://arxiv.org/abs/1811.01831v1, 2018.
A. Volkening, D. F. Linder, M. A. Porter, and G. A. Rempala, Forecasting Elections Using Compartmental Models, https://gitlab.com/alexandriavolkening/forecasting-elections-using-compartmental-models/-/tree/master/Original%20Programs.
N. Wang, Y. Fu, H. Zhang, and H. Shi, An evaluation of mathematical models for the outbreak of COVID-19, Precis. Clin. Med., 3 (2020), pp. 85--93.
S. S.-H. Wang, Origins of Presidential poll aggregation: A perspective from 2004 to 2012, Int. J. Forecast., 31 (2015), pp. 898--909.
W. Wang, D. Rothschild, S. Goel, and A. Gelman, Forecasting elections with non-representative polls, Int. J. Forecast., 31 (2015), pp. 980--991.
D. J. Watts, R. Muhamad, D. C. Medina, and P. S. Dodds, Multiscale, resurgent epidemics in a hierarchical metapopulation model, Proc. Natl. Acad. Sci. USA, 102 (2005), pp. 11157--11162.
C. Wlezien and R. S. Erikson, The timeline of presidential election campaigns, J. Politics, 64 (2002), pp. 969--993.
J. Zittrain, Engineering an election. Digital gerrymandering poses a threat to democracy, Harvard Law Rev. Forum, 8 (2014), pp. 335--341.

Information & Authors


Published In

cover image SIAM Review
SIAM Review
Pages: 837 - 865
ISSN (online): 1095-7200


Submitted: 16 December 2019
Accepted: 24 August 2020
Published online: 3 November 2020


  1. elections
  2. compartmental modeling
  3. polling data
  4. forecasting
  5. complex systems

MSC codes

  1. 34F05
  2. 37N99
  3. 60G10
  4. 91D10



Funding Information

National Science Foundation https://doi.org/10.13039/100000001 : DMS-1440386, DMS-1853587, DMS-1764421

Funding Information

Simons Foundation https://doi.org/10.13039/100000893 : 597491-RWC

Metrics & Citations



If you have the appropriate software installed, you can download article citation data to the citation manager of your choice. Simply select your manager software from the list below and click Download.

Cited By

There are no citations for this item

View Options

View options


View PDF

Get Access







Copy the content Link

Share with email

Email a colleague

Share on social media