Small Case Study: Comparing Supercoach and AFL Fantasy Scores

Aim: Compare the differences between Supercoach and AFL Fantasy scores through a single season of data

What are these scores?

Supercoach:

AFL Supercoach is a fantasy footy game where you get to assemble your dream team of Aussie Rules superstars. With a salary cap, just like the AFL, you’ll strategise and pick the best players from the 18 teams to create a powerhouse squad. Each week, you’ll earn points based on your players’ on-field performances. Team alterations may need to be made during the season if a player becomes injured, gets suspended, or has a constant decline in form, therefore, impacting their score!

The AFL Supercoach score is a weighted sum that is made up of different actions, for each good and poor play on an AFL field, if a player kicks a goal, that will add to their score. But, if a player gives away a free kick, their score will have reduced. This is calculated from a wide range of statistics, with each having their own worth. It is the coach’s (you) job to make sure their Supercoach team is optimised to have a range of high grade players, along with other talented players.

AFL Fantasy:

In a very similar aspect to the way that AFL Supercoach is conducted, the AFL Fantasy is the AFL’s very own fantasy league system. They too see users assemble a team within a salary cap, with players earning points for actions like kicks, handballs, goals, marks, tackles, and more. And just like Supercoach, the aim is to build up as many points as possible per round, to beat your opponent for that round of AFL football.

However, it should be noted that these two fantasy leagues are not the same, and sometimes they can give different results due to their different formulas to return a rating score.

To get yourself started with this small comparison between Supercoach and AFL Fantasy, install some small packages:

#install.packages("tidyverse")
#install.packages("fitzRoy")
#install.packages("ggpubr")
#install.packages("gridExtra")

library(tidyverse)
library(fitzRoy)
library(ggpubr)
library(gridExtra)

Note to get rid of the ‘#’ before installing the packages, if you do not have them installed already!

Using fitzRoy

fitzRoy is a very popular package among the AFL analyst community that is able to efficiently scrape AFL data from a wide number of sources. You are able to pull player information, match stats, player stats, ladders, and more with a single line of code, from any recent season you want.

The data pulled below shows that the fitzRoy package is fetching player stats, from the 2018 season, from all rounds, and taking the data from the ‘fryzigg’ source. This pulls in a large amount of data, we will then filter out everything we don’t need for this small analysis and only select the match_id, and the Supercoach and AFL Fantasy scores.

data <- fetch_player_stats(2018, round_number = 1:24, source = "fryzigg")


rating_scores <- data %>% 
  select(match_id, supercoach_score, afl_fantasy_score)

Quick peak at the data

The base R ‘head’ function can allow you to quickly view the first 6 rows of the data, and if you wanted to, ‘tail’ can allow you to see the last 6 rows of the data.

head(rating_scores)
## # A tibble: 6 × 3
##   match_id supercoach_score afl_fantasy_score
##      <int>            <int>             <int>
## 1    15201              150               129
## 2    15201               61                68
## 3    15201               73                74
## 4    15201               79                62
## 5    15201              101               100
## 6    15201               45                59

Creating Histograms

Histograms can be made using the ggplot2 package, or base R functions too, for this example, we will be using ggplot2. The newly named ‘rating scores’ can be piped into the ggplot functions using ‘ctrl + shift + m’ to create the %>% sign. The x axis is set to be Supercoach, and then another plot will be made simultaneously where the x axis is set to AFL Fantasy. A histogram will be used since the data is a single set of numeric values. Additional colour can be added for aesthetics which matches the colour of the base fantasy score’s branding. And finally, they are saved to different names so they can be plotted side-by-side later on.

fantasy_hist <- rating_scores %>% 
  ggplot(aes(x = supercoach_score)) +
  geom_histogram(col = 'darkgrey', fill = 'lightblue') +
  labs(x = 'AFL Fantasy Score',
       title = 'Distribution of AFL Fantasy Across the 2018 Season')

super_coach_hist <- rating_scores %>% 
  ggplot(aes(x = afl_fantasy_score)) +
  geom_histogram(col = 'darkgrey', fill = 'green4') +
  labs(x = 'Supercoach Score',
       title = 'Distribution of Supercoach Score Across the 2018 Season')

Plotting Charts Together

Another small package used here, it is the ‘gridExtra’, this has a small function that will be used to simple put the two plots next to each other. Here we have used the ‘grid.arrange’ function to place our two charts side by side for comparison.

grid.arrange(fantasy_hist, super_coach_hist)

When comparing the two distributions of the AFL Fantasy and Supercoach scores, it is very clear that they are very similar in terms of count, both minimum and maximum values, along with very similar distributions. From this, we can tell that both metrics must measure the same AFL performance relatively similarly and accurately.

One more final plot can still be made to look how the two scores directly correlate.

Final correlation plot

The last plot to look at in this small study comparing the Supercoach and AFL Fantasy ratings is to make a small correlation plot. The same idea will be used as before, piping the data into a ggplot, only this time, a geom_point will be used where the x axis will have Supercoach Score, and the y axis will have AFL Fantasy Score. The alpha has been set to 0.1 so that the data points are transparent to see more of the points overall.

Some more aesthetics have also been added onto this final chart

  • geom_smooth: this adds a line of best fit through the data so that the correlation can be visualised. Additionally, the method of ‘lm’ means ‘linear model’, just so that the line going through the data is a linear relationship and not something else.

  • stat_cor: this has been added to display the Pearson Correlation Coefficient, which is a measure of linear correlation. The result of r = 0.88 displays a very strong, linear, positive relationship. Meaning that the two fantasy scores strongly correlate with each other.

  • labs and theme: these have just been included to add more of an aesthetic, label the axis and give the plot a title.

rating_scores %>% 
  ggplot(aes(x = supercoach_score, y = afl_fantasy_score)) +
  geom_point(alpha = 0.1) +
  geom_smooth(method = 'lm') +
  stat_cor(label.x = 1, label.y = 150, label.sep = ": ", method = "pearson", size = 4) +
  labs(x = 'Supercoach Score',
       y = 'AFL Fantasy Score',
       title = 'Supercoach Score vs AFL Fantasy Score 2018 Season') +
  theme_bw()