Here are the results of my 6 hour hacking…

Final Presentation:

1

2

3

Game plan:

-Open given files find which game would relate to down the stretch-ness the most

1/25/2016 Kings vs. Hornets 85-99

1/31/2016 Lakers vs. Hornets 82-101

2/3/2016 Kings vs. Bulls 102-107—3rd quarter 75 vs 80

2/6/2016 Cavs vs. Pelicans

2/10/2016 Trail Blazers vs. Rockets

-put all player info for both teams in sas to find the coefficients

-use coefficients to scale to 0-1

-make sure to check adjusted r squared value

-calculate each term

-to plot

-pull career free throw averages from nba stats

-plot

-screenshot

-research judges

Excel:

screenshot-2017-03-03-at-9-31-11-am

SAS:

data hackathon;

input drebp deffouls charges win;

datalines;

0.1538461538 0 0 1

0.1538461538 0.2 0 1

0.2820512821 0.2 0.5 1

0.1025641026 0.2 0.5 1

0.1025641026 0.06666666666667 0 1

0.05128205128 0.0666666666667 0 1

0.05128205128 0.0666666666667 0 1

0.07692307692 0.2 0 1

0.02564102564 0.0666666666667 0 1

0.08333333333 0.3 0 0  

0.22222222222 0.1 0 0  

0.08333333333 0.15 0 0

0.11111111111 0.15 0 0

0.02777777778 0.15 0 0

0.16666666667 0.05 0 0

0.05555555556 0 0 0  

0.13888888889 0.05 0 0

0.11111111111 0.05 0 0  

;

proc print data= hackathon;

run;

proc corr data=hackathon;

var drebp deffouls charges;

with win;

run;

proc reg data= hackathon;

model win= deffouls drebp charges;

run;

proc logistic data=hackathon;

model win= deffouls drebp charges/

selection = ADJRSQ best = 3;

R code:

#Y Variable Calculations:

#vectors calculated on excel  

bullsdreb = c(0.1538461538, 0.1538461538, 0.2820512821, 0.1025641026, 0.1025641026, 0.05128205128,0.05128205128, 0.07692307692, 0.02564102564)

kingsdreb = c(0.0833333333, 0.22222222222, 0.0833333333, 0.1111111111, 0.027777777777, 0.166666666666, 0.0555555555, 0.138888888, 0.1111111)

bullsdeffouls = c(0, 0.2, 0.2, 0.2, 0.0666666666, 0.06666666666, 0.06666666, 0.2, 0.066666666)

kingsdeffouls = c(0.3, 0.1, 0.15, 0.15, 0.15, 0.05, 0, 0.05, 0.05)

bullscharges = c(0,0,0.5,0.5,0,0,0,0,0)

kingscharges = c(0,0,0,0,0,0,0,0,0)

#correlation coefficients calculated on SAS

DReb_coeff= -9.0429

DFouls_coeff= 3.31426

CDrawn_coeff= -2.76100

#Defensive Rebounds Percentage with weight calculated

bullsdreb_plot = DReb_coeff* bullsdreb

kingsdreb_plot = DReb_coeff* kingsdreb

#Defensive Fouls Percentage with weight calcuated

bullsdeffouls_plot = DFouls_coeff * bullsdeffouls

kingsdeffouls_plot = DFouls_coeff * kingsdeffouls

#Charges Drawn Percentage with weight calcuated

bullscharges_plot = CDrawn_coeff*bullscharges

kingscharges_plot = CDrawn_coeff*kingscharges

#Sloppiness Totals Unscaled but Weighted

bulls_yplot = bullsdreb_plot + bullsdeffouls_plot + bullscharges_plot

kings_yplot = kingsdreb_plot + kingsdeffouls_plot + kingscharges_plot

#Scaling Sloppiness from 0 to 1

#find min/max for both teams

minslop_bulls = min(bulls_yplot)

maxslop_bulls = max(bulls_yplot)

minslop_kings = min(kings_yplot)

maxslop_kings = max(kings_yplot)

#scale by adding factor

factor= 4

minslop_bullsf = factor + minslop_bulls

maxslop_bullsf = factor + maxslop_bulls

minslop_kingsf = factor + minslop_kings

maxslop_kingsf = factor + maxslop_kings

#y points for vectors calculated

bulls_ypoints = factor + bulls_yplot

kings_ypoints = factor + kings_yplot

#y points starters and non-starters division

bulls_starters = bulls_ypoints[1:5]

bulls_nstarts = bulls_ypoints[6:9]

kings_starters = kings_ypoints[1:5]

kings_nstarters = kings_ypoints[6:9]

#starters scale due to more PT

#bulls_starterf = bulls_starters -1.5

#kings_starterf = kings_starters -1.5

#starters scale due to more PT

#calculated from excel

bullsptscale = c(0.45833, 0.708333, 0.770833, 0.770833, 0.541666, 0.41666, 0.5, 0.375, 0.20833)

kingsptsscale = c(0.6666, 0.791666, 0.375, 0.75, 0.645833, 0.52083, 0.604166, 0.3125, 0.3541666)

#starters PT scale

bullsstartpt = 1 + bullsptscale[1:5]

kingsstartpt = 1 + kingsptsscale[1:5]

#non staters PT scale

bulls_pt = bullsptscale[6:9]

kings_pt = kingsptsscale[6:9]

bulls_starterf = bulls_starters – bullsstartpt

kings_starterf = kings_starters – kingsstartpt

Plot Code:

x = c(80, 69, 75, 74, 82)

y = c(bulls_starterf)

d = c(71, 85, 80, 83)

e = c(bulls_nstarts)

a = c(80, 74, 64, 83, 61)

b = c(kings_starterf)

f = c(67, 85, 60, 78)

g = c(kings_nstarters)

plot(x,y, main=”Down the Stretch Decisions”, xlab=”Career Free Throw % “,xlim=c(60,86), ylab=”Defensive Sloppiness”,ylim=c(4.5,0),col= “red”, pch=19, cex=5)

names= c(“20”, “22”, “16”, “55”, “1”)

points(a,b,col= “blue”, pch=19, cex=5)

words= c(“8”, “15”, “0”, “3”, “9”)

points(d,e,col= “red”, pch=19, cex=3)

titles= c(“5”, “3”, “12”, “0”)

points(f,g, col= “blue”, pch=19, cex=3)

labls= c(“18”, “7”, “41”, “23”)

text(x, y, labels=names)

text(a, b, labels=words)

text(d, e, labels=titles)

text(f, g, labels= labls)

legend(“topleft”, inset= c(0, 0) , c(“Kings”, “Bulls”), fill= c(“blue”,”red”), horiz=TRUE)

 

Advertisements