Skip to content

Instantly share code, notes, and snippets.

View friscojosh's full-sized avatar
🏈
Triggering the innumerates & rubes

Josh Hermsmeyer friscojosh

🏈
Triggering the innumerates & rubes
View GitHub Profile
@friscojosh
friscojosh / WOPR Stability
Last active January 27, 2021 16:13
WOPR year over year stability analysis
############################################################################
#### Grab airyards data from airyards.com and test the year-to-year
#### stability of WOPR (Weighted Opportunity Rating)
############################################################################
library(tidyverse)
library(jsonlite)
## define a function that uses jsonlite to call the airyards.com
## API and returns the processed JSON as a dataframe.
library(tidyverse)
passes <- read_csv('data/third_and_long_pass_plays.csv')
grouped_passes <- passes %>%
group_by(air_yards) %>%
summarize(catch_rate = mean(passing_cmp)) %>%
filter(air_yards !=0) %>%
filter(air_yards >= -4)
@friscojosh
friscojosh / true_td_rate
Created February 13, 2018 21:00
Use empirical priors to find true td rates for NFL Qbs
library(ggplot2)
library(tidyverse)
library(ebbr)
### SQL to generate the data from nfldb. https://github.com/BurntSushi/nfldb
# SELECT a.player_id , b.full_name ,a.passing_att, a.passing_tds
# FROM play_player a
# INNER JOIN player b ON a.player_id = b.player_id
# INNER JOIN game c ON a.gsis_id = c.gsis_id
@friscojosh
friscojosh / 0_reuse_code.js
Created February 24, 2017 19:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Player Team Tgt Rec Catch% Contested Catch% Yds YAC Juke Rate TD Air Yards Tgt Share MS Air aYPT RACR WOPR
Tyler Byrd TENN 21 13 62% 0% 201 136 62% 0 116 0.07 0.05 5.5 1.74 0.14
Alvin Kamara TENN 32 22 69% 0% 256 281 55% 3 13 0.11 0.01 0.4 20.00 0.17
De'Veon Smith MICH 20 16 80% 0% 66 85 50% 0 -8 0.05 -0.00 -0.4 -8.25 0.08
Joshua Jacobs BAMA 19 14 74% 0% 166 189 50% 0 -4 0.05 -0.00 -0.2 -43.68 0.07
Samaje Perine OKLA 11 10 91% 100% 106 113 50% 1 -14 0.03 -0.00 -1.3 -7.41 0.04
Justin Davis USC 20 15 75% 100% 112 131 47% 0 -10 0.04 -0.00 -0.5 -11.20 0.06
Jalen Greene USC 16 9 56% 17% 116 53 44% 0 182 0.03 0.05 11.4 0.64 0.08
Mykel Jones OKLA 16 13 81% 40% 106 81 38% 0 110 0.04 0.03 6.9 0.96 0.08
Damien Harris BAMA 16 13 81% 0% 106 166 38% 2 -37 0.04 -0.01 -2.3 -2.88 0.05
@friscojosh
friscojosh / Complex year over year
Created June 23, 2016 18:13
SQL to do complex year over year queries
SELECT a.player, a.fname, a.lname, a.year, a.top12
, b.year, b.top12
FROM
(SELECT __top12_weeks_WR.*
FROM __top12_weeks_WR)a
INNER JOIN
@friscojosh
friscojosh / Age adusted year over year
Created June 23, 2016 18:13
SQL for age adusted y/y queries
SELECT *
FROM __pff_grades
WHERE pid IN (
SELECT __pff_grades.pid
FROM __pff_grades
INNER JOIN player
ON __pff_grades.pid = player.player
WHERE __pff_grades.season BETWEEN 2011 AND 2015 && pos1 ='RB' && __pff_grades.age = 22
)
&& __pff_grades.season BETWEEN 2011 AND 2015 && __pff_grades.age = 21