This file contains results from the model used to predict NHL Teams’ win percentage, which is based on the Elo rating system. In essence, each hockey team gets assigned a rating which is used to predict the chances that team has to win both during the regular season as well as in the playoffs. To start the season, each team will get a numerical rating somewhere in the area of 1500. The Elo rating gets modified based on adjustments such as home-ice advantage (home team gets additional points) and point reduction for teams who are favorites and win by several goals; this is done to prevent lopsided results. The data in this file yields the results of thousands of performed simulations which are based on the actual past results of the teams. The teams with the higher win percentage in regular season simulations are the more likely ones to make the playoffs. It is also important to note that every team’s ELO rating is dynamic and changes based on the results of the previous game. This is the link to the article: https://fivethirtyeight.com/methodology/how-our-nhl-predictions-work/
# The data set used
nhl_elo <- read.csv("https://raw.githubusercontent.com/GitHub-Vlad/Data-Science/87b4529ea4714f88b4c020d10ea5693ec194c20e/nhl_elo_latest.csv", header = TRUE)
#Display the first 10 rows of the original data set
head(nhl_elo,10)
## season date playoff neutral status ot home_team
## 1 2022 2021-10-12 0 0 post Tampa Bay Lightning
## 2 2022 2021-10-12 0 0 post Vegas Golden Knights
## 3 2022 2021-10-13 0 0 post Toronto Maple Leafs
## 4 2022 2021-10-13 0 0 post Washington Capitals
## 5 2022 2021-10-13 0 0 post Colorado Avalanche
## 6 2022 2021-10-13 0 0 post Anaheim Ducks
## 7 2022 2021-10-13 0 0 post SO Edmonton Oilers
## 8 2022 2021-10-14 0 0 post Buffalo Sabres
## 9 2022 2021-10-14 0 0 post OT New York Rangers
## 10 2022 2021-10-14 0 0 post OT Florida Panthers
## away_team home_team_abbr away_team_abbr home_team_pregame_rating
## 1 Pittsburgh Penguins TBL PIT 1567.700
## 2 Seattle Kraken VEG SEA 1560.471
## 3 Montreal Canadiens TOR MTL 1530.745
## 4 New York Rangers WSH NYR 1531.924
## 5 Chicago Blackhawks COL CHI 1565.298
## 6 Winnipeg Jets ANA WPG 1451.045
## 7 Vancouver Canucks EDM VAN 1516.160
## 8 Montreal Canadiens BUF MTL 1448.106
## 9 Dallas Stars NYR DAL 1507.136
## 10 Pittsburgh Penguins FLA PIT 1531.710
## away_team_pregame_rating home_team_winprob away_team_winprob overtime_prob
## 1 1539.108 0.6112121 0.3887879 0.2305011
## 2 1489.804 0.6669926 0.3330074 0.2234528
## 3 1503.670 0.6091345 0.3908655 0.2307582
## 4 1511.149 0.6004676 0.3995324 0.2318276
## 5 1482.373 0.6824761 0.3175239 0.2214286
## 6 1507.939 0.4900796 0.5099204 0.2428666
## 7 1481.604 0.6193389 0.3806611 0.2294926
## 8 1501.851 0.4946108 0.5053892 0.2434200
## 9 1504.687 0.5749131 0.4250869 0.2349581
## 10 1545.712 0.5516200 0.4483800 0.2377935
## home_team_expected_points away_team_expected_points home_team_score
## 1 1.311921 0.9182729 2
## 2 1.408418 0.8150995 4
## 3 1.308496 0.9223427 2
## 4 1.293629 0.9383772 5
## 5 1.435292 0.7862332 4
## 6 1.103888 1.1387556 4
## 7 1.326066 0.9035040 3
## 8 1.112243 1.1311766 5
## 9 1.249704 0.9852542 2
## 10 1.209862 1.0279316 5
## away_team_score home_team_postgame_rating away_team_postgame_rating
## 1 6 1561.096 1545.712
## 2 3 1561.990 1488.285
## 3 1 1532.564 1501.851
## 4 1 1535.937 1507.136
## 5 2 1567.567 1480.104
## 6 1 1455.770 1503.213
## 7 2 1517.926 1479.839
## 8 1 1453.367 1496.590
## 9 3 1504.287 1507.536
## 10 4 1533.837 1543.584
## game_quality_rating game_importance_rating game_overall_rating
## 1 95 35 65
## 2 72 37 54
## 3 63 67 65
## 4 68 80 74
## 5 70 30 50
## 6 16 51 33
## 7 38 70 54
## 8 13 50 31
## 9 48 74 61
## 10 86 55 70
summary(nhl_elo)
## season date playoff neutral
## Min. :2022 Length:1401 Min. :0.00000 Min. :0
## 1st Qu.:2022 Class :character 1st Qu.:0.00000 1st Qu.:0
## Median :2022 Mode :character Median :0.00000 Median :0
## Mean :2022 Mean :0.06353 Mean :0
## 3rd Qu.:2022 3rd Qu.:0.00000 3rd Qu.:0
## Max. :2022 Max. :1.00000 Max. :0
## status ot home_team away_team
## Length:1401 Length:1401 Length:1401 Length:1401
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## home_team_abbr away_team_abbr home_team_pregame_rating
## Length:1401 Length:1401 Min. :1399
## Class :character Class :character 1st Qu.:1461
## Mode :character Mode :character Median :1513
## Mean :1509
## 3rd Qu.:1554
## Max. :1632
## away_team_pregame_rating home_team_winprob away_team_winprob overtime_prob
## Min. :1397 Min. :0.2944 Min. :0.2017 Min. :0.2045
## 1st Qu.:1461 1st Qu.:0.4995 1st Qu.:0.3578 1st Qu.:0.2261
## Median :1514 Median :0.5725 Median :0.4275 Median :0.2332
## Mean :1509 Mean :0.5697 Mean :0.4303 Mean :0.2317
## 3rd Qu.:1554 3rd Qu.:0.6422 3rd Qu.:0.5005 3rd Qu.:0.2389
## Max. :1634 Max. :0.7983 Max. :0.7056 Max. :0.2441
## home_team_expected_points away_team_expected_points home_team_score
## Min. :0.7429 Min. :0.5666 Min. : 0.000
## 1st Qu.:1.1212 1st Qu.:0.8612 1st Qu.: 2.000
## Median :1.2456 Median :0.9896 Median : 3.000
## Mean :1.2397 Mean :0.9919 Mean : 3.288
## 3rd Qu.:1.3655 3rd Qu.:1.1229 3rd Qu.: 4.000
## Max. :1.6378 Max. :1.4754 Max. :11.000
## away_team_score home_team_postgame_rating away_team_postgame_rating
## Min. : 0.000 Min. :1397 Min. :1399
## 1st Qu.: 2.000 1st Qu.:1460 1st Qu.:1461
## Median : 3.000 Median :1514 Median :1514
## Mean : 3.004 Mean :1509 Mean :1509
## 3rd Qu.: 4.000 3rd Qu.:1554 3rd Qu.:1554
## Max. :10.000 Max. :1634 Max. :1632
## game_quality_rating game_importance_rating game_overall_rating
## Min. : 0.00 Min. : 0.00 Min. : 0.00
## 1st Qu.: 19.00 1st Qu.: 3.00 1st Qu.: 17.00
## Median : 47.00 Median : 14.00 Median : 37.00
## Mean : 49.88 Mean : 25.84 Mean : 37.63
## 3rd Qu.: 84.00 3rd Qu.: 39.00 3rd Qu.: 52.00
## Max. :100.00 Max. :100.00 Max. :100.00
# Creating and displaying a new data frame nhl_playoff_ot_elo"
nhl_playoff_ot_elo <- subset(nhl_elo,playoff==1 & ot== "OT")
#Display the first 10 rows of the subset
head(nhl_playoff_ot_elo,10)
## season date playoff neutral status ot home_team
## 1327 2022 2022-05-05 1 0 post OT Colorado Avalanche
## 1341 2022 2022-05-09 1 0 post OT Washington Capitals
## 1348 2022 2022-05-10 1 0 post OT Edmonton Oilers
## 1353 2022 2022-05-12 1 0 post OT Tampa Bay Lightning
## 1357 2022 2022-05-13 1 0 post OT Washington Capitals
## 1362 2022 2022-05-15 1 0 post OT New York Rangers
## 1363 2022 2022-05-15 1 0 post OT Calgary Flames
## 1365 2022 2022-05-17 1 0 post OT Colorado Avalanche
## 1366 2022 2022-05-18 1 0 post OT Carolina Hurricanes
## 1380 2022 2022-05-25 1 0 post OT Colorado Avalanche
## away_team home_team_abbr away_team_abbr home_team_pregame_rating
## 1327 Nashville Predators COL NSH 1603.995
## 1341 Florida Panthers WSH FLA 1542.482
## 1348 Los Angeles Kings EDM LAK 1554.174
## 1353 Toronto Maple Leafs TBL TOR 1577.777
## 1357 Florida Panthers WSH FLA 1537.607
## 1362 Pittsburgh Penguins NYR PIT 1561.524
## 1363 Dallas Stars CGY DAL 1562.128
## 1365 St. Louis Blues COL STL 1612.560
## 1366 New York Rangers CAR NYR 1587.353
## 1380 St. Louis Blues COL STL 1617.453
## away_team_pregame_rating home_team_winprob away_team_winprob overtime_prob
## 1327 1515.376 0.7305549 0.2694451 0.2148583
## 1341 1584.838 0.5137475 0.4862525 0.2423998
## 1348 1502.189 0.6756472 0.3243528 0.2223259
## 1353 1580.494 0.5842468 0.4157532 0.2338179
## 1357 1589.713 0.4962112 0.5037888 0.2436156
## 1362 1549.475 0.6098008 0.3901992 0.2306758
## 1363 1513.401 0.6704883 0.3295117 0.2229990
## 1365 1572.279 0.6569260 0.3430740 0.2247503
## 1366 1563.339 0.6300827 0.3699173 0.2281513
## 1380 1567.386 0.6726157 0.3273843 0.2227219
## home_team_expected_points away_team_expected_points home_team_score
## 1327 1.519002 0.6958560 2
## 1341 1.145362 1.0970373 2
## 1348 1.423406 0.7989194 4
## 1353 1.265704 0.9681137 4
## 1357 1.115153 1.1284624 3
## 1362 1.309611 0.9210646 4
## 1363 1.414457 0.8085416 3
## 1365 1.390958 0.8337923 3
## 1366 1.344563 0.8835888 2
## 1380 1.418147 0.8045749 4
## away_team_score home_team_postgame_rating away_team_postgame_rating
## 1327 1 1605.195 1514.177
## 1341 3 1539.989 1587.330
## 1348 5 1550.695 1505.668
## 1353 3 1579.729 1578.543
## 1357 4 1535.213 1592.106
## 1362 3 1563.339 1547.660
## 1363 2 1563.629 1511.901
## 1365 2 1614.130 1570.709
## 1366 1 1589.062 1561.630
## 1380 5 1613.994 1570.845
## game_quality_rating game_importance_rating game_overall_rating
## 1327 97 100 98
## 1341 98 100 99
## 1348 76 100 88
## 1353 100 100 100
## 1357 98 100 99
## 1362 96 100 98
## 1363 85 100 92
## 1365 100 100 100
## 1366 100 100 100
## 1380 100 100 100
# renaming the "status" column to "game_status"
colnames(nhl_playoff_ot_elo)[colnames(nhl_playoff_ot_elo)== "status"] <-"game_status"
# renaming the "ot" column to "overtime"
colnames(nhl_playoff_ot_elo)[colnames(nhl_playoff_ot_elo)== "ot"] <-"overtime"
#Display the first 10 rows of the subset
head(nhl_playoff_ot_elo,10)
## season date playoff neutral game_status overtime home_team
## 1327 2022 2022-05-05 1 0 post OT Colorado Avalanche
## 1341 2022 2022-05-09 1 0 post OT Washington Capitals
## 1348 2022 2022-05-10 1 0 post OT Edmonton Oilers
## 1353 2022 2022-05-12 1 0 post OT Tampa Bay Lightning
## 1357 2022 2022-05-13 1 0 post OT Washington Capitals
## 1362 2022 2022-05-15 1 0 post OT New York Rangers
## 1363 2022 2022-05-15 1 0 post OT Calgary Flames
## 1365 2022 2022-05-17 1 0 post OT Colorado Avalanche
## 1366 2022 2022-05-18 1 0 post OT Carolina Hurricanes
## 1380 2022 2022-05-25 1 0 post OT Colorado Avalanche
## away_team home_team_abbr away_team_abbr home_team_pregame_rating
## 1327 Nashville Predators COL NSH 1603.995
## 1341 Florida Panthers WSH FLA 1542.482
## 1348 Los Angeles Kings EDM LAK 1554.174
## 1353 Toronto Maple Leafs TBL TOR 1577.777
## 1357 Florida Panthers WSH FLA 1537.607
## 1362 Pittsburgh Penguins NYR PIT 1561.524
## 1363 Dallas Stars CGY DAL 1562.128
## 1365 St. Louis Blues COL STL 1612.560
## 1366 New York Rangers CAR NYR 1587.353
## 1380 St. Louis Blues COL STL 1617.453
## away_team_pregame_rating home_team_winprob away_team_winprob overtime_prob
## 1327 1515.376 0.7305549 0.2694451 0.2148583
## 1341 1584.838 0.5137475 0.4862525 0.2423998
## 1348 1502.189 0.6756472 0.3243528 0.2223259
## 1353 1580.494 0.5842468 0.4157532 0.2338179
## 1357 1589.713 0.4962112 0.5037888 0.2436156
## 1362 1549.475 0.6098008 0.3901992 0.2306758
## 1363 1513.401 0.6704883 0.3295117 0.2229990
## 1365 1572.279 0.6569260 0.3430740 0.2247503
## 1366 1563.339 0.6300827 0.3699173 0.2281513
## 1380 1567.386 0.6726157 0.3273843 0.2227219
## home_team_expected_points away_team_expected_points home_team_score
## 1327 1.519002 0.6958560 2
## 1341 1.145362 1.0970373 2
## 1348 1.423406 0.7989194 4
## 1353 1.265704 0.9681137 4
## 1357 1.115153 1.1284624 3
## 1362 1.309611 0.9210646 4
## 1363 1.414457 0.8085416 3
## 1365 1.390958 0.8337923 3
## 1366 1.344563 0.8835888 2
## 1380 1.418147 0.8045749 4
## away_team_score home_team_postgame_rating away_team_postgame_rating
## 1327 1 1605.195 1514.177
## 1341 3 1539.989 1587.330
## 1348 5 1550.695 1505.668
## 1353 3 1579.729 1578.543
## 1357 4 1535.213 1592.106
## 1362 3 1563.339 1547.660
## 1363 2 1563.629 1511.901
## 1365 2 1614.130 1570.709
## 1366 1 1589.062 1561.630
## 1380 5 1613.994 1570.845
## game_quality_rating game_importance_rating game_overall_rating
## 1327 97 100 98
## 1341 98 100 99
## 1348 76 100 88
## 1353 100 100 100
## 1357 98 100 99
## 1362 96 100 98
## 1363 85 100 92
## 1365 100 100 100
## 1366 100 100 100
## 1380 100 100 100
# removing the "season" column because there is only one season (2022)
nhl_playoff_ot_elo$season <- NULL
#Display the first 10 rows of the subset
head(nhl_playoff_ot_elo,10)
## date playoff neutral game_status overtime home_team
## 1327 2022-05-05 1 0 post OT Colorado Avalanche
## 1341 2022-05-09 1 0 post OT Washington Capitals
## 1348 2022-05-10 1 0 post OT Edmonton Oilers
## 1353 2022-05-12 1 0 post OT Tampa Bay Lightning
## 1357 2022-05-13 1 0 post OT Washington Capitals
## 1362 2022-05-15 1 0 post OT New York Rangers
## 1363 2022-05-15 1 0 post OT Calgary Flames
## 1365 2022-05-17 1 0 post OT Colorado Avalanche
## 1366 2022-05-18 1 0 post OT Carolina Hurricanes
## 1380 2022-05-25 1 0 post OT Colorado Avalanche
## away_team home_team_abbr away_team_abbr home_team_pregame_rating
## 1327 Nashville Predators COL NSH 1603.995
## 1341 Florida Panthers WSH FLA 1542.482
## 1348 Los Angeles Kings EDM LAK 1554.174
## 1353 Toronto Maple Leafs TBL TOR 1577.777
## 1357 Florida Panthers WSH FLA 1537.607
## 1362 Pittsburgh Penguins NYR PIT 1561.524
## 1363 Dallas Stars CGY DAL 1562.128
## 1365 St. Louis Blues COL STL 1612.560
## 1366 New York Rangers CAR NYR 1587.353
## 1380 St. Louis Blues COL STL 1617.453
## away_team_pregame_rating home_team_winprob away_team_winprob overtime_prob
## 1327 1515.376 0.7305549 0.2694451 0.2148583
## 1341 1584.838 0.5137475 0.4862525 0.2423998
## 1348 1502.189 0.6756472 0.3243528 0.2223259
## 1353 1580.494 0.5842468 0.4157532 0.2338179
## 1357 1589.713 0.4962112 0.5037888 0.2436156
## 1362 1549.475 0.6098008 0.3901992 0.2306758
## 1363 1513.401 0.6704883 0.3295117 0.2229990
## 1365 1572.279 0.6569260 0.3430740 0.2247503
## 1366 1563.339 0.6300827 0.3699173 0.2281513
## 1380 1567.386 0.6726157 0.3273843 0.2227219
## home_team_expected_points away_team_expected_points home_team_score
## 1327 1.519002 0.6958560 2
## 1341 1.145362 1.0970373 2
## 1348 1.423406 0.7989194 4
## 1353 1.265704 0.9681137 4
## 1357 1.115153 1.1284624 3
## 1362 1.309611 0.9210646 4
## 1363 1.414457 0.8085416 3
## 1365 1.390958 0.8337923 3
## 1366 1.344563 0.8835888 2
## 1380 1.418147 0.8045749 4
## away_team_score home_team_postgame_rating away_team_postgame_rating
## 1327 1 1605.195 1514.177
## 1341 3 1539.989 1587.330
## 1348 5 1550.695 1505.668
## 1353 3 1579.729 1578.543
## 1357 4 1535.213 1592.106
## 1362 3 1563.339 1547.660
## 1363 2 1563.629 1511.901
## 1365 2 1614.130 1570.709
## 1366 1 1589.062 1561.630
## 1380 5 1613.994 1570.845
## game_quality_rating game_importance_rating game_overall_rating
## 1327 97 100 98
## 1341 98 100 99
## 1348 76 100 88
## 1353 100 100 100
## 1357 98 100 99
## 1362 96 100 98
## 1363 85 100 92
## 1365 100 100 100
## 1366 100 100 100
## 1380 100 100 100
# Transforming the values of the "overtime" column
nhl_playoff_ot_elo$overtime[nhl_playoff_ot_elo$overtime == "OT"] <- "OverTime"
nhl_playoff_ot_elo$overtime[nhl_playoff_ot_elo$overtime == "3OT"] <- "Third OverTime"
nhl_playoff_ot_elo$overtime[nhl_playoff_ot_elo$overtime == "SO"] <- "Shootout"
#Display the first 10 rows of the subset
head(nhl_playoff_ot_elo,10)
## date playoff neutral game_status overtime home_team
## 1327 2022-05-05 1 0 post OverTime Colorado Avalanche
## 1341 2022-05-09 1 0 post OverTime Washington Capitals
## 1348 2022-05-10 1 0 post OverTime Edmonton Oilers
## 1353 2022-05-12 1 0 post OverTime Tampa Bay Lightning
## 1357 2022-05-13 1 0 post OverTime Washington Capitals
## 1362 2022-05-15 1 0 post OverTime New York Rangers
## 1363 2022-05-15 1 0 post OverTime Calgary Flames
## 1365 2022-05-17 1 0 post OverTime Colorado Avalanche
## 1366 2022-05-18 1 0 post OverTime Carolina Hurricanes
## 1380 2022-05-25 1 0 post OverTime Colorado Avalanche
## away_team home_team_abbr away_team_abbr home_team_pregame_rating
## 1327 Nashville Predators COL NSH 1603.995
## 1341 Florida Panthers WSH FLA 1542.482
## 1348 Los Angeles Kings EDM LAK 1554.174
## 1353 Toronto Maple Leafs TBL TOR 1577.777
## 1357 Florida Panthers WSH FLA 1537.607
## 1362 Pittsburgh Penguins NYR PIT 1561.524
## 1363 Dallas Stars CGY DAL 1562.128
## 1365 St. Louis Blues COL STL 1612.560
## 1366 New York Rangers CAR NYR 1587.353
## 1380 St. Louis Blues COL STL 1617.453
## away_team_pregame_rating home_team_winprob away_team_winprob overtime_prob
## 1327 1515.376 0.7305549 0.2694451 0.2148583
## 1341 1584.838 0.5137475 0.4862525 0.2423998
## 1348 1502.189 0.6756472 0.3243528 0.2223259
## 1353 1580.494 0.5842468 0.4157532 0.2338179
## 1357 1589.713 0.4962112 0.5037888 0.2436156
## 1362 1549.475 0.6098008 0.3901992 0.2306758
## 1363 1513.401 0.6704883 0.3295117 0.2229990
## 1365 1572.279 0.6569260 0.3430740 0.2247503
## 1366 1563.339 0.6300827 0.3699173 0.2281513
## 1380 1567.386 0.6726157 0.3273843 0.2227219
## home_team_expected_points away_team_expected_points home_team_score
## 1327 1.519002 0.6958560 2
## 1341 1.145362 1.0970373 2
## 1348 1.423406 0.7989194 4
## 1353 1.265704 0.9681137 4
## 1357 1.115153 1.1284624 3
## 1362 1.309611 0.9210646 4
## 1363 1.414457 0.8085416 3
## 1365 1.390958 0.8337923 3
## 1366 1.344563 0.8835888 2
## 1380 1.418147 0.8045749 4
## away_team_score home_team_postgame_rating away_team_postgame_rating
## 1327 1 1605.195 1514.177
## 1341 3 1539.989 1587.330
## 1348 5 1550.695 1505.668
## 1353 3 1579.729 1578.543
## 1357 4 1535.213 1592.106
## 1362 3 1563.339 1547.660
## 1363 2 1563.629 1511.901
## 1365 2 1614.130 1570.709
## 1366 1 1589.062 1561.630
## 1380 5 1613.994 1570.845
## game_quality_rating game_importance_rating game_overall_rating
## 1327 97 100 98
## 1341 98 100 99
## 1348 76 100 88
## 1353 100 100 100
## 1357 98 100 99
## 1362 96 100 98
## 1363 85 100 92
## 1365 100 100 100
## 1366 100 100 100
## 1380 100 100 100
library("ggplot2")
se <- subset(nhl_elo,select=c(ot))
barplot(table(se),
main="Number of times each Overtime type (NONE,OT,3OT,SO) occured",
xlab="OverTime",
ylab="Count",
border="red",
col="blue",
density=10
)
I believe that the article should go in more detail on how they give teams with a lower Elo score in the regular season a better chance to win in the playoffs. I think that this model gives teams which performed well in regular season a higher chance to win than the teams (underdogs) who barely made it in. As a hockey fan, I have seen many instances of wild card teams beat the first place teams and in some instances even win the Stanley Cup. I want to see the model work with the relationship of a team in the regular season and how it translates over into the playoffs. Otherwise, I think the Elo system does a pretty good job in the arena of hockey analytics.