library(readr)
football_data <- read.csv("football_recruiting(in).csv")
football_data$WinPct <- football_data$W / (football_data$W + football_data$L)
football_data$Conf_clean <- gsub("\\s*\\(.*\\)", "", football_data$Conf)
football_data$WinPct <- as.numeric(football_data$WinPct)
football_data$Conf_clean <- as.factor(football_data$Conf_clean)
football_data$Conf_clean <- relevel(football_data$Conf_clean, ref = "ACC")
football_data$Conf_clean <- droplevels(as.factor(football_data$Conf_clean))
ols_model <- lm(points ~ WinPct*Conf_clean + HC_change + net_transfer_quantity + net_avg_transfer_quality, data = football_data)
summary(ols_model)
##
## Call:
## lm(formula = points ~ WinPct * Conf_clean + HC_change + net_transfer_quantity +
## net_avg_transfer_quality, data = football_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -126.317 -18.127 1.924 19.889 97.992
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 169.7488 10.1711 16.689 < 2e-16 ***
## WinPct 73.0646 17.9930 4.061 5.42e-05 ***
## Conf_cleanAmerican -37.0119 13.8033 -2.681 0.00750 **
## Conf_cleanBig 12 -5.0330 15.3830 -0.327 0.74363
## Conf_cleanBig Ten 5.3493 13.5124 0.396 0.69231
## Conf_cleanCUSA -35.9008 13.6868 -2.623 0.00890 **
## Conf_cleanInd -98.7067 20.2543 -4.873 1.35e-06 ***
## Conf_cleanMAC -38.7521 13.5398 -2.862 0.00433 **
## Conf_cleanMWC -40.6166 13.5498 -2.998 0.00281 **
## Conf_cleanPac-12 5.1541 13.9075 0.371 0.71104
## Conf_cleanSEC 8.8397 13.8680 0.637 0.52405
## Conf_cleanSun Belt -44.9617 13.9678 -3.219 0.00134 **
## HC_change -7.0702 2.8918 -2.445 0.01473 *
## net_transfer_quantity -1.2704 0.2155 -5.895 5.71e-09 ***
## net_avg_transfer_quality 11.0543 4.7630 2.321 0.02057 *
## WinPct:Conf_cleanAmerican -16.2435 24.4921 -0.663 0.50740
## WinPct:Conf_cleanBig 12 11.2540 26.8407 0.419 0.67513
## WinPct:Conf_cleanBig Ten 2.2283 23.5567 0.095 0.92466
## WinPct:Conf_cleanCUSA -52.8378 25.6888 -2.057 0.04006 *
## WinPct:Conf_cleanInd 71.1422 33.4615 2.126 0.03383 *
## WinPct:Conf_cleanMAC -53.4332 25.2270 -2.118 0.03450 *
## WinPct:Conf_cleanMWC -44.9443 24.3788 -1.844 0.06565 .
## WinPct:Conf_cleanPac-12 -14.6804 24.7379 -0.593 0.55307
## WinPct:Conf_cleanSEC 43.9339 23.5798 1.863 0.06284 .
## WinPct:Conf_cleanSun Belt -41.0536 24.9725 -1.644 0.10062
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 30.92 on 730 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.6828, Adjusted R-squared: 0.6723
## F-statistic: 65.46 on 24 and 730 DF, p-value: < 2.2e-16
library(broom)
library(gt)
reg_table <- tidy(ols_model)
gt(reg_table)
| term |
estimate |
std.error |
statistic |
p.value |
| (Intercept) |
169.748753 |
10.1711117 |
16.6893017 |
3.265732e-53 |
| WinPct |
73.064566 |
17.9930143 |
4.0607185 |
5.421209e-05 |
| Conf_cleanAmerican |
-37.011940 |
13.8032663 |
-2.6813900 |
7.497313e-03 |
| Conf_cleanBig 12 |
-5.032973 |
15.3830154 |
-0.3271773 |
7.436276e-01 |
| Conf_cleanBig Ten |
5.349295 |
13.5124023 |
0.3958804 |
6.923090e-01 |
| Conf_cleanCUSA |
-35.900781 |
13.6867945 |
-2.6230233 |
8.897208e-03 |
| Conf_cleanInd |
-98.706695 |
20.2543134 |
-4.8733667 |
1.346517e-06 |
| Conf_cleanMAC |
-38.752126 |
13.5397591 |
-2.8620987 |
4.328933e-03 |
| Conf_cleanMWC |
-40.616554 |
13.5498328 |
-2.9975687 |
2.813767e-03 |
| Conf_cleanPac-12 |
5.154096 |
13.9075210 |
0.3705978 |
7.110446e-01 |
| Conf_cleanSEC |
8.839750 |
13.8679568 |
0.6374226 |
5.240494e-01 |
| Conf_cleanSun Belt |
-44.961678 |
13.9678216 |
-3.2189471 |
1.343535e-03 |
| HC_change |
-7.070210 |
2.8918380 |
-2.4448846 |
1.472524e-02 |
| net_transfer_quantity |
-1.270411 |
0.2154902 |
-5.8954444 |
5.709956e-09 |
| net_avg_transfer_quality |
11.054332 |
4.7630246 |
2.3208639 |
2.056881e-02 |
| WinPct:Conf_cleanAmerican |
-16.243506 |
24.4920851 |
-0.6632145 |
5.074026e-01 |
| WinPct:Conf_cleanBig 12 |
11.253961 |
26.8407385 |
0.4192865 |
6.751301e-01 |
| WinPct:Conf_cleanBig Ten |
2.228346 |
23.5567034 |
0.0945950 |
9.246625e-01 |
| WinPct:Conf_cleanCUSA |
-52.837762 |
25.6887955 |
-2.0568408 |
4.005637e-02 |
| WinPct:Conf_cleanInd |
71.142203 |
33.4615053 |
2.1260909 |
3.383067e-02 |
| WinPct:Conf_cleanMAC |
-53.433184 |
25.2270143 |
-2.1180939 |
3.450445e-02 |
| WinPct:Conf_cleanMWC |
-44.944296 |
24.3787898 |
-1.8435819 |
6.564924e-02 |
| WinPct:Conf_cleanPac-12 |
-14.680439 |
24.7378913 |
-0.5934394 |
5.530710e-01 |
| WinPct:Conf_cleanSEC |
43.933899 |
23.5797995 |
1.8632007 |
6.283541e-02 |
| WinPct:Conf_cleanSun Belt |
-41.053648 |
24.9724951 |
-1.6439546 |
1.006161e-01 |
reg_table %>%
gt() %>%
tab_options(
table.font.size = px(10) # shrink font
)
| term |
estimate |
std.error |
statistic |
p.value |
| (Intercept) |
169.748753 |
10.1711117 |
16.6893017 |
3.265732e-53 |
| WinPct |
73.064566 |
17.9930143 |
4.0607185 |
5.421209e-05 |
| Conf_cleanAmerican |
-37.011940 |
13.8032663 |
-2.6813900 |
7.497313e-03 |
| Conf_cleanBig 12 |
-5.032973 |
15.3830154 |
-0.3271773 |
7.436276e-01 |
| Conf_cleanBig Ten |
5.349295 |
13.5124023 |
0.3958804 |
6.923090e-01 |
| Conf_cleanCUSA |
-35.900781 |
13.6867945 |
-2.6230233 |
8.897208e-03 |
| Conf_cleanInd |
-98.706695 |
20.2543134 |
-4.8733667 |
1.346517e-06 |
| Conf_cleanMAC |
-38.752126 |
13.5397591 |
-2.8620987 |
4.328933e-03 |
| Conf_cleanMWC |
-40.616554 |
13.5498328 |
-2.9975687 |
2.813767e-03 |
| Conf_cleanPac-12 |
5.154096 |
13.9075210 |
0.3705978 |
7.110446e-01 |
| Conf_cleanSEC |
8.839750 |
13.8679568 |
0.6374226 |
5.240494e-01 |
| Conf_cleanSun Belt |
-44.961678 |
13.9678216 |
-3.2189471 |
1.343535e-03 |
| HC_change |
-7.070210 |
2.8918380 |
-2.4448846 |
1.472524e-02 |
| net_transfer_quantity |
-1.270411 |
0.2154902 |
-5.8954444 |
5.709956e-09 |
| net_avg_transfer_quality |
11.054332 |
4.7630246 |
2.3208639 |
2.056881e-02 |
| WinPct:Conf_cleanAmerican |
-16.243506 |
24.4920851 |
-0.6632145 |
5.074026e-01 |
| WinPct:Conf_cleanBig 12 |
11.253961 |
26.8407385 |
0.4192865 |
6.751301e-01 |
| WinPct:Conf_cleanBig Ten |
2.228346 |
23.5567034 |
0.0945950 |
9.246625e-01 |
| WinPct:Conf_cleanCUSA |
-52.837762 |
25.6887955 |
-2.0568408 |
4.005637e-02 |
| WinPct:Conf_cleanInd |
71.142203 |
33.4615053 |
2.1260909 |
3.383067e-02 |
| WinPct:Conf_cleanMAC |
-53.433184 |
25.2270143 |
-2.1180939 |
3.450445e-02 |
| WinPct:Conf_cleanMWC |
-44.944296 |
24.3787898 |
-1.8435819 |
6.564924e-02 |
| WinPct:Conf_cleanPac-12 |
-14.680439 |
24.7378913 |
-0.5934394 |
5.530710e-01 |
| WinPct:Conf_cleanSEC |
43.933899 |
23.5797995 |
1.8632007 |
6.283541e-02 |
| WinPct:Conf_cleanSun Belt |
-41.053648 |
24.9724951 |
-1.6439546 |
1.006161e-01 |
acc_2023 <- subset(football_data, Conf_clean == "ACC" & Year == 2023)
quantile(acc_2023$net_transfer_quantity, probs = 0.75, na.rm = TRUE)
## 75%
## 1
quantile(acc_2023$net_avg_transfer_quality, probs = 0.50, na.rm = TRUE)
## 50%
## -0.002757193
# Create a new dataset with your predictor values
acc_team <- data.frame(
WinPct = 0.8,
Conf_clean = "ACC",
HC_change = 0,
net_transfer_quantity = 1,
net_avg_transfer_quality = -.002757193
)
# Predict points
predict(ols_model, newdata = acc_team)
## 1
## 226.8995
team_points <- 226.8995 # replace with your calculated number
# Calculate rank of your number among all ACC 2023 teams
team_rank <- sum(acc_2023$points > team_points, na.rm = TRUE) + 1
team_rank
## [1] 4