NFL Statistics: An Exploratory Data Analysis

Posted on Aug 29, 2017

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). Β Β Β 

The skills the author demonstrated here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

About Author

Andre Toujas

β€œWhy?” The question β€œwhy” has always intrigued Andre. That simple question is what made Andre pursue his degree in mechanical engineering, and answering β€œwhy” is what drives him as a data scientist. Two of his four NYCDSA projects...
View all posts by Andre Toujas >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI