NFL Statistics: An Exploratory Data Analysis
INTRODUCTION
The mission: making more informed, “better” decisions when placing wagers on NFL football games.
In order to accomplish this mission, an interactive R Shiny Dashboard (link) was created so that the user can select a specific team-opponent combination to obtain historical matchup performance trends in addition to variables correlated with beating the team’s user specified opponent.
Once the user is able to gain information on how the selected team performs against the selected opponent, better gambling decisions based on statistical analysis can be made.
R & R SHINY
R is an open-source computer programming language widely used for statistical analyses. R is bundled with visualization packages that easily allows the programmers to display their statistical findings.
R Shiny is a web application framework which allows users to interact with the data set being analyzed to produce visualizations as per the input parameters set by the user. R Shiny is a package bundled with the RStudio integrated development environment (IDE).
NFL BETTING CONCEPTS
There are 2 main types of wagers when betting on NFL games: the point spread and the point total. The R Shiny Dashboard was tailored to present the data with the point spread and point total betting types in mind, but the data can be applied to other NFL wagers.
The Point Spread
Sportsbooks formulate a point spread (aka “line”) for each NFL game. If the “line” is negative, the team mentioned preceding the line is favored by the amount of the line. For example, if the New Orleans Saints are -9 vs the Atlanta Falcons and a gambler places a point spread wager on the Saints, the gambler needs the Saints to beat the Falcons by 10 or more points in order to win the bet (aka “cover”).
If the Atlanta Falcons are +9 vs the New Orleans Saints and a gambler places a point spread wager on the Falcons, the gambler needs the Falcons to lose the game by 8 or less points in order to “cover” the bet. If New Orleans wins by exactly 9 points, the bet is a draw (aka “push”); and no money is exchanged.
In reality, sportsbooks charge the gambler a percentage (aka “vig”) of the bet to take the bet. The gambler loses the percentage in a push bet, but that concept is outside the scope of the topics covered.
The Point Total
Sportsbooks also formulate a point total (aka “over/under”) for each NFL game. A gambler can bet over or under on the combined points of both teams. For example, if the “Over/Under” is set at 46 points and a gambler bets the over, he can win if the two teams’ combined score is above that amount.
For example, if the Saints scored 34 points and the Falcons scored 20 points, the gambler wins the wager since a combined 54 points were scored in the game. Just as in the point spread bet, if the combined score totals 46 points, the bet is a draw and no money is exchanged.
DATA SET
The data set used for the R Shiny web application was obtained from Pro Football Reference, which is an NFL statistic aggregating website (https://www.pro-football-reference.com). Quarterback (QB), running back (RB) and wide receiver (WR) statistics from each game of the past five (5) NFL seasons--2012 through 2016--were compiled into a CSV file so that it could be loaded into the R Studio IDE.
Reference the snapshot below for the QB statistics collected:
Reference the snapshot below for the WR statistics collected:
Reference the snapshot below for the RB statistics collected:
R SHINY WEB APPLICATION
HOME PAGE
The Home page is meant to illustrate that teams generally do not have very big swings in win total from season to season. Also, the line graphs illustrate total wins (y-axis) by season (x-axis) with each color representing a team. The graphs are separated by conference and division.
The user can select a number for the win difference from year to year, and the table below will display the teams with a win total swing greater than the value selected. For example, if the user selects 6 as the input, the table will update to display the 8 teams over the last 5 years that had a swing in total wins of 7 games or more.
BETTING MENU, MATHCUP TABLES
The matchup tables sub-menu page under the betting menu is a way for the user to easily see tables containing the statistics of prior matchups between the selected team and the selected opponent. The user can select the team for analysis and the opponent via the sidebar. Reference the table below for a legend explaining the variable names in the tables:
Variable Dictionary Table:
Season: NFL season in which game occurred | Week: Week of game | Team: Team for analysis | X: Home or Away |
Opponent: Upcoming opponent | Result: Win, Lose or Tie | ptsFor: Points scored by Team | ptsAgst: Points scored by Opponent or defensive points allowed by Team |
psYds: Team passing yards | psTDs: Team passing TDs | psInt: Interceptions thrown by Team | QBR: Quarterback Rating (QB efficiency metric) |
psYds: Team sacks allowed | rsYds: Team rushing yards | rsTD: Team rushing TDs |
Receiving statistics were excluded from team analysis since the receiving statistics mirror the passing statistics. For example, receiving yards for each team is equal to passing yards.
BETTING MENU, TEAM vs OPPONENT ANALYSIS
To analyze what variables are correlated to beating a specific opponent, a “Winning” variable was created. A value of 1 or 0 was assigned so that correlations could be determined.
Then a variable correlation matrix was created/plotted so that the user can visualize how the variables are correlated to one another, specifically to beating the selected opponent.
Additionally, the correlations (values) to the “Winning” variable were extracted and presented in a table so that the user would readily have access to that information. See below for an example:
BETTING MENU, CURRENT SEASON ANALYSIS
The final feature of this Shiny web application allows the user to analyze the current season performance of the selected team and opponent. In the preceding features historical statistical information was analyzed, and the variable(s) most correlated to beating a specific opponent were obtained.
This feature presents how the selected team is performing and how the defense of the selected opponent is performing for a specific variable that the user can select.
Since the 2017 football season has not yet started, Week 12 of the 2016 season was arbitrarily selected and used in this example to present how the feature will operate.
FUTURE ITEMS TO ADDRESS
There is room for improvement for this Shiny Web application. The following items will be addressed:
- Load more years
- 5 years of historical data was limited. This provided for some missing and inaccurate correlations.
- Missing values
- Addressing missing values fell outside the scope of this project but will be addressed in the near future.
- Load more variables
- There are other variables that are likely correlated to performance/winning such as indoor vs outdoor, early season vs late season performance, etc.
The path forward for this web application would be to input sportsbook betting lines and predict scores of future games based on historical performance (both current season and prior seasons) via machine learning techniques.
Once betting line information is received and scores of games are predicted, the predicted score can be compared against the betting lines to determine which wagers have positive expected value (EV).