{"cells":[{"metadata":{"_uuid":"c8cfd05c379a90f87dd06085fae1f340694fc4b2"},"cell_type":"markdown","source":"# NFL Punt Analytics - Fair Catch or It's a Wrap\nWe were challenged to use data from the NFL to come up data-driven rule change suggestions to reduce concussions for punt plays. Based on our analysis we recomend the two following rule changes:\n1. Incentivize the use of fair catch by awarding the receiving team 10 yards for utilizing the option.\n2. Penalize teams for non-wrap tackles on the punt receiver.\n\n# Outline:\n* **Methods**\n* **Null Hypothesis**\n* **Data Analysis**\n    * **Statistically Insignificant Results**\n    * **Statistically Significant Results**\n* **Final Conclusion**\n* **Suggested Rule Changes**\n"},{"metadata":{"_uuid":"3cb60aed21bef71c8230219c77d46e9b5aad7f70"},"cell_type":"markdown","source":"# **Methods**\nThe following is a secondary analysis of NFL punt plays for the 2016 and 2017 seasons in respect to concussions.\n\nPlease refer to these links for further details of our analysis and for our code:\n\n[Data Analysis Plan](https://kaggle.com/mellamomark/nfl-punt-analytics-data-analysis-plan?scriptVersionId=9374968)\n\n[Game and Player Data Cleaning (Python)](https://kaggle.com/mellamomark/nflpuntanalytics-data-cleaning?scriptVersionId=9374625)\n* Please note that we accidently switched typical player role and punt role\n* We account for this mixup in our analysis\n\n[NGS Data Cleaning (Python)](https://kaggle.com/mellamomark/nfl-punt-analytics-combining-ngs-datasets?scriptVersionId=9370872)\n* We unfortunately did not get around to using this data but would love to integrate it in the future\n\n[Data Analysis Code (R)](https://kaggle.com/mellamomark/nfl-punt-analytics-analysis-code-r?scriptVersionId=9369213)\n"},{"metadata":{"_uuid":"20bd193d9e2541bd211c12f62c00910bbb543b6d"},"cell_type":"markdown","source":"# **Null Hypothesis**\n\n#### Null Hypothesis 1:\nPlayers with ball possession and players with no ball position have the same association for increased concussions during punt plays.\n\n#### Null Hypothesis 2:\nNFL games on turf fields and grass fields have the same association for increased concussions.\n\n#### Null Hypothesis 3:\n'Gunners' have the same association for increased concussion as other punt posiitons.\n\n#### Null Hypothesis 4:\nPlayers on the receiving side and kicking side of the play have the same association for increased concussions."},{"metadata":{"_uuid":"20129a80be2fc369d41a5ae0cbc84b6de902a62f"},"cell_type":"markdown","source":"# **Data Analysis**"},{"metadata":{"_uuid":"12479495ed7c88fa33b646f9a3c094f1a2ead7ef"},"cell_type":"markdown","source":"# *Importing Packages and Data*"},{"metadata":{"trusted":true,"_uuid":"79d60aec4f950e9888a41bac9841d21ceb6d1d07","_kg_hide-output":true,"_kg_hide-input":false},"cell_type":"code","source":"# Import Packages\nlibrary(ggplot2)\nlibrary(forcats)\n\n# Import Data\nnfl_final <- read.csv('../input/nflpuntanalytics-datacleaning/nfl_final.csv', header = T)\n\n# subsetting to dataframe to only players with concussion\n# still keeping column 'concussion_status'\nnfl_concussion <- subset(nfl_final, subset = concussion_status == 'concussion', select = c(Season_Year:concussion_status))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"b0f70e3bdc5f0d0786cd0935f53accd37e1f00e1"},"cell_type":"markdown","source":"# *Sample Size Calculation*\nOne of our biggest concerns was the small proportion of concussions in respect to the population and whether we can find statistically significant results.\n\nLogic regression requires a large sample size; below is the calculation to determine sample size based on number of dependent variables to find statistically significant results.\n\nsample size = ((10 * number of independent variables)/probability of least frequent outcome)"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3539e4dce21231ade8a5e48e708252d4cffb70fd"},"cell_type":"code","source":"sample_size_1 <- as.integer(((10*1)/(37/146573)))\nsample_size_2 <- as.integer(((10*2)/(37/146573)))\nsample_size_3 <- as.integer(((10*3)/(37/146573)))\nsample_size_4 <- as.integer(((10*4)/(37/146573)))\n\n# Assign names to x \nx <- c('1','2','3','4')\n# Assign names to y\ny <- c(sample_size_1, sample_size_2, sample_size_3, sample_size_4)\n# Create a non-empty data frame with column names \n# Assign x to \"First Name\" as column name \n# Assign y to \"Age\" as column name \nnedf <- data.frame( \"Number_Dependent_Variables\" = x, \"Required_Sample_Size\" = y)\n# Print the data frame\nnedf","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ed4bca9030d4a9b0d92e064cab0376b07130cfb6"},"cell_type":"markdown","source":"Our sample size is 146,573. Thus, we can use 3 dependent variables max in our logisitic regressions to find statistically significant results."},{"metadata":{"_uuid":"82fe6f9870d2f0a197f6c3884016952c509a0879"},"cell_type":"markdown","source":"# *Statistically Insignificant Results*"},{"metadata":{"_uuid":"60f79067a86c6730cc99b82762d6a26de6672a7a"},"cell_type":"markdown","source":"#### Null Hypothesis 1:\nPlayers with ball possession and players with no ball position have the same association for increased concussions during punt plays.\n* Defining players with ball possession as Punter and Kick Returner\n* Y value: 'concussion_status'; whether or not an individual has a concussion\n* X value: 'ball_posession'; was the player a Punter (P) or a Kick Returner (PR)\n* Stat Test: logisitc regression"},{"metadata":{"_uuid":"5d6d74e305ccaaa100acfe388a11f62d038c9d4b"},"cell_type":"markdown","source":"##### Simple Logistic Regression"},{"metadata":{"_kg_hide-output":false,"_kg_hide-input":true,"trusted":true,"_uuid":"7c2521a925f9e24d48d4c9e7be9a667ac3dbafb7"},"cell_type":"code","source":"nfl_ball <- nfl_final\n\n# Creating variable 'ball_posession'\nnfl_ball$ball_posession <- ifelse(nfl_ball$Role == \"P\" | nfl_ball$Role == \"PR\", 1, 0)\n\n# logistic regression\nball_glm <- glm(concussion_status ~ ball_posession, data = nfl_ball, family = binomial)\nsummary(ball_glm)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ac2de7fe66a74afd5dc1262c3dbd5a84ce9ff792"},"cell_type":"markdown","source":"Simple logistic regression resulted in p > 0.05, thus we cannot reject the null hypothesis. Maybe accounting for confounders might change things?"},{"metadata":{"_uuid":"8d879e27367f5996960ac92108158d403bb4a4e9"},"cell_type":"markdown","source":"##### Multiple Logistic Regression - Controlling for Quarter and StadiumType"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"5c6d4693e46b778ee793660cd11027d6a0a2b557"},"cell_type":"code","source":"ball_glm <- glm(concussion_status ~ \n                  ball_posession +\n                  Quarter +\n                  StadiumType,\n                data = nfl_ball,\n                family = binomial\n                )\nsummary(ball_glm)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e133c90aa25047a9345c79a2b6860cb96450bb43"},"cell_type":"markdown","source":"Controlling for confounders still resulted in p > 0.05, thus we cannot reject the null hypothesis.\n\nBased on the two tests, we conclude that ball posession is not associated with concussions among this population."},{"metadata":{"_uuid":"6a20577604cc00b3d827bf3610bdf72565fb8f64"},"cell_type":"markdown","source":"#### Null Hypothesis 2:\nNFL games on turf fields and grass fields have the same association for increased concussions.\n* Y value: 'concussion_status'; whether or not an individual has a concussion\n* X value: 'Turf'; was the playing field grass or turf\n* Stat Test: logisitc regression\n\nWe researched the provided turf brand names to help us clean the Turf column. Many of the turf companies promoted that their turf reduced concussions, thus this null hypothesis seeks to understand if their claims are true."},{"metadata":{"_uuid":"59b75709349077b19d853fdc464f45913d1c3ea5"},"cell_type":"markdown","source":"##### Simple Logistic Regression"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"e3b1e38a0da511df7acb965cb9ca54fb09340627"},"cell_type":"code","source":"nfl_turf <- nfl_final\n\n#Turning all variable labels into a coded number\nnfl_turf$Turf <- ifelse(nfl_final$Turf == \"Turf\", 1, 0)\n\n# logistic regression\nturf_glm <- glm(concussion_status ~ Turf, data = nfl_turf, family = binomial)\nsummary(turf_glm)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f8c9653c9a66ad26118b13346c064e1ff98f8050"},"cell_type":"markdown","source":"Simple logistic regression resulted in p > 0.05, thus we cannot reject the null hypothesis. Does accounting for confounders change things?"},{"metadata":{"_uuid":"04053c2f7c568ae143f727b59d94e1e18004a015"},"cell_type":"markdown","source":"##### Multiple Logistic Regression - Controlling for GameWeather"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"97d6ec96fd0da75f4eb42b1ac1214f9b7d56d540"},"cell_type":"code","source":"# Multiple logistic regression to adddress confounders\n# Controlling for GameWeather\nturf_glm <- glm(concussion_status ~ \n                  Turf +\n                  GameWeather +\n                  Turf*GameWeather,\n                data = nfl_turf,\n                family = binomial\n                )\nsummary(turf_glm)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"badeb0d09949dd5d191148fc241daece3481caf5"},"cell_type":"markdown","source":"Controlling for confounders still resulted in p > 0.05, thus we cannot reject the null hypothesis."},{"metadata":{"_uuid":"d6df08a7dee75119a22098f0be2c340cf136eecf"},"cell_type":"markdown","source":"#### Null Hypothesis 3:\n'Gunners' have the same association for increased concussion as other punt posiitons.\n* Y value: 'concussion_status'; whether or not an individual has a concussion\n* X value: 'gunner'; is the NFL player a 'punt returner'gunner' punt position\n* Stat Test: logisitc regression\n\nGunners are the players that sprint up the field after a punt to tackle the punt receiver. We were curious if this tackle-heavy position was associated with increased concussions."},{"metadata":{"_uuid":"5b737fee55cd9fee3e16f6ae7e0ce2c78021149d"},"cell_type":"markdown","source":"##### Simple Logistic Regression"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"6bb9805703a66f3a0d3bf21f313af4ab1ab42c9a"},"cell_type":"code","source":"nfl_gunner <- nfl_final\n\n# coding whether or not player is a gunner (GL or GR)\nnfl_gunner$gunner <- ifelse(nfl_gunner$Role == \"GL\" | nfl_gunner$Role == \"GR\", 1, 0)\n\n# logistic regression\ngunner_glm <- glm(concussion_status ~ gunner, data = nfl_gunner, family = binomial)\nsummary(gunner_glm)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"7b1aa6fb172736171fb6cbb9a9d940a056378648"},"cell_type":"markdown","source":"Simple logistic regression resulted in p > 0.05, thus we cannot reject the null hypothesis. Does accounting for confounders change things?"},{"metadata":{"_uuid":"eec86e580f4f9aba5ed30df3be2076b899f25c6a"},"cell_type":"markdown","source":"##### Multiple Logistic Regression - Controlling for Quarter and StadiumType"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"75c8c0739b363b08b2970f6a65ec5e3d3c09868c"},"cell_type":"code","source":"# Multiple logistic regression to adddress confounders\n# Controlling for Quarter and Stadium Type (i.e. indoor or outdoor)\ngunner_glm <- glm(concussion_status ~\n                gunner +\n                Quarter +\n                StadiumType,\n              data = nfl_gunner,\n              family = binomial\n              )\nsummary(gunner_glm)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6fe2ce5b95a335f9749e0ee5301bfd85ec221e1b"},"cell_type":"markdown","source":"Controlling for confounders still resulted in p > 0.05, thus we cannot reject the null hypothesis."},{"metadata":{"_uuid":"35411bd617a18a80d3073be6d1a3bd18b04475db"},"cell_type":"markdown","source":"# *Statistically Significant Results*"},{"metadata":{"_uuid":"7a5c8a9e7ef56314abef0bb745822a34ff1badc1"},"cell_type":"markdown","source":"#### Null Hypothesis 4:\nPlayers on the receiving side and kicking side of the play have the same association for increased concussions.\n* Y value: 'concussion_status'; whether or not an individual has a concussion\n* X value: 'side'; is the NFL player on recieving side or kicking side\n* Stat Test: logisitc regression"},{"metadata":{"_uuid":"3a7362b2f98848372fe610030a922acc08d0b59e"},"cell_type":"markdown","source":"##### Simple Logistic Regression"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"4a9d1f05e8be027c1c1d416f7417f199f3beee2e"},"cell_type":"code","source":"nfl_side <- nfl_final\n\n# coding whether or not player is on kicking or receiving side\n# 0 = kicking, 1 = receiving\nnfl_side$side <- ifelse(nfl_side$Role == \"GL\" |\n                          nfl_side$Role == \"PLW\" |\n                          nfl_side$Role == \"PLT\" |\n                          nfl_side$Role == \"PLG\" |\n                          nfl_side$Role == \"PLS\" |\n                          nfl_side$Role == \"PRG\" |\n                          nfl_side$Role == \"PRT\" |\n                          nfl_side$Role == \"PRW\" |\n                          nfl_side$Role == \"PC\" |\n                          nfl_side$Role == \"PPR\" |\n                          nfl_side$Role == \"P\" |\n                          nfl_side$Role == \"GR\",\n                        0, 1\n                        )\n\n# logistic regression\nside_glm <- glm(concussion_status ~ side, data = nfl_side, family = binomial)\nsummary(side_glm)\nprint(confint(side_glm))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"2297b9d46859cf8384f2d0bff09401788284686c"},"cell_type":"markdown","source":"p value = 0.0039, results are statistically significant.\n\nConverting log odds (i.e. logistic regression coefficient) to probability:"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"af9338f6e05c8bbd5e38394b0251f1a8179877d2"},"cell_type":"code","source":"print((exp(1.0694)/(1 + exp(1.0694))))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"928b8f9971e8fcd69d3839da8f78b57b55ec6a26"},"cell_type":"markdown","source":"Does controlling for observed confounders change anything?"},{"metadata":{"_uuid":"42c4119364b6af0917564e379c7bf2a2622f6dff"},"cell_type":"markdown","source":"##### Multiple Logistic Regression - Controlling for Quarter and StadiumType"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f928086d97acacad8e5e226acb07f4623f1f91a4"},"cell_type":"code","source":"# Multiple logistic regression to adddress confounders\n# Controlling for Quarter and Stadium Type (i.e. indoor or outdoor)\nside_glm <- glm(concussion_status ~\n                side +\n                Quarter +\n                StadiumType,\n              data = nfl_side,\n              family = binomial\n              )\n\nsummary(side_glm)\noptions(warn=-1) # turns off warning message\nprint(confint(side_glm))\noptions(warn=-0) # turns on warning message","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ce9673a50d35b078b25ff384e7dc6d3b7826fa76"},"cell_type":"markdown","source":"p value still 0.0039, results are statistically significant"},{"metadata":{"_uuid":"f6103fa45d504619cfd4058e6349c2f3ade44617"},"cell_type":"markdown","source":"***Based on these statistically significant results, we can state that being on the receiving side of a punt increased the odds of concussion by 74% among NFL punt plays for the 2016 and 2017 seasons.***\n\nWe decided to dig in a little deeper after finding these results to better understand what was happening. Therfore we decided to look at the punt receiver."},{"metadata":{"_uuid":"d848b8559dc90b10978a6e89e91dde73a5baa911"},"cell_type":"markdown","source":"#### Null Hypothesis 4.1:\nPunt returners have the same association for increased concussion as other punt positons.\n* Y value: 'concussion_status'; whether or not an individual has a concussion\n* X value: 'PR'; is the NFL player a punt returner\n* Stat Test: logisitc regression"},{"metadata":{"_uuid":"a8599e59f642e2db997c3604b968646d871d8de5"},"cell_type":"markdown","source":"##### Simple Logistic Regression"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"27c6b5fdde05f5413eb20b1d370cacfe74b8ebc2"},"cell_type":"code","source":"nfl_pr <- nfl_final\n\n# coding whether or not player is a punt returner (PR)\nnfl_pr$pr <- ifelse(nfl_pr$Role == \"PR\", 1, 0)\n\n# logistic regression\npr_glm <- glm(concussion_status ~ pr, data = nfl_pr, family = binomial)\nsummary(pr_glm)\nprint(confint(pr_glm))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"b61a946aea2af415c8ecff29425bfaf1f09bf46c"},"cell_type":"markdown","source":"p value = 0.0139, results are statistically significant.\n\nConverting log odds (i.e. logistic regression coefficient) to probability:"},{"metadata":{"trusted":true,"_uuid":"76407bd2f0e858cb00f59cb39ad9881a398e633b"},"cell_type":"code","source":"print((exp(-1.1832)/(1 + exp(-1.1832))))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"55cb6e4b37f18a8668140453f14daa1cf167d86b"},"cell_type":"markdown","source":"Does controlling for observed confounders change anything?"},{"metadata":{"_uuid":"36a5e1209dea680d94dbbbd5aa6ec38367fcd696"},"cell_type":"markdown","source":"##### Multiple Logistic Regression - Controlling for Quarter and StadiumType"},{"metadata":{"trusted":true,"_uuid":"2f78e656c0cabab9b9c1ebef2e923d46e2e0cd78"},"cell_type":"code","source":"pr_glm <- glm(concussion_status ~\n                pr +\n                Quarter +\n                StadiumType,\n              data = nfl_pr,\n              family = binomial\n              )\nsummary(pr_glm)\noptions(warn=-1) # turns off warning message\nprint(confint(pr_glm))\noptions(warn=-0) # turns on warning message","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0a39e9a73917965c945e0932dcfd4b2efe4f511e"},"cell_type":"markdown","source":"p value still 0.0139, results are statistically significant."},{"metadata":{"_uuid":"f6bdca9e73692879d736c976e2588792e909b7e5"},"cell_type":"markdown","source":"***Based on these statistically significant results, we can state that being punt receiver increased the odds of concussion by 23% among NFL punt plays for the 2016 and 2017 seasons.***"},{"metadata":{"_uuid":"837bbcc2d4c48730cdc27b76664ac4c5901548ea"},"cell_type":"markdown","source":"# Data Visualization"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"6845d1e34aa39715b9fbee6a700a1ee2f108247a"},"cell_type":"code","source":"## Turf\n\nturf.plt <- \n  ggplot(nfl_concussion, aes(Turf)) +\n  geom_bar() + \n  labs(x = \"Turf Type\",\n       y = 'Number of Concussions',\n       title = 'Total Number of Punt Play Concussions by Turf Type',\n       subtitle = '2016-2017 Seasons Combined'\n       ) +\n  scale_y_continuous(breaks = seq(1, 30, by = 2))\n\nturf.plt","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"a7c766d5b9905acc994aebabf52d715c5bc1753f"},"cell_type":"code","source":"## Punt_Position\n\nnfl_concussion$Role <- fct_infreq(nfl_concussion$Role)\npunt_position.plt <- \n  ggplot(nfl_concussion, aes(Role)) +\n  geom_bar() + \n  labs(x = \"Punt Position\",\n       y = 'Number of Concussions',\n       title = 'Total Number of Punt Play Concussions by Punt Position',\n       subtitle = '2016-2017 Seasons Combined'\n  ) +\n  scale_y_continuous(breaks = seq(1, 10, by = 1))\n\npunt_position.plt","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"2e63d50d2e913388fb29fa7c381daad0741656c2"},"cell_type":"code","source":"## Player_Activity_Derived\n\nnfl_concussion$Player_Activity_Derived <- fct_infreq(nfl_concussion$Player_Activity_Derived)\nplayer_activity.plt <- \n  ggplot(nfl_concussion, aes(Player_Activity_Derived)) +\n  geom_bar() + \n  labs(x = \"Player Activity\",\n       y = 'Number of Concussions',\n       title = 'Total Number of Punt Play Concussions by Player Activity',\n       subtitle = '2016-2017 Seasons Combined'\n  ) +\n  scale_y_continuous(breaks = seq(1, 30, by = 2))\n\nplayer_activity.plt","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"1e68a11364b1e0961da487c290a2894b74d85b0f"},"cell_type":"markdown","source":"# Final Conclusion\nFrom our analysis we determined the following:\n* Player ball possession durring punt plays was not associated with increased concussions.\n* Though many turf companies market that their products reduce concussions, type of grass fields were not associated with increased concussions compared to turf fields.\n* We were honestly suprised that gunner punt positions were not associated with increased concussions either.\n* Finally, we determined that punt returners had significant risk for concussions durring punt plays.\n\nBased on these conclusions, our suggested rule changes focused on how we can mitage risk for punt returners durring punt plays."},{"metadata":{"_uuid":"60bcd15749866a5b6b50710d5ccad64901b0797c"},"cell_type":"markdown","source":"# Suggested Rule Changes"},{"metadata":{"_uuid":"8c6c1761211ca3eadf2ce8493be570d19df262cd"},"cell_type":"markdown","source":"### 1. Incentivize the use of fair catch by awarding the receiving team 10 yards for utilizing the option.\n\nFair catch is a rule already in place that reduces the chances of concussions among punt receivers. We are hoping our suggested rule change nudges players to engage in safer plays to reduce their risk of receiving a concussion. In respect to gameplay, we believe this can also add an element of strategy for teams in which they must decide if they want a secured 10 yards or play for the possibiility of even more yard gain by running the ball.\n\n### 2. Penalize teams for non-wrap tackles on the punt receiver.\n\nTackles in which the tackeler wraps the oppenent reduces the chance of the tackeler or the tackled from engaging in head-to-head collisions. Similar to the previous rule suggestion, we hope that penalizing non-wrap tackles on the punt reciever can nudge players towards safer tackeling behaviors and prevent concussions."}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":1}