May 7, 2018

I don't want better goal kicking accuracy in the AFL

Update: There is far less of a relationship between goal accuracy and margin than originally published - I’ve fixed the error in code below which was using Away.Points instead of Away.Behinds in calculating goal-kicking accuracy.

Today I practice ggplot2 and investigate skills in the AFL.

The #AFLWonkWednesdays week 2 topic is;

What is going on with skills?

There has been a lot of chatter about the quality of skills and goal kicking in the AFL of late. The greats have had their say. Goal kicking is at HISTORIC lows (since 1990). The league is even on scoring trend watch.

But what do the wonks think?

I think I am too new to AFL stats to call myself a wonk but I will tell you what I think - even though watching a slew of points is frustrating, it might be a signal of a better (more exciting, lower margin of victory) game.

Update: After fixing the goal-kicking accuracy calculation I still don’t care about increasing goal-accuracy as it seems to have no effect on if a game will be tight or not, which is my ‘success’ criteria

# Packages
library(tidyverse)
library(here)
library(ggthemes)
library(devtools)
library(fitzRoy)
library(viridis)

Big thanks to Jimmy Day for the data;

d <- get_match_results()
glimpse(d)
## Observations: 15,263
## Variables: 16
## $ Game         <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15...
## $ Date         <date> 1897-05-08, 1897-05-08, 1897-05-08, 1897-05-08, ...
## $ Round        <chr> "R1", "R1", "R1", "R1", "R2", "R2", "R2", "R2", "...
## $ Home.Team    <chr> "Fitzroy", "Collingwood", "Geelong", "Sydney", "S...
## $ Home.Goals   <int> 6, 5, 3, 3, 6, 4, 3, 9, 6, 5, 12, 8, 5, 5, 2, 11,...
## $ Home.Behinds <int> 13, 11, 6, 9, 4, 6, 8, 10, 5, 9, 6, 11, 14, 11, 8...
## $ Home.Points  <int> 49, 41, 24, 27, 40, 30, 26, 64, 41, 39, 78, 59, 4...
## $ Away.Team    <chr> "Carlton", "St Kilda", "Essendon", "Melbourne", "...
## $ Away.Goals   <int> 2, 2, 7, 6, 5, 8, 10, 3, 5, 7, 6, 0, 3, 5, 6, 7, ...
## $ Away.Behinds <int> 4, 4, 5, 8, 6, 2, 6, 1, 7, 8, 5, 2, 4, 3, 6, 4, 8...
## $ Away.Points  <int> 16, 16, 47, 44, 36, 50, 66, 19, 37, 50, 41, 2, 22...
## $ Venue        <chr> "Brunswick St", "Victoria Park", "Corio Oval", "L...
## $ Margin       <int> 33, 25, -23, -17, 4, -20, -40, 45, 4, -11, 37, 57...
## $ Season       <dbl> 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1...
## $ Round.Type   <chr> "Regular", "Regular", "Regular", "Regular", "Regu...
## $ Round.Number <int> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5...

Margin

ggplot(data = d, aes(x = Date, y = Margin)) +
  geom_boxplot(aes(group = cut_interval(Date, n = 100))) +
  theme_tufte() +
  labs(title = "Margin in AFL over time")

Goal-kicking accuracy

# Define goal accuracy = goal scoring shots / total scoring shots
d$goal_accuracy <- round((d$Home.Goals + d$Away.Goals) / (d$Home.Goals + d$Away.Goals + d$Home.Behinds + d$Away.Behinds), digits = 2)
ggplot(data = d, aes(x = Date, y = goal_accuracy)) +
  geom_boxplot(aes(group = cut_interval(Date, n = 100))) +
  theme_tufte() +
  labs(title = "Goal-kicking accuracy in AFL over time")

Margin and goal-kicking accuracy

Class any game that has a margin that falls within the default IQR from base R as ‘exciting’.

summary(abs(d$Margin)) # Convert margin to absolute because negative margin doesn't make sense to me in this context
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   12.00   26.00   32.27   46.00  190.00
d$game_type <- ifelse(abs(d$Margin) >= 0 & abs(d$Margin) <= 46, "exciting", "boring") # Use ranges from summary
d$game_type <- as.factor(d$game_type)
ggplot(data = d, aes(x = goal_accuracy, y = abs(Margin), col = game_type)) +
  geom_point(alpha = 0.4) +
  theme_tufte() +
  geom_smooth() +
  scale_color_manual(values=c( "#91a3b0", "#7eb233")) +
  labs(title = "Goal-kicking accuracy and tight margins",
       subtitle = "More accuracy might mean a less exciting game",
       x = "Combined goal-kicking accuracy (% of scoring shots that are goals from both sides)",
       y = "Absolute margin of game",
       caption = expression(paste(italic("Source: AFL games 1897 to 2018 c/o fitzRoy package"))))
## `geom_smooth()` using method = 'gam'

ggplot(data = d, aes(x = goal_accuracy, y = abs(Margin))) +
  stat_density_2d(geom = "tile", aes(fill = ..density..), contour = FALSE)+
  scale_fill_viridis() +
  theme_tufte() +
  labs(title = "Goal-kicking accuracy and tight margins",
       subtitle = "",
       x = "Goal-kicking accuracy (% of scoring shots that are goals)",
       y = "Absolute margin of game",
       caption = expression(paste(italic("Source: AFL games 1897 to 2018 c/o fitzRoy package"))))

© Will Bidstrup 2018