Oliver Fitzpatrick s3686342
Last updated: 20 October, 2017
AFL_Drafts <- readxl::read_excel("C:/Users/sarah/Desktop/Oliver/AFL_Drafts(1999-2009).xlsx",
col_types = c("text", "numeric", "text",
"text", "text", "numeric", "numeric",
"text", "numeric", "numeric", "numeric",
"text", "text", "text"))
View(AFL_Drafts)AFL_Drafts$Draft_Position <- AFL_Drafts$Draft_Position %>% factor(levels = c('Top 20','20-40','40-60','60-80','80-100','100-120','>120'),ordered = TRUE)
AFL_Drafts$AA <- AFL_Drafts$AA %>% factor(levels = c('Yes','No'),ordered = TRUE)AFL_Drafts$Games_Played %>% hist(xlab = "Number of Games Played",ylab = "Frequency", main = "Distribution of Games Played By AFL Footballers",col = "dodgerblue") - We can see the data is heavily positively skewed, with the vast majority of players playing less than 50 games.
AFL_Drafts %>% group_by(Draft_Position) %>% summarise(Q1 = quantile(Games_Played,probs = .25,na.rm = TRUE)%>%round(1),
Median = median(Games_Played, na.rm = TRUE)%>%round(1),
Q3 = quantile(Games_Played,probs = .75,na.rm = TRUE)%>%round(1),
Max = max(Games_Played,na.rm = TRUE),
Mean = mean(Games_Played, na.rm = TRUE)%>%round(1),
SD = sd(Games_Played, na.rm = TRUE)%>%round(1),
n = n(),
Missing = sum(is.na(Games_Played))) -> table1
knitr::kable(table1)| Draft_Position | Q1 | Median | Q3 | Max | Mean | SD | n | Missing |
|---|---|---|---|---|---|---|---|---|
| Top 20 | 48.0 | 125.0 | 197.5 | 353 | 128.3 | 88.9 | 220 | 0 |
| 20-40 | 12.8 | 62.5 | 139.5 | 319 | 82.6 | 80.1 | 220 | 0 |
| 40-60 | 4.0 | 27.0 | 111.0 | 332 | 63.9 | 75.8 | 220 | 6 |
| 60-80 | 0.0 | 13.0 | 59.8 | 251 | 43.2 | 63.0 | 220 | 66 |
| 80-100 | 0.0 | 2.0 | 61.0 | 275 | 41.6 | 65.3 | 220 | 35 |
| 100-120 | 0.0 | 1.0 | 45.5 | 289 | 38.4 | 66.9 | 220 | 16 |
| >120 | 0.0 | 3.0 | 31.0 | 290 | 27.5 | 49.6 | 477 | 78 |
AFL_Drafts %>% boxplot(Games_Played ~ Draft_Position, data = ., main = "Box Plot of Games Played by Draft Position", xlab = "Draft Position", ylab = "Games Played", col = "firebrick1") - The Boxplots help us notice the obvious difference between the top picks and later picks - The trend seems to be that the later the pick, the less games the player will play, although it does apppear that the groups 60-80, 80-100 and 100-120 are somewhat similar - Further analysis will need to be done to see whether there is a statistically significant difference between the groups
AFL_Drafts %>% histogram(~Games_Played | Draft_Position,data=.,main = "Distribution of Games Played by Draft Position", xlab = "Games Played", ylab = "Frequency", layout=c(4,2)) - The histograms are interesting, they appear to add weight to the idea that earlier picks play more games - the distribution amongst the top 20 group is almost uniform, but as the picks get later, the distribution becomes more and more positively skewed - This tells us that more players taken with late picks play only a few games than players taken with early picks
AFL_Drafts %>% group_by(Draft_Position) %>% summarise(
Max = max(Brownlow,na.rm = TRUE),
Mean = mean(Brownlow, na.rm = TRUE)%>%round(1),
SD = sd(Brownlow, na.rm = TRUE)%>% round(1),
n = n(),
Missing = sum(is.na(Brownlow))) -> table2
knitr::kable(table2)| Draft_Position | Max | Mean | SD | n | Missing |
|---|---|---|---|---|---|
| Top 20 | 210 | 23.5 | 38.0 | 220 | 3 |
| 20-40 | 220 | 10.3 | 29.1 | 220 | 8 |
| 40-60 | 186 | 5.3 | 17.2 | 220 | 23 |
| 60-80 | 35 | 1.7 | 5.6 | 220 | 40 |
| 80-100 | 72 | 2.6 | 7.9 | 220 | 35 |
| 100-120 | 146 | 3.2 | 15.0 | 220 | 25 |
| >120 | 66 | 1.7 | 6.5 | 477 | 68 |
table(AFL_Drafts$AA,AFL_Drafts$Draft_Position) %>% prop.table(margin = 2)%>% round(3)##
## Top 20 20-40 40-60 60-80 80-100 100-120 >120
## Yes 0.227 0.095 0.045 0.014 0.014 0.014 0.013
## No 0.773 0.905 0.955 0.986 0.986 0.986 0.987
AAfreq <- table(AFL_Drafts$AA,AFL_Drafts$Draft_Position) %>% prop.table(margin = 2)%>% round(3)
barplot(AAfreq, main = "Proportion of All Australians From Each Draft Position", ylab = "Proportion", xlab = "Draft Position", legend.text = TRUE) - Earlier picks are also far more likely to make an All Australian team - over 20% of top 20 picks will be picked at some point in their career, and this fades to around 1% as the picks get later
AFL_Drafts %>% group_by(Draft_Position) %>% summarise(Mean = round(mean(Games_Played, na.rm = TRUE),2),
SD = round(sd(Games_Played, na.rm = TRUE),3),
n = n(),
tcrit = round(qt(p = 0.975, df = n - 1),3),
SE = round(SD/sqrt(n),3),
`95% CI Lower Bound` = round(Mean - tcrit * SE,2),
`95% CI Upper Bound` = round(Mean + tcrit * SE,2))p1 <- ggplot(data = AFL_Drafts, aes(x = Draft_Position, y = Games_Played))
p1 + geom_dotplot(binaxis = "y", stackdir = "center", dotsize = 1/2, alpha = .25,binwidth = 10) +
stat_summary(fun.y = "mean", geom = "point", colour = "red") +
stat_summary(fun.data = "mean_cl_normal", colour = "red",
geom = "errorbar", width = .2) - The confidence intervals show us that Top 20 picks are significantly more likely to play more games than players taken at any other time in the draft - The confidence levels do appear to decrease as the picks get later in the draft, but there is some overlap
fit <- aov(Games_Played ~ Draft_Position, data = AFL_Drafts)
TukeyHSD(fit)## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Games_Played ~ Draft_Position, data = AFL_Drafts)
##
## $Draft_Position
## diff lwr upr p adj
## 20-40-Top 20 -45.668182 -65.18472 -26.1516460 0.0000000
## 40-60-Top 20 -64.426805 -84.07966 -44.7739476 0.0000000
## 60-80-Top 20 -85.075974 -106.58215 -63.5697990 0.0000000
## 80-100-Top 20 -86.671867 -107.09063 -66.2531065 0.0000000
## 100-120-Top 20 -89.924332 -109.81986 -70.0287985 0.0000000
## >120-Top 20 -100.765995 -117.95484 -83.5771528 0.0000000
## 40-60-20-40 -18.758624 -38.41148 0.8942342 0.0726378
## 60-80-20-40 -39.407792 -60.91397 -17.9016172 0.0000015
## 80-100-20-40 -41.003686 -61.42245 -20.5849247 0.0000001
## 100-120-20-40 -44.256150 -64.15168 -24.3606167 0.0000000
## >120-20-40 -55.097813 -72.28665 -37.9089710 0.0000000
## 60-80-40-60 -20.649169 -42.27913 0.9807925 0.0725470
## 80-100-40-60 -22.245062 -42.79416 -1.6959635 0.0239661
## 100-120-40-60 -25.497526 -45.52680 -5.4682504 0.0033553
## >120-40-60 -36.339189 -53.68266 -18.9957197 0.0000000
## 80-100-60-80 -1.595893 -23.92404 20.7322546 0.9999927
## 100-120-60-80 -4.848358 -26.69905 17.0023319 0.9948498
## >120-60-80 -15.690021 -35.10848 3.7284416 0.2053812
## 100-120-80-100 -3.252464 -24.03377 17.5288461 0.9992733
## >120-80-100 -14.094127 -32.30091 4.1126546 0.2516957
## >120-100-120 -10.841663 -28.45965 6.7763206 0.5368725
bivariate<-as.matrix(dplyr::select(AFL_Drafts, Draft_Number,Games_Played)) #Create a matrix of the variables to be correlated
rcorr(bivariate, type = "pearson")## Draft_Number Games_Played
## Draft_Number 1.00 -0.39
## Games_Played -0.39 1.00
##
## n
## Draft_Number Games_Played
## Draft_Number 1797 1596
## Games_Played 1596 1596
##
## P
## Draft_Number Games_Played
## Draft_Number 0
## Games_Played 0
CIr(-0.39, n = 1596, level = .95)## [1] -0.4308229 -0.3475842