#packages
library(readxl)
library(Metrics)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
data<- read_excel('/Users/dylansnelsire/Desktop/301 Data.xlsx')
data$size <- as.double(data$size)
data
## # A tibble: 99 × 4
## School size average_viewers NIL
## <chr> <dbl> <dbl> <dbl>
## 1 Alabama 38316 5110000 217000
## 2 Georgia 40118 3500000 139000
## 3 Texas 51991 3060000 291000
## 4 Ohio State 61677 5800000 125000
## 5 LSU 35912 3220000 98000
## 6 Miami 19096 608000 100000
## 7 Oklahoma 28042 1748000 122000
## 8 Oregon 22257 2210000 76000
## 9 Notre Dame 13139 3300000 83000
## 10 Clemson 27341 2590000 89000
## # ℹ 89 more rows
data.cor = cor(data[, c("size", "average_viewers", "NIL")])
data.cor
## size average_viewers NIL
## size 1.0000000 0.3795284 0.328651
## average_viewers 0.3795284 1.0000000 0.699638
## NIL 0.3286510 0.6996380 1.000000
#scatterplot size vs average viewers
ggplot(data, aes(x=size, y=average_viewers)) + geom_point(color = 'darkgreen')+
geom_smooth(method='lm', color = 'black') +
labs(title="Size vs Average viewers", x ="Size", y = "Average viewers")
## `geom_smooth()` using formula = 'y ~ x'
#scatterplot size vs NIL
ggplot(data, aes(x=size, y=NIL)) + geom_point(color = 'blue')+
geom_smooth(method='lm', color = 'black') +
labs(title="Size vs NIL", x ="Size", y = "NIL")
## `geom_smooth()` using formula = 'y ~ x'
#scatterplot average viewers vs NIL
ggplot(data, aes(x=NIL, y=average_viewers)) + geom_point(color = 'red')+
geom_smooth(method='lm', color = 'black')+
labs(title="NIL vs Average viewers", x ="NIL", y = "Average Viewers")
## `geom_smooth()` using formula = 'y ~ x'
#ANOVA Test
one.way <- aov(average_viewers ~ size, data = data)
summary(one.way)
## Df Sum Sq Mean Sq F value Pr(>F)
## size 1 1.901e+13 1.901e+13 16.32 0.000107 ***
## Residuals 97 1.130e+14 1.164e+12
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
two.way <- aov(average_viewers ~ size + NIL, data = data)
summary(two.way)
## Df Sum Sq Mean Sq F value Pr(>F)
## size 1 1.901e+13 1.901e+13 28.49 6.30e-07 ***
## NIL 1 4.890e+13 4.890e+13 73.28 1.83e-13 ***
## Residuals 96 6.406e+13 6.672e+11
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
two.way2 <- aov(average_viewers ~ NIL + size, data = data)
summary(two.way2)
## Df Sum Sq Mean Sq F value Pr(>F)
## NIL 1 6.459e+13 6.459e+13 96.806 3.3e-16 ***
## size 1 3.311e+12 3.311e+12 4.961 0.0283 *
## Residuals 96 6.406e+13 6.672e+11
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(AICcmodavg)
model.set <- list(one.way, two.way)
model.names <- c("one.way", "two.way")
aictab(model.set, modnames = model.names)
##
## Model selection based on AICc:
##
## K AICc Delta_AICc AICcWt Cum.Wt LL
## two.way 4 2981.75 0.00 1 1 -1486.66
## one.way 3 3035.73 53.98 0 1 -1514.74
#homoscdasticity check
par(mfrow=c(2,2))
plot(two.way)
par(mfrow=c(1,1))
Interpration: Adding both variables is important for the model no matter looking at NIL or size first adding the other variable helps make the model more accurate to predict average viwership. So it appears both variables are useful in predicting viewership for college football teams.
The two way model is the best to pick in fact the only on with a AIC weight of 1 it explains all the variation and it also has the lowest AIC value.
The modeel does fit the assunption of homoscadasticity it seems we may have just one outlier value at the end in the residual plot. For the q-q plot our slope seems to follow close to a slope of 1 so that passes and it appears there are no violations there.
#t test
ttest <- t.test(data$average_viewers, data$size, data = data, paired = T)
ttest
##
## Paired t-test
##
## data: data$average_viewers and data$size
## t = 9.0019, df = 98, p-value = 1.772e-14
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 814171.1 1274649.0
## sample estimates:
## mean difference
## 1044410
ttest2 <- t.test(data$average_viewers, data$NIL, data = data, paired = T)
ttest2
##
## Paired t-test
##
## data: data$average_viewers and data$NIL
## t = 9.1302, df = 98, p-value = 9.342e-15
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 810669.1 1260934.9
## sample estimates:
## mean difference
## 1035802
Interpration: The means of both NIL and school size do have an effect on average viewership and are statistically different. With t values of 9.009 and 9.1302 and both having p-values less then .001 we have enough evidence to confirm that the means are statistically different and do play an effect when facotring in how much viewership a football team will average or get for games. This helps gauge fan interest and involvement.