<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/comparing-predictions-world-cup-scores/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.statworx.com/de/blog/data-science/comparing-predictions-world-cup-scores/"> r-bloggers – STATWORX</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>As many others too, me and some colleges at <a rel="nofollow" href="https://www.statworx.com/" target="_blank">STATWORX</a> took part in a little betting game for the World Cup 2018. Since the group stage is over, I was wondering how well – or better – how worse my prediction was. I am comparing my result with other predictions by using the point system of the betting game. All functions, code and data can be found at our <a rel="nofollow" href="https://github.com/STATWORX/blog/tree/master/WM2018" target="_blank">Github page</a>.</p>
<h2>Which prediction methods to use?</h2>
<p>Since I don't follow soccer at all but I like rolling dice, I thought to just randomly predict the result for each game. The follow up question was: How? Do I just predict the number of goals for each team and assume a goal's distribution? Do I use additional information like betting odds or FIFA ranking? Do I just lay back and watch some games?</p>
<p>At the end I decided to predict the result as a whole and not for each team. Since I didn't want to assume a distribution I used all past World Cups results and took a sample of 48 (the number of games in the group stage this time).</p>
<p>During my search for other prediction results I came across <a rel="nofollow" href="https://www.r-bloggers.com/another-prediction-for-the-fifa-world-cup-2018/" target="_blank">this blog post on R-bloggers</a> which was build on a talk by Claus Thorn Ekstrøm at the <a rel="nofollow" href="https://www.statworx.com/blog/statworx-on-tour-erum-2018/" target="_blank">eRum in May 2018</a>. His ideas can be found <a rel="nofollow" href="https://github.com/ekstroem/socceR2018" target="_blank">here</a> and were the foundation of the fuctions I used in my prediction.<br>
I also found <a rel="nofollow" href="http://fussballmathe.de/simulation/" target="_blank">this nice World Cup simulator</a> from a team at the Goethe-Universität Frankfurt. Here you can simulate the whole World Cup with all results.</p>
<p>So I had my own and some other methods for the prediction – all I was missing was data!</p>
<h2>How to get the data?</h2>
<h3>Historical data</h3>
<p>On the official FIFA website I found tables for all past World Cup result, which I could just copy into some textfiles and than search them for the results. I distinguished between a <code>0-1</code> and a <code>1-0</code> since there is an order in the betting game. The distribution of all historical group stage games looked like this:</p>
<p><img alt="score distribution" src="https://i0.wp.com/www.statworx.com/wp-content/uploads/score-distribution.png?w=450&ssl=1" class="wp-image-14495" data-recalc-dims="1"></p>
<h3>Scrapping the online simulation</h3>
<p>Here I would like to say thanks to my colleague Moritz, who worte a python script for me, that clicked the simulation button 100 times and copied it into an csv file. Also thanks to the guys from <a rel="nofollow" href="https://www.statworx.com/de/blog/data-science/comparing-predictions-world-cup-scores/fussballmathe.de" target="_blank">fussballmathe</a> for providing the online simulation tool.</p>
<p>To compare the simulation scores with the other ones, we had to make a few adjustments:</p>
<ul>
<li>the data had to be translated from german into englisch</li>
<li>the order of the games needed to be the same as the others (just as a convenience)</li>
<li>some of the scores were switched, so we transformed them form <code>A - B</code> to <code>B - A</code></li>
</ul>
<h3>Simulating the other methods</h3>
<p>As mentioned above, the main functions originated from Claus Thorn Ekstrøm. The <code>play_game</code> function he wrote uses three different method to predict the scores:</p>
<ol>
<li>Using two independant Poisson distributions, with no further information about the teams.</li>
<li>Using a Skellam distribution (difference of Poissons) when there is a restriction on the parameters based on the skill levels of the teams.</li>
<li>Using the <a rel="nofollow" href="https://www.eloratings.net/" target="_blank">ELO ratings</a> as additional information to predict the scores.</li>
</ol>
<p>Luckily, Ekstrøm provided data for these functions on his github page, so that I could just use them for the comparison. Furthermore, I added the historical and the other simulation to the <code>play_game</code> function.</p>
<p>For every method I simulated 100 World Cups to get an overview of which method may produce the best outcome. Now I had all the data and just needed to apply the point system of the betting game to compare the results.</p>
<h2>How does the point system work?</h2>
<p>To compare all the different prediction and evaluate them I used the point system of the betting game which got me into this problem at the first place. The system is quite simple, you get points depending on how good your bet was. If your bet was spot on, you get four points. If your goal difference was right, you still get three. If you at least had the same winner or also a draw you get two points. For everything else – well zero points!</p>
<figure>
<table>
<thead>
<tr>
<th> </th>
<th>trend</th>
<th>goal difference</th>
<th>result</th>
</tr>
</thead>
<tbody>
<tr>
<td>Victory</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>Draw</td>
<td>2</td>
<td>–</td>
<td>4</td>
</tr>
</tbody>
</table>
</figure>
<h2>Who did it the best?</h2>
<p>So all preparations were done and I just had to wait for the real scores to come in!</p>
<p>We can see, that there are some methods, which seems to have the same outcome:</p>
<ul>
<li>the historical data and the Poisson distribution</li>
<li>the Skellam distribution and fussballmathe's simulation</li>
</ul>
<p>The best method to predict the result seems to be the one based on the ELO ratings. This is not so surprising, since it used the most relevant information. </p>
<p><img alt="points for all models" src="https://i0.wp.com/www.statworx.com/wp-content/uploads/points-for-all-models.png?w=450&ssl=1" class="wp-image-14494" data-recalc-dims="1"></p>
<p>The last graph shows the result of all participants in the betting game. One could say, that expert knowledge is better than chance – but not always. <img alt="😉" src="https://s.w.org/images/core/emoji/2.4/72x72/1f609.png" class="wp-smiley"><br>
The red line represents the mean of the method and the two black lines show my bet and the points I got … well nearly. When I had to make the bet, I accidentally did not load the last three World Cups for the historical data. That's why my actual points are 34 and not 38. So yes, I came in dead last – but with honor and my head held hight!</p>
<p>But whatever result we were predicting – let's enjoy the final round of this year’s World Cup!</p>
<div>
<h6>Über den Autor</h6>
<p><img src="https://i1.wp.com/www.statworx.com/wp-content/uploads/jakob-1-300x300.jpg?resize=180%2C180&ssl=1" width="180" alt="Jakob Gepp" class="wp-user-avatar wp-user-avatar-180" data-recalc-dims="1" height="180"></p>
<div>
<h4>Jakob Gepp</h4>
<p>Jakob ist im Statistik Team und interessiert sich im Moment stark für Hadoop und Big Data. In seiner Freizeit bastelt er gerne an alten Elektrogeräten und spielt Hockey.</p>
</div>
</div>
<p>Der Beitrag <a rel="nofollow" href="https://www.statworx.com/de/blog/data-science/comparing-predictions-world-cup-scores/" target="_blank">Comparing predictions: World Cup scores</a> erschien zuerst auf <a rel="nofollow" href="https://www.statworx.com/de/" target="_blank">STATWORX</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.statworx.com/de/blog/data-science/comparing-predictions-world-cup-scores/"> r-bloggers – STATWORX</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/zNKgWg4YcpY" height="1"></a></div>