---
title: "CFB Analysis"
#author: "Mark"
date: "9/6/2017"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## CFB Stats compared to Ws and Ls

Here's a fun little article: https://theathletic.com/89525/2017/08/29/the-four-stats-that-matter-to-college-football-coaches/

It's behind a paywall so most folks can probably see only the beginning. Here's the main claim, though - Amongst the myriad stats that college football coaches track to gauge their team's strength, four stand out as highly correlated to wins and losses:

 * 3rd down conversion percentage
 * Average yards per pass attempt
 * Turnover margin
 * Rush attempts

Moreover, these are more highly correlated to winning percentage than are other oft cited stats, such as total offense, pass defense or total defense.

As usual, I've got a CSV file that stores all sorts of relevant data on my webpage. This particular data set was scraped off of http://www.cfbstats.com/. Let's read it in and examine the column variables.

```{r}
df = read.csv('../../../data/CFB2016.csv')
names(df)
```

That's 117 fields for all 128 FBS teams - quite a lot of data. 

### Measuring their statistics

Let's take a look at the specific data menioned in the article and who well it correlates with wins and losses.

#### Third down conversion rate

```{r}
wl = df$Wins/(df$Wins + df$Losses)
other = as.numeric(sub("%","",df$TEAM.3rd.Down.Conversion..))
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

A correlation of 0.53 with an F-Stat of about $10^{-10}$.

#### Average yards per pass attempt

```{r}
other = df$TEAM.Passing..Yards/df$TEAM.Passing..Attempts
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

#### Turnover margin


```{r}
other = (df$OPP.Fumbles.Lost-df$TEAM.Fumbles.Lost) + (df$OPP.Passing.Interceptions-df$TEAM.Passing.Interceptions)
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

#### Rushing attempts

```{r}
other = df$TEAM.Rushing..Attempts
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

### Some of the things that the article indicates are less important

#### Total offense (by yards/play)

```{r}
other = df$TEAM.Total.Offense..Yards...Play
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

```{r}
other = df$OPP.Total.Offense..Yards...Play
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

```{r}
other = df$OPP.Total.Offense..Yards...Play
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```


### A couple more

Here's the deal - if you want to win games, then score points.

```{r}
other = df$TEAM.Total.Points
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```

Keeping the other team from scoring points seems less important.

```{r}
other = df$OPP.Total.Points
cor(wl,other)
plot(wl,other)
fit = lm(other~wl)
abline(fit)
summary(fit)
```
