<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/a-bayesian-election-prediction-implemented-with-r-and-stan/"></div></div><div><a data-url="https://www.r-bloggers.com/a-bayesian-election-prediction-implemented-with-r-and-stan/" data-counturl="https://www.r-bloggers.com/a-bayesian-election-prediction-implemented-with-r-and-stan/" data-count="horizontal" data-text="A Bayesian election prediction, implemented with R and Stan" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2016/11/a-bayesian-election-forecast.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>If the media coverage is anything to go by, people are desperate to know who will win the US election on November 8. Polls give us some indication of what's likely to happen, but any single poll isn't a great guide (despite the hype that accompanies some of them). One poll is subject to any number of possible errors, statistical and otherwise: the sample, the methodology, the analysis, or even deliberate bias.</p>
<p>But put a whole bunch of polls together, and you can assemble a more realistic picture of the likely outcome, and the uncertainty associated with it. That's what poll aggregators like <a target="_blank" rel="nofollow" href="http://blog.revolutionanalytics.com/2016/07/data-journalism-with-r-at-538.html">FiveThirtyEight</a> do: take state and national polls, etimate pollster biases and correlations between states, incorporate other influential variables (like economic data) and build a statistical model to forecast the number of electoral college seats won by each candidate (which in US elections, is pretty much the only thing that matters). FiveThirtyEight's <a target="_blank" rel="nofollow" href="http://fivethirtyeight.com/features/a-users-guide-to-fivethirtyeights-2016-general-election-forecast/">methodology</a> is a sound one, and has been largely successful at predicting elections, but the actual details of the process they use is secret, and is thus itself subject to accusations (unfounded, IMO) of bias.</p>
<p>A new <a target="_blank" rel="nofollow" href="http://www.slate.com/features/pkremp_forecast/report.html">election forecast by Pierre-Antoine Kremp</a>, uses a similar (but Bayesian) process to predict the election, and all of the methodology is transparent and open. The forecast is implemented in the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/documents/what-is-r/">R programming language</a> and <a target="_blank" rel="nofollow" href="http://blog.revolutionanalytics.com/2012/08/rstan-fast-multilevel-bayesian-modeling-in-r.html">Stan</a>, the Bayesian computation engine. (The new model was <a target="_blank" rel="nofollow" href="http://www.slate.com/articles/technology/future_tense/2016/11/the_polls_of_the_future_will_be_reproducible_and_open_source.html">introduced by Stan author Andrew Gelman on Slate</a>, which hosts its forecasts.) All of the data, code and the generated report are <a target="_blank" rel="nofollow" href="https://github.com/pkremp/polls">available to inspect on GitHub</a>, and the statistical methodology is included with every forecast (scroll down to the <a target="_blank" rel="nofollow" href="https://rawgit.com/pkremp/polls/master/report.html#Model">Model section</a>). The model itself is based on the <a target="_blank" rel="nofollow" href="http://blog.revolutionanalytics.com/2013/01/forecasting-presidential-elections-with-r.html">Votamatic model by Drew Linzer</a>, which was very successful at predicting the 2012 election. As of this writing on November 2, the model predicts a win by Hillary Clinton with a probability of 88%. (FiveThirtyEight's polls-only forecast gives her a 69.9% chance.)</p>
<p>One interesting chart included in the report is the state-by-state probabilities of winning. Nothing shows how divided this country is than how few states are actually competitive at all:</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb094e6845970d-pi"><img title="States" alt="States" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb094e6845970d-800wi" border="0"></a></p>
<p>To check out the latest forecast from Kremp's model, follow the link below.</p>
<p>Slate: <a target="_blank" rel="nofollow" href="http://www.slate.com/features/pkremp_forecast/report.html">State and National Poll Aggregation</a></p>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/a-bayesian-election-prediction-implemented-with-r-and-stan/"></div></div><div><a data-url="https://www.r-bloggers.com/a-bayesian-election-prediction-implemented-with-r-and-stan/" data-counturl="https://www.r-bloggers.com/a-bayesian-election-prediction-implemented-with-r-and-stan/" data-count="vertical" data-text="A Bayesian election prediction, implemented with R and Stan" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2016/11/a-bayesian-election-forecast.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/Htpj6Pbu0hc"></a></div>