library(tidyverse)
## ── Attaching packages ───────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.1 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
data <- read_csv('McCormack.csv')
## Parsed with column specification:
## cols(
## Name = col_character(),
## Height = col_double(),
## Weight = col_double(),
## FS_velo = col_double(),
## FS_rpm = col_double(),
## FS_rel_h = col_double(),
## FS_rel_v = col_double(),
## SL_velo = col_double(),
## SL_rpm = col_double(),
## SL_rel_h = col_double(),
## SL_rel_v = col_double(),
## FB_HB = col_double(),
## FB_VB = col_double(),
## SL_HB = col_double(),
## SL_VB = col_double(),
## Round = col_double(),
## Bonus = col_double(),
## Career_Earnings = col_double()
## )
train <- data[1:19,]
test <- data[20,]
train
## # A tibble: 19 x 18
## Name Height Weight FS_velo FS_rpm FS_rel_h FS_rel_v SL_velo SL_rpm SL_rel_h
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Drew… 74 225 97.6 2454 -2.15 6.11 86.8 2725 -2.48
## 2 Seth… 75 240 93.3 2318 -3.27 5.69 83.2 2457 -3.27
## 3 Corb… 75 205 96.1 2669 -0.79 6.01 86.7 2909 -0.9
## 4 Aaro… 74 215 91.3 2343 -0.72 6.07 82.2 2709 -0.81
## 5 Jimm… 74 190 92.7 2181 -0.93 6.26 86.8 2442 -1.08
## 6 Brya… 74 203 94.6 2172 -2.8 5.56 87.3 2439 -2.87
## 7 Broo… 75 190 94.8 2405 -0.92 5.76 83.1 2603 -0.75
## 8 Ian … 75 250 95.2 2053 -0.6 6.13 86.8 2272 -0.62
## 9 Jimm… 75 170 93.5 2345 -2.16 5.43 83 2610 -2.38
## 10 Tren… 72 195 92.1 2380 -0.89 5.52 80.3 3057 -0.97
## 11 Drew… 74 190 95.1 2469 -2.11 5.85 79.4 2793 -2.07
## 12 John… 77 220 94 2309 -2.46 6.38 85.2 2568 -2.7
## 13 Jame… 74 215 97.7 2364 -2.21 5.89 83.2 1910 -2.22
## 14 Robe… 74 180 92.1 2321 -2.32 5.07 81.7 2443 -2.33
## 15 Burc… 76 225 94.4 2444 -2.31 5.62 83 2421 -2.65
## 16 Jake… 75 205 90.7 2189 -2.72 5.75 84.6 2183 -2.8
## 17 Kyle… 75 190 87.4 1972 -2.01 6.07 72.1 2810 -1.92
## 18 Tyle… 73 199 90 2249 -0.04 6.12 82.8 2497 -0.35
## 19 Cart… 77 230 97.3 2313 -3.35 5.09 85.3 2230 -3.55
## # … with 8 more variables: SL_rel_v <dbl>, FB_HB <dbl>, FB_VB <dbl>,
## # SL_HB <dbl>, SL_VB <dbl>, Round <dbl>, Bonus <dbl>, Career_Earnings <dbl>
test
## # A tibble: 1 x 18
## Name Height Weight FS_velo FS_rpm FS_rel_h FS_rel_v SL_velo SL_rpm SL_rel_h
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Eli … 75 180 93 2571 -0.8 6.6 77.7 2332 -1
## # … with 8 more variables: SL_rel_v <dbl>, FB_HB <dbl>, FB_VB <dbl>,
## # SL_HB <dbl>, SL_VB <dbl>, Round <dbl>, Bonus <dbl>, Career_Earnings <dbl>
McCormack_round_model <- lm(formula = Round ~ FS_velo + Height + FS_rpm + FB_HB + FB_VB + SL_velo + FS_rel_v + SL_rpm, data = train)
summary(McCormack_round_model)
##
## Call:
## lm(formula = Round ~ FS_velo + Height + FS_rpm + FB_HB + FB_VB +
## SL_velo + FS_rel_v + SL_rpm, data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.7160 -1.6675 -0.8464 0.7754 7.1155
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.548e+01 1.203e+02 0.627 0.545
## FS_velo -6.511e-01 9.937e-01 -0.655 0.527
## Height 3.043e-01 9.611e-01 0.317 0.758
## FS_rpm 1.339e-04 9.995e-03 0.013 0.990
## FB_HB 4.572e-01 4.958e-01 0.922 0.378
## FB_VB -1.469e-01 1.012e+00 -0.145 0.887
## SL_velo 1.520e-01 4.337e-01 0.351 0.733
## FS_rel_v -4.438e+00 3.846e+00 -1.154 0.275
## SL_rpm -6.579e-03 5.415e-03 -1.215 0.252
##
## Residual standard error: 4.434 on 10 degrees of freedom
## Multiple R-squared: 0.3232, Adjusted R-squared: -0.2183
## F-statistic: 0.5969 on 8 and 10 DF, p-value: 0.7618
round_pred <- predict(McCormack_round_model, test)
round_pred
## 1
## 5.534312
Predicted draft round between 5 and 6.
McCormack_bonus_model <- lm(Bonus ~ FS_velo + Height + FS_rpm + FB_HB + FB_VB + SL_velo + FS_rel_v + SL_rpm, data = train)
summary(McCormack_bonus_model)
##
## Call:
## lm(formula = Bonus ~ FS_velo + Height + FS_rpm + FB_HB + FB_VB +
## SL_velo + FS_rel_v + SL_rpm, data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -243442 -72700 -21792 75183 311681
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -914556.7 5307229.9 -0.172 0.867
## FS_velo -18587.4 43828.5 -0.424 0.680
## Height 24843.6 42390.2 0.586 0.571
## FS_rpm 428.3 440.8 0.972 0.354
## FB_HB -6269.8 21869.9 -0.287 0.780
## FB_VB 18446.3 44616.3 0.413 0.688
## SL_velo 1696.9 19127.1 0.089 0.931
## FS_rel_v -30251.9 169621.9 -0.178 0.862
## SL_rpm 152.0 238.8 0.636 0.539
##
## Residual standard error: 195600 on 10 degrees of freedom
## Multiple R-squared: 0.2623, Adjusted R-squared: -0.3279
## F-statistic: 0.4444 on 8 and 10 DF, p-value: 0.8685
bonus_pred <- predict(McCormack_bonus_model, test)
bonus_pred
## 1
## 366220.8
Predicted bonus of $366,220.
McCormack_earnings_model <- lm(Career_Earnings ~ FS_velo + Height + FS_rpm + FB_HB + FB_VB + SL_velo + FS_rel_v + SL_rpm, data = train)
summary(McCormack_earnings_model)
##
## Call:
## lm(formula = Career_Earnings ~ FS_velo + Height + FS_rpm + FB_HB +
## FB_VB + SL_velo + FS_rel_v + SL_rpm, data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9978292 -5053213 -331634 3325679 13226289
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -115059759 237184086 -0.485 0.63805
## FS_velo 1828042 1958728 0.933 0.37266
## Height 2856173 1894449 1.508 0.16257
## FS_rpm -47894 19701 -2.431 0.03539 *
## FB_HB 263413 977381 0.270 0.79302
## FB_VB -1058005 1993937 -0.531 0.60727
## SL_velo -2991474 854804 -3.500 0.00573 **
## FS_rel_v 7631658 7580529 1.007 0.33780
## SL_rpm 13949 10674 1.307 0.22052
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8741000 on 10 degrees of freedom
## Multiple R-squared: 0.818, Adjusted R-squared: 0.6725
## F-statistic: 5.62 on 8 and 10 DF, p-value: 0.00684
earnings_pred <- predict(McCormack_earnings_model, test)
earnings_pred
## 1
## 10747054
Predicted career earnings of $10,747,054.