Import Data
read_excel("../00_data/Premier League Match Data 21-22.xlsx")
## # A tibble: 380 × 22
## Date HomeTeam AwayTeam FTHG FTAG FTR HTHG HTAG HTR Referee HS
## <chr> <chr> <chr> <dbl> <dbl> <chr> <dbl> <dbl> <chr> <chr> <dbl>
## 1 13/08/20… Brentfo… Arsenal 2 0 H 1 0 H M Oliv… 8
## 2 14/08/20… Man Uni… Leeds 5 1 H 1 0 H P Tier… 16
## 3 14/08/20… Burnley Brighton 1 2 A 1 0 H D Coote 14
## 4 14/08/20… Chelsea Crystal… 3 0 H 2 0 H J Moss 13
## 5 14/08/20… Everton Southam… 3 1 H 0 1 A A Madl… 14
## 6 14/08/20… Leicest… Wolves 1 0 H 1 0 H C Paws… 9
## 7 14/08/20… Watford Aston V… 3 2 H 2 0 H M Dean 13
## 8 14/08/20… Norwich Liverpo… 0 3 A 0 1 A A Marr… 14
## 9 15/08/20… Newcast… West Ham 2 4 A 2 1 H M Atki… 17
## 10 15/08/20… Tottenh… Man City 1 0 H 0 0 D A Tayl… 13
## # ℹ 370 more rows
## # ℹ 11 more variables: AS <dbl>, HST <dbl>, AST <dbl>, HF <dbl>, AF <dbl>,
## # HC <dbl>, AC <dbl>, HY <dbl>, AY <dbl>, HR <dbl>, AR <dbl>
Introduction
Questions
Variation
Visualizing distributions
ggplot(data = Prem ) +
geom_bar(mapping = aes(x = Referee))

Prem %>% count(Referee)
## # A tibble: 22 × 2
## Referee n
## <chr> <int>
## 1 A Madley 16
## 2 A Marriner 19
## 3 A Taylor 28
## 4 C Kavanagh 18
## 5 C Pawson 26
## 6 D Coote 20
## 7 D England 15
## 8 G Scott 12
## 9 J Brooks 4
## 10 J Gillett 9
## # ℹ 12 more rows
ggplot(data = Prem) +
geom_histogram(mapping = aes(x = HY))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(data = Prem, mapping = aes(x = HY, colour = Referee))+
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Typical values
Prem %>%
# Filter out FTHG <1
filter(FTHG < 1)
## # A tibble: 93 × 22
## Date HomeTeam AwayTeam FTHG FTAG FTR HTHG HTAG HTR Referee HS
## <chr> <chr> <chr> <dbl> <dbl> <chr> <dbl> <dbl> <chr> <chr> <dbl>
## 1 14/08/20… Norwich Liverpo… 0 3 A 0 1 A A Marr… 14
## 2 21/08/20… Crystal… Brentfo… 0 0 D 0 0 D M Atki… 7
## 3 22/08/20… Wolves Tottenh… 0 1 A 0 1 A S Attw… 25
## 4 22/08/20… Arsenal Chelsea 0 2 A 0 2 A P Tier… 6
## 5 28/08/20… Brighton Everton 0 2 A 0 1 A J Moss 14
## 6 29/08/20… Wolves Man Uni… 0 1 A 0 0 D M Dean 15
## 7 44509 Brentfo… Brighton 0 1 A 0 0 D G Scott 7
## 8 44509 Leicest… Man City 0 1 A 0 0 D P Tier… 6
## 9 44509 Southam… West Ham 0 0 D 0 0 D D Coote 11
## 10 44509 Watford Wolves 0 2 A 0 0 D P Bank… 6
## # ℹ 83 more rows
## # ℹ 11 more variables: AS <dbl>, HST <dbl>, AST <dbl>, HF <dbl>, AF <dbl>,
## # HC <dbl>, AC <dbl>, HY <dbl>, AY <dbl>, HR <dbl>, AR <dbl>
Unusual values
Prem %>%
ggplot(aes(FTHG)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Prem %>%
ggplot(aes(FTHG)) +
geom_histogram() +
coord_cartesian(ylim = c(0,50))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Covariation
A categorical and continuous variable
Prem %>%
ggplot(aes(x = HY, y = Referee)) +
geom_boxplot()

Two categorical variables
Prem %>%
count(FTHG, FTAG) %>%
ggplot(aes(x = FTHG, y = FTAG, fill = n))+
geom_tile()

Two continous variables
Patterns and models