Show the code
BYUdt <- select(BYU, Opponent, Year, Win, PassYds)
datatable(BYUdt,
options=list(scrollX= TRUE,
lengthMenu = c(5, 10, 15)),
extensions="Responsive")Course MATH 325
Lexi Soelberg
BYU’s 2024 season has been really good so far (a 10/2 season!) For the sake of this analysis, I’m only looking at the data since Nov 16th 2024.
I wanted to compare the wins and passing yards from the past 3 years. I went to the BYU schedules on ESPN and the season statistics from BYU’s football website.
The wins and passing yards from the last 3 years are represented in the data table below.
P(Y_i = 1|\, x_i) = \frac{e^{\beta_0 + \beta_1 x_i}}{1+e^{\beta_0 + \beta_1 x_i}} = \pi_i
If \beta_1 is zero in the above model, then x_i (passing yards) provides no insight about the probability of a BYU win. If not zero however, then passing yards plays an important role in the probability of BYU’s win.
Using a significance level of
\alpha = 0.05
we will test the below hypotheses about \beta_1.
H_0: \beta_1 = 0 \\ H_a: \beta_1 \neq 0
The estimates of the coefficients \beta_0 and \beta_1 for the above logistic regression model and data are shown below.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | -0.09965 | 0.8884 | -0.1122 | 0.9107 |
| PassYds | 0.003374 | 0.003612 | 0.9343 | 0.3502 |
(Dispersion parameter for binomial family taken to be 1 )
| Null deviance: | 61.11 on 47 degrees of freedom |
| Residual deviance: | 60.20 on 46 degrees of freedom |
This gives the estimated model for \pi_i as
P(Y_i = 1|x_i) \approx \frac{e^{-0.09965+0.003374 x_i}}{1+e^{-0.09965+0.003374x_i}} = \hat{\pi}_i
b_0 = -0.09965 is the value of the (Intercept) which estimates \beta_0 and b_1 = 0.003374 is the value of PassYds which estimates \beta_1.
The p-value for the test of PassYds of p=0.3502 does not show sufficient evidence to conclude that \beta_1 \neq 0. Again, we were looking for sufficient evidence that the p-value would have shown us that \beta_1 was not 0. Therefore because we can’t say that \beta_1 is not 0 we conclude that BYU’s passing yards of the game does not effect their probability of a win.
BYUplot <- ggplot(data = BYU, aes(y = Num, x = PassYds, color=PassYds)) +
geom_point(size = 3.5, alpha = 0.8, aes(
text = paste(
"Passing Yards in a Game:", PassYds, "<br>",
"Win/Lose:", Win))) +
geom_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE, color = "royalblue1")+
scale_color_gradient(low = "royalblue1", high = "royalblue4") +
labs(title = "Is BYU More Likely to Win With More Passing Yards in a Game?",
x = "Passing Yards",
y = "Win or Lose") +
theme_minimal() +
theme(
panel.background = element_rect(fill = "white", color = NA),
plot.background = element_rect(fill = "white", color = NA)
)
ggplotly(BYUplot, tooltip="text")[1] "0.00016"
We will run a Hosmer-Lemeshow Goodness-of-Fit Test to diagnose how well the x-values are represented in the logistic regression. There are very few repeated values in the data.
| Test statistic | df | P value |
|---|---|---|
| 11.73 | 4 | 0.01943 * |
In order to claim that the logistic regression is appropriate for this data we needed to see a p-value greater than \alpha (0.05). With p-value=0.01943 we cannot say that the logistic regression is a good fit for this data.
There was not significant evidence to conclude that BYU wins more with more passing yards. The p-value of the \beta1 test did not reach significance at p=0.3502. The appropriateness of the x-values was also found to not be a good fit thanks to the Hosmer and Lemeshow (GOF) test. p-value=0.01943
There isn’t much significance in the model, however I still wanted to see the win probability prediction of passing yards at 300. That puts the model at:
P(Y_i = 1|x_i) \approx \frac{e^{-0.09965+0.003374*300}}{1+e^{-0.09965+0.003374*300}} = \hat{\pi}_i
which, using R to do this calculation we get \hat{\pi_i} \approx 0.71354. This shows that a win for BYU was much more likely to happen when the passing yards reached 300.
Based on this prediction, BYU should put in the work on their passing yards. Their win probability is roughly 70% if they can pass the length of 3 football fields in one game!
: )