Abstract

For Project 1, we are using hockey shot data supplied from moneypuck. The data represents all shots in the NHL from the 2007-08 season up until to the current season and is updated nightly. For our project, we are focusing on all shots from the 2007-08 season. For each shot, there are 124 features and there are saved shots on goal, missed shots and goals included. Waris will be analyzing the data through a multiple regression fit, a ridge regression fit, and a LOESS fit. Cameron will be analyzing the data through a kNN classification, a Naive Bayes classification, and a classification using Logistic Regression.

Classification Section:

For the Classification aspect of the project we want to see how much does home field advantage really matter in the NHL? To do this, we will be testing the three classification methods to see which one classifies the best using the attributes found in the dataset and seeing if the classification models are useful models to predict future outcomes. The attributes we’ll be using is the home or away where we will encode a dummy variable with 1 for a home game and 0 for an away game and predicte it based off the goals for the home team and the goals against the home team.

ABSTRACT:

For Project 1, we are using hockey shot data supplied from moneypuck. The data represents all shots in the NHL from the 2007-08 season up until to the current season and is updated nightly. For our project, we are focusing on all shots from the 2007-08 season. For each shot, there are 124 features and there are saved shots on goal, missed shots and goals included. Waris will be analyzing the data through a multiple regression fit, a ridge regression fit, and a LOESS fit. Cameron will be analyzing the data through a kNN classification, a Naive Bayes classification, and a classification using Logistic Regression.

Classification Section:

For the Classification aspect of the project we want to see how much does home field advantage really matter in the NHL? To do this, we will be testing the three classification methods to see which one classifies the best using the attributes found in the dataset and seeing if the classification models are useful models to predict future outcomes. The attributes we’ll be using is the home or away where we will encode a dummy variable with 1 for a home game and 0 for an away game and predicte it based off the goals for the home team and the goals against the home team.

kNN classification

kNN Discussion:

The kNN model seems to not have any legible conclusions. The model seems to not perform well given the parameters and the cause may be bad parameters, or kNN being not a good model to discuss the relationship between home teams and scoring and defending shots.

KNN Plot


Naive Bayes Classification

Naive Bayes Discussion:

Using the Naive Bayes method gave us some indication that home advantages aren’t that effective in helping a home team overcome an away team. In the confustion matrix we can see that the predicted vs. actual for home teams was only 38%. These results show that it may not prove useful to predict whether a team was home or away by the goals scored against it and for it. Which isn’t what we believed may happen because in thought, it may seem that win a team is home, the home crowd will put the away team on edge and may make them play worse or allow the home players to play more comfortably than normal. And while these still could be true, it doesn’t seem to have a large affect on wheter a team will defend better and score better at home.

Cross Table


 
   Cell Contents
|-------------------------|
|                       N |
|           N / Col Total |
|-------------------------|

 
Total Observations in Table:  3286 

 
             | actual 
   predicted |      AWAY |      HOME | Row Total | 
-------------|-----------|-----------|-----------|
        AWAY |      1119 |      1024 |      2143 | 
             |     0.684 |     0.620 |           | 
-------------|-----------|-----------|-----------|
        HOME |       516 |       627 |      1143 | 
             |     0.316 |     0.380 |           | 
-------------|-----------|-----------|-----------|
Column Total |      1635 |      1651 |      3286 | 
             |     0.498 |     0.502 |           | 
-------------|-----------|-----------|-----------|

 

Logistic Regression Classification

Column

Summary of Logistic Regression

Logistic Regression Discussion:

For the Logistic Regression, we can see the linear relationship goalsFor has with being home or away which suggests that there is some positive relationship with home teams scoring more and the relationship that away teams are letting in more goals. Our model with goals against and goals for seems like a good model, but there may be some other variables not in the dataset or discussed here that also have an impact on predicting and classifying home and away teams.

Column

Logistic Regression Plot

GOF Test


    Hosmer and Lemeshow goodness of fit (GOF) test

data:  modelglm$y, modelglm$fitted.values
X-squared = 4.3741, df = 2, p-value = 0.1122

Total Goal Factors

Total Goal Factors Analysis

In this part of the project we sought to analyze which factors have the greatest impact on the amount of points scored by a team in a given game. The potential factors we considered in this model were the following:

Fenwick Percentage:

The percentage of all taken shots by a team vs their opponent. This value represents how offensive a team is and how often their actively controlling the puck.

Ice Time:

This is the amount of time (in minutes) a team spends on ice. Not all games have the same amount of time played, as overtime and penalties can occur.

Penalties For:

This is the amount of penalties that the team commits.

Giveaways For:

This value represents the amount of times that the puck was intercepted into the players possession

Giveaways Against:

This value represents the amount of times that the puck was intercepted out of the players possession

Missed Shots Against:

This is specifically the amount of shots that the enemy team misses against their goal.

Using a stepwise regression it was found that Giveaways against was not significant at the \(\alpha\) = 0.05 level. However the rest were found to have some relationship. Analyzing these relationships, it can be seen that the Fenwick Percentage has the greatest affect on increasing the total goals scored. Furthermore, penalties received to the team actually has a negative effect on total points scored. This could be because the interceptions may not always be at an advantageous position, and the players need to process that possession has switched. The rest of the variables seemed to have some positive correlation to points scored, except for time spent on ice, which is near 0.

#Row

Model Info


Call:
lm(formula = y ~ fenwickPercentage + iceTime + penaltiesFor + 
    giveawaysAgainst + missedShotsAgainst, data = teams_sample)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.9544 -0.5533 -0.1096  0.4157  6.8243 

Coefficients:
                      Estimate  Std. Error t value             Pr(>|t|)    
(Intercept)        -0.17688116  0.05222862  -3.387             0.000721 ***
fenwickPercentage   0.68288825  0.08434544   8.096 0.000000000000000975 ***
iceTime             0.00044780  0.00004413  10.146 < 0.0000000000000002 ***
penaltiesFor        0.04626036  0.01848080   2.503             0.012388 *  
giveawaysAgainst    0.01754259  0.00861745   2.036             0.041912 *  
missedShotsAgainst  0.03915313  0.00949174   4.125 0.000038601562506362 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.097 on 1994 degrees of freedom
Multiple R-squared:  0.481, Adjusted R-squared:  0.4797 
F-statistic: 369.6 on 5 and 1994 DF,  p-value: < 0.00000000000000022

Fenwick Plot

Ice Time Plot

Penalty Plot

Give Aways Plot

Missed Shots Plot


Fenwick and Penalties

Applying Fenwick with Penalties

Column

Now that the importance of the Fenwick percentage has been identified, we can take this a step further to see how it interacts with other variables. There is a common belief among hockey fans that the more penalty time a team receives, the better off the other team is. To analyze the truth of this a plot was made with the Fenwick percent with respect to Penalty Minutes (The amount of time the opposing team spent in penalty). Firstly, plotting the data reveals that there is a non-linear relationship between the Fenwick percent and the amount of penalties the other team has received. Using a LOESS regression, the data can be modeled as the red plot. That plot can then be used to find the penalty amount that optimizes the Fenwick value, which would lead to a much higher score. It was found that the percent has a maximum at around 0.51 penalty minutes with a percent of 7.1. After that, the percentage takes a steep decline again. So the benefit is not constantly increasing. The percent likely drops so steeply because if there are constant penalties the game will be less competitive, resulting in fewer passes among players.

Column

LOESS Plot

Summary Statistics

Call:
loess(formula = y ~ x)

Number of Observations: 2000 
Equivalent Number of Parameters: 4.44 
Residual Standard Error: 4.45 
Trace of smoother matrix: 4.83  (exact)

Control settings:
  span     :  0.75 
  degree   :  2 
  family   :  gaussian
  surface  :  interpolate     cell = 0.2
  normalize:  TRUE
 parametric:  FALSE
drop.square:  FALSE 
[1] "The Maximum Fenwick Percent is: 7.3"

Ridge Regression

Row

Info

Shot Risks

In Hockey, shots taken by players to the goal are divided into the categories low, medium, and high danger. These represent the amount of risk involved in taking the shot. Sports analysts use this value to determine how risky or offensive a given player or team is. In this part, we sought to create a model that can accurately calculate the amount of goals using the frequency of the type of goals shot, and find which strategy is best. This is not possible with MLR because the variables are so correlated with each other, but the lambda regularization parameter helps mitigate this to help deal with overfitting and multicollinearity.

Analysis:

Analyzing the coefficients of the model, it can be seen that low danger shots tend to lead to a higher total amount of points. This means that the high risk of taking guarded or far shots is not commonly rewarded, and players are likely better off making passes to advantageous positions.

Row

Ridge Summary

          Length Class     Mode   
a0        100    -none-    numeric
beta      300    dgCMatrix S4     
df        100    -none-    numeric
dim         2    -none-    numeric
lambda    100    -none-    numeric
dev.ratio 100    -none-    numeric
nulldev     1    -none-    numeric
npasses     1    -none-    numeric
jerr        1    -none-    numeric
offset      1    -none-    logical
call        4    -none-    call   
nobs        1    -none-    numeric

Coefficient Analysis

[1] "The Mean Squared Error for this Model is 1.31"
3 x 100 sparse Matrix of class "dgCMatrix"
                                                                             
lowDangerGoalsFor    0.000000000000000000000000000000000001484071 0.002235898
mediumDangerGoalsFor 0.000000000000000000000000000000000001477836 0.002226513
highDangerGoalsFor   0.000000000000000000000000000000000001385330 0.002087325
                                                                    
lowDangerGoalsFor    0.002453365 0.002691927 0.002953618 0.003240666
mediumDangerGoalsFor 0.002443068 0.002680630 0.002941224 0.003227070
highDangerGoalsFor   0.002290361 0.002513097 0.002757433 0.003025451
                                                                    
lowDangerGoalsFor    0.003555513 0.003900831 0.004279543 0.004694851
mediumDangerGoalsFor 0.003540598 0.003884469 0.004261596 0.004675166
highDangerGoalsFor   0.003319431 0.003641871 0.003995503 0.004383321
                                                                    
lowDangerGoalsFor    0.005150255 0.005649585 0.006197028 0.006797158
mediumDangerGoalsFor 0.005128665 0.005625907 0.006171062 0.006768685
highDangerGoalsFor   0.004808596 0.005274909 0.005786175 0.006346673
                                                                               
lowDangerGoalsFor    0.007454975 0.008175933 0.008965989 0.009831640 0.01077997
mediumDangerGoalsFor 0.007423754 0.008141704 0.008928466 0.009790509 0.01073489
highDangerGoalsFor   0.006961079 0.007634498 0.008372504 0.009181180 0.01006716
                                                                           
lowDangerGoalsFor    0.01181868 0.01295618 0.01420161 0.01556487 0.01705676
mediumDangerGoalsFor 0.01176928 0.01290206 0.01414231 0.01549992 0.01698563
highDangerGoalsFor   0.01103766 0.01210055 0.01326441 0.01453852 0.01593301
                                                                           
lowDangerGoalsFor    0.01868895 0.02047410 0.02242591 0.02455915 0.02688978
mediumDangerGoalsFor 0.01861107 0.02038886 0.02233261 0.02445708 0.02677814
highDangerGoalsFor   0.01745884 0.01912790 0.02095306 0.02294823 0.02512841
                                                                           
lowDangerGoalsFor    0.02943496 0.03221315 0.03524410 0.03854897 0.04215031
mediumDangerGoalsFor 0.02931290 0.03207973 0.03509834 0.03838978 0.04197654
highDangerGoalsFor   0.02750978 0.03010974 0.03294695 0.03604139 0.03941442
                                                                           
lowDangerGoalsFor    0.04607210 0.05033976 0.05498013 0.06002143 0.06549321
mediumDangerGoalsFor 0.04588251 0.05013302 0.05475483 0.05977607 0.06522617
highDangerGoalsFor   0.04308877 0.04708856 0.05143935 0.05616803 0.06130283
                                                                           
lowDangerGoalsFor    0.07142619 0.07785221 0.08480396 0.09231478 0.10041837
mediumDangerGoalsFor 0.07113581 0.07753670 0.08446146 0.09194335 0.10001600
highDangerGoalsFor   0.06687324 0.07290985 0.07944423 0.08650872 0.09413614
                                                                      
lowDangerGoalsFor    0.1091484 0.1185381 0.1286197 0.1394242 0.1509800
mediumDangerGoalsFor 0.1087130 0.1180676 0.1281120 0.1388770 0.1503912
highDangerGoalsFor   0.1023595 0.1112117 0.1207250 0.1309304 0.1418573
                                                                      
lowDangerGoalsFor    0.1633131 0.1764456 0.1903954 0.2051750 0.2207909
mediumDangerGoalsFor 0.1626807 0.1757675 0.1896697 0.2044000 0.2199651
highDangerGoalsFor   0.1535327 0.1659806 0.1792213 0.1932704 0.2081379
                                                                      
lowDangerGoalsFor    0.2372426 0.2545219 0.2726124 0.2914885 0.3111154
mediumDangerGoalsFor 0.2363647 0.2535909 0.2716277 0.2904499 0.3100230
highDangerGoalsFor   0.2238282 0.2403381 0.2576573 0.2757668 0.2946390
                                                                      
lowDangerGoalsFor    0.3314483 0.3524332 0.3740065 0.3960956 0.4186198
mediumDangerGoalsFor 0.3303030 0.3512362 0.3727596 0.3948012 0.4172810
highDangerGoalsFor   0.3142375 0.3345161 0.3554200 0.3768851 0.3988395
                                                                      
lowDangerGoalsFor    0.4414914 0.4646168 0.4878978 0.5112339 0.5345232
mediumDangerGoalsFor 0.4401118 0.4632004 0.4864495 0.5097587 0.5330268
highDangerGoalsFor   0.4212034 0.4438909 0.4668107 0.4898678 0.5129650
                                                                      
lowDangerGoalsFor    0.5576648 0.5805601 0.6031148 0.6252403 0.6468549
mediumDangerGoalsFor 0.5561530 0.5790392 0.6015911 0.6237202 0.6453448
highDangerGoalsFor   0.5360045 0.5588895 0.5815259 0.6038237 0.6256983
                                                                      
lowDangerGoalsFor    0.6678851 0.6882661 0.7079427 0.7268693 0.7450100
mediumDangerGoalsFor 0.6663910 0.6867940 0.7064982 0.7254574 0.7436355
highDangerGoalsFor   0.6470719 0.6678744 0.6880437 0.7075270 0.7262803
                                                                      
lowDangerGoalsFor    0.7623384 0.7788374 0.7944982 0.8093200 0.8233088
mediumDangerGoalsFor 0.7610054 0.7775494 0.7932581 0.8081302 0.8221711
highDangerGoalsFor   0.7442689 0.7614667 0.7778565 0.7934291 0.8081826
                                                                      
lowDangerGoalsFor    0.8364772 0.8488427 0.8604277 0.8712580 0.8813624
mediumDangerGoalsFor 0.8353926 0.8478121 0.8594511 0.8703352 0.8804927
highDangerGoalsFor   0.8221218 0.8352578 0.8476065 0.8591885 0.8700278
                                                                      
lowDangerGoalsFor    0.8907720 0.8995192 0.9076375 0.9151608 0.9221230
mediumDangerGoalsFor 0.8899544 0.8987523 0.9069197 0.9144904 0.9214981
highDangerGoalsFor   0.8801516 0.8895890 0.8983712 0.9065299 0.9140980
                                                                      
lowDangerGoalsFor    0.9285578 0.9344979 0.9399755 0.9450215 0.9496655
mediumDangerGoalsFor 0.9279762 0.9339576 0.9394743 0.9445573 0.9492361
highDangerGoalsFor   0.9211080 0.9275925 0.9335835 0.9391124 0.9442093
                              
lowDangerGoalsFor    0.9539360
mediumDangerGoalsFor 0.9535393
highDangerGoalsFor   0.9489035

==================