R Environment Preparation

Read in .csv and bring in necessary libraries (CBB team data 2002-18)

setwd("~/Documents/Spring 2019/Data Mining/R Files")
load("CBBstats.RData")

library(forecast)
library(gains)
library(caret)
library(e1071)

Dataset: Must have been tournament eligible

Delete non-numeric columns

seasonstats <- seasonstats[,c(4:42)]
summary(seasonstats)
##    IsPowerSix          TSp              eFGp             ORBp       
##  Min.   :0.0000   Min.   :0.4560   Min.   :0.4130   Min.   :0.1650  
##  1st Qu.:0.0000   1st Qu.:0.5420   1st Qu.:0.5020   1st Qu.:0.3010  
##  Median :1.0000   Median :0.5590   Median :0.5200   Median :0.3320  
##  Mean   :0.5367   Mean   :0.5597   Mean   :0.5204   Mean   :0.3303  
##  3rd Qu.:1.0000   3rd Qu.:0.5750   3rd Qu.:0.5370   3rd Qu.:0.3620  
##  Max.   :1.0000   Max.   :0.8040   Max.   :0.6210   Max.   :0.4950  
##       DRBp             ASTp             TOVp             STLp       
##  Min.   :0.5640   Min.   :0.3790   Min.   :0.1040   Min.   :0.0550  
##  1st Qu.:0.6870   1st Qu.:0.5210   1st Qu.:0.1470   1st Qu.:0.0880  
##  Median :0.7070   Median :0.5550   Median :0.1600   Median :0.1000  
##  Mean   :0.7077   Mean   :0.5575   Mean   :0.1605   Mean   :0.1015  
##  3rd Qu.:0.7280   3rd Qu.:0.5910   3rd Qu.:0.1720   3rd Qu.:0.1130  
##  Max.   :0.7940   Max.   :0.8440   Max.   :0.2360   Max.   :0.1920  
##       BLKp              PPS          FICFourty          ORtg      
##  Min.   :0.02200   Min.   :1.100   Min.   :0.935   Min.   :0.912  
##  1st Qu.:0.08475   1st Qu.:1.300   1st Qu.:1.282   1st Qu.:1.051  
##  Median :0.10200   Median :1.300   Median :1.390   Median :1.080  
##  Mean   :0.10586   Mean   :1.309   Mean   :1.393   Mean   :1.084  
##  3rd Qu.:0.12500   3rd Qu.:1.300   3rd Qu.:1.491   3rd Qu.:1.113  
##  Max.   :0.30000   Max.   :2.100   Max.   :1.968   Max.   :1.526  
##       DRtg            eDiff          PossperMin         Pace       
##  Min.   :0.8120   Min.   :-0.029   Min.   :1.151   Min.   :0.4600  
##  1st Qu.:0.9280   1st Qu.: 0.079   1st Qu.:1.639   1st Qu.:0.6558  
##  Median :0.9580   Median : 0.122   Median :1.694   Median :0.6780  
##  Mean   :0.9607   Mean   : 0.123   Mean   :1.692   Mean   :0.6766  
##  3rd Qu.:0.9880   3rd Qu.: 0.160   3rd Qu.:1.757   3rd Qu.:0.7030  
##  Max.   :1.3810   Max.   : 0.316   Max.   :1.950   Max.   :0.7800  
##       FGM              FGA             FGp            ThreePM      
##  Min.   :0.4000   Min.   :0.800   Min.   :0.4000   Min.   :0.1000  
##  1st Qu.:0.6000   1st Qu.:1.300   1st Qu.:0.4000   1st Qu.:0.1000  
##  Median :0.6000   Median :1.400   Median :0.5000   Median :0.2000  
##  Mean   :0.6429   Mean   :1.399   Mean   :0.4677   Mean   :0.1732  
##  3rd Qu.:0.7000   3rd Qu.:1.500   3rd Qu.:0.5000   3rd Qu.:0.2000  
##  Max.   :0.8000   Max.   :1.700   Max.   :0.5000   Max.   :0.3000  
##     ThreePA          ThreePp            FTM              FTA        
##  Min.   :0.3000   Min.   :0.2000   Min.   :0.2000   Min.   :0.3000  
##  1st Qu.:0.4000   1st Qu.:0.3000   1st Qu.:0.3000   1st Qu.:0.5000  
##  Median :0.5000   Median :0.4000   Median :0.4000   Median :0.5000  
##  Mean   :0.4747   Mean   :0.3652   Mean   :0.3741   Mean   :0.5282  
##  3rd Qu.:0.5000   3rd Qu.:0.4000   3rd Qu.:0.4000   3rd Qu.:0.6000  
##  Max.   :0.7000   Max.   :0.4000   Max.   :0.5000   Max.   :0.8000  
##       FTp              TOV               PF              ORB        
##  Min.   :0.6000   Min.   :0.2000   Min.   :0.3000   Min.   :0.1000  
##  1st Qu.:0.7000   1st Qu.:0.3000   1st Qu.:0.4000   1st Qu.:0.2000  
##  Median :0.7000   Median :0.3000   Median :0.4000   Median :0.3000  
##  Mean   :0.7067   Mean   :0.3112   Mean   :0.4382   Mean   :0.2668  
##  3rd Qu.:0.7000   3rd Qu.:0.3000   3rd Qu.:0.5000   3rd Qu.:0.3000  
##  Max.   :0.8000   Max.   :0.5000   Max.   :0.6000   Max.   :0.6000  
##       DRB              AST              STL              BLK        
##  Min.   :0.4000   Min.   :0.2000   Min.   :0.1000   Min.   :0.0000  
##  1st Qu.:0.6000   1st Qu.:0.3000   1st Qu.:0.1000   1st Qu.:0.1000  
##  Median :0.6000   Median :0.4000   Median :0.2000   Median :0.1000  
##  Mean   :0.6001   Mean   :0.3586   Mean   :0.1738   Mean   :0.1014  
##  3rd Qu.:0.6000   3rd Qu.:0.4000   3rd Qu.:0.2000   3rd Qu.:0.1000  
##  Max.   :0.9000   Max.   :0.5000   Max.   :0.3000   Max.   :0.2000  
##       PTS             Winp             MOV              SOS          
##  Min.   :1.500   Min.   :0.5000   Min.   :-4.180   Min.   :-12.8600  
##  1st Qu.:1.700   1st Qu.:0.6562   1st Qu.: 5.117   1st Qu.: -0.1475  
##  Median :1.800   Median :0.7246   Median : 7.840   Median :  6.0850  
##  Mean   :1.832   Mean   :0.7215   Mean   : 7.933   Mean   :  4.1507  
##  3rd Qu.:1.900   3rd Qu.:0.7838   3rd Qu.:10.320   3rd Qu.:  8.3425  
##  Max.   :2.200   Max.   :0.9744   Max.   :22.780   Max.   : 12.7900  
##       OSRS              DSRS          IsEliteEight   
##  Min.   :-13.380   Min.   :-12.710   Min.   :0.0000  
##  1st Qu.:  2.545   1st Qu.:  2.047   1st Qu.:0.0000  
##  Median :  6.285   Median :  5.740   Median :0.0000  
##  Mean   :  6.149   Mean   :  5.393   Mean   :0.1219  
##  3rd Qu.: 10.232   3rd Qu.:  8.940   3rd Qu.:0.0000  
##  Max.   : 23.850   Max.   : 24.000   Max.   :1.0000
seasonstatsmodel <- seasonstats

standardize numerical predictors to 0-1 scale for both the new record and full dataset

cols <- c("IsPowerSix", "TSp",  "eFGp", "ORBp", "DRBp", "ASTp",
          "TOVp",   "STLp", "BLKp", "PPS",  "FICFourty",    "ORtg", "DRtg",
          "eDiff",  "PossperMin",   "Pace", "FGM",  "FGA",  "FGp",  "ThreePM",
          "ThreePA",    "ThreePp",  "FTM",  "FTA",  "FTp",  "TOV",  "PF",   "ORB",
          "DRB",    "AST",  "STL",  "BLK",  "PTS",  "Winp", "MOV", "SOS","OSRS","DSRS","IsEliteEight")
for (i in cols) {
  seasonstatsmodel[[i]] <- (seasonstatsmodel[[i]] - min(seasonstatsmodel[[i]])) / (max(seasonstatsmodel[[i]]) - min(seasonstatsmodel[[i]]))
}
summary(seasonstatsmodel)
##    IsPowerSix          TSp              eFGp             ORBp       
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.0000   1st Qu.:0.2471   1st Qu.:0.4279   1st Qu.:0.4121  
##  Median :1.0000   Median :0.2960   Median :0.5144   Median :0.5061  
##  Mean   :0.5367   Mean   :0.2981   Mean   :0.5164   Mean   :0.5009  
##  3rd Qu.:1.0000   3rd Qu.:0.3420   3rd Qu.:0.5962   3rd Qu.:0.5970  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       DRBp             ASTp             TOVp             STLp       
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.5348   1st Qu.:0.3054   1st Qu.:0.3258   1st Qu.:0.2409  
##  Median :0.6217   Median :0.3785   Median :0.4242   Median :0.3285  
##  Mean   :0.6248   Mean   :0.3839   Mean   :0.4284   Mean   :0.3398  
##  3rd Qu.:0.7130   3rd Qu.:0.4559   3rd Qu.:0.5152   3rd Qu.:0.4234  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       BLKp             PPS           FICFourty           ORtg       
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.2257   1st Qu.:0.2000   1st Qu.:0.3366   1st Qu.:0.2264  
##  Median :0.2878   Median :0.2000   Median :0.4407   Median :0.2736  
##  Mean   :0.3017   Mean   :0.2094   Mean   :0.4433   Mean   :0.2797  
##  3rd Qu.:0.3705   3rd Qu.:0.2000   3rd Qu.:0.5381   3rd Qu.:0.3274  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       DRtg            eDiff          PossperMin          Pace       
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.2039   1st Qu.:0.3130   1st Qu.:0.6108   1st Qu.:0.6117  
##  Median :0.2566   Median :0.4377   Median :0.6799   Median :0.6813  
##  Mean   :0.2614   Mean   :0.4406   Mean   :0.6769   Mean   :0.6768  
##  3rd Qu.:0.3093   3rd Qu.:0.5478   3rd Qu.:0.7584   3rd Qu.:0.7594  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       FGM              FGA              FGp            ThreePM     
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.000  
##  1st Qu.:0.5000   1st Qu.:0.5556   1st Qu.:0.0000   1st Qu.:0.000  
##  Median :0.5000   Median :0.6667   Median :1.0000   Median :0.500  
##  Mean   :0.6073   Mean   :0.6652   Mean   :0.6774   Mean   :0.366  
##  3rd Qu.:0.7500   3rd Qu.:0.7778   3rd Qu.:1.0000   3rd Qu.:0.500  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.000  
##     ThreePA          ThreePp            FTM              FTA        
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.2500   1st Qu.:0.5000   1st Qu.:0.3333   1st Qu.:0.4000  
##  Median :0.5000   Median :1.0000   Median :0.6667   Median :0.4000  
##  Mean   :0.4368   Mean   :0.8262   Mean   :0.5803   Mean   :0.4565  
##  3rd Qu.:0.5000   3rd Qu.:1.0000   3rd Qu.:0.6667   3rd Qu.:0.6000  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       FTp              TOV               PF              ORB        
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.5000   1st Qu.:0.3333   1st Qu.:0.3333   1st Qu.:0.2000  
##  Median :0.5000   Median :0.3333   Median :0.3333   Median :0.4000  
##  Mean   :0.5336   Mean   :0.3707   Mean   :0.4606   Mean   :0.3337  
##  3rd Qu.:0.5000   3rd Qu.:0.3333   3rd Qu.:0.6667   3rd Qu.:0.4000  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       DRB              AST              STL              BLK        
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.4000   1st Qu.:0.3333   1st Qu.:0.0000   1st Qu.:0.5000  
##  Median :0.4000   Median :0.6667   Median :0.5000   Median :0.5000  
##  Mean   :0.4002   Mean   :0.5287   Mean   :0.3692   Mean   :0.5072  
##  3rd Qu.:0.4000   3rd Qu.:0.6667   3rd Qu.:0.5000   3rd Qu.:0.5000  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       PTS              Winp             MOV              SOS        
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.2857   1st Qu.:0.3294   1st Qu.:0.3449   1st Qu.:0.4956  
##  Median :0.4286   Median :0.4734   Median :0.4458   Median :0.7386  
##  Mean   :0.4738   Mean   :0.4670   Mean   :0.4493   Mean   :0.6632  
##  3rd Qu.:0.5714   3rd Qu.:0.5982   3rd Qu.:0.5378   3rd Qu.:0.8266  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##       OSRS             DSRS         IsEliteEight   
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.4277   1st Qu.:0.4020   1st Qu.:0.0000  
##  Median :0.5282   Median :0.5026   Median :0.0000  
##  Mean   :0.5245   Mean   :0.4931   Mean   :0.1219  
##  3rd Qu.:0.6342   3rd Qu.:0.5898   3rd Qu.:0.0000  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000

```

Logistic Model - focus on high sensitivity (positivity accuracy) vs high specificity

set.seed(rnorm(1))
train.rows <- sample(nrow(seasonstatsmodel), nrow(seasonstatsmodel) * 0.6)
seasonstatsmodel.train <- seasonstatsmodel[train.rows, ]
seasonstatsmodel.valid <- seasonstatsmodel[-train.rows, ]
seasonstatsmodel.glm <- glm(IsEliteEight ~ ., family = "binomial", data = seasonstatsmodel.train)
summary(seasonstatsmodel.glm)
## 
## Call:
## glm(formula = IsEliteEight ~ ., family = "binomial", data = seasonstatsmodel.train)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -1.80870  -0.29385  -0.12230  -0.01468   3.15334  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  15.02879   43.91691   0.342   0.7322    
## IsPowerSix    0.17019    0.72416   0.235   0.8142    
## TSp           5.75703   20.23418   0.285   0.7760    
## eFGp          2.75791    8.67608   0.318   0.7506    
## ORBp          3.59918    4.11099   0.876   0.3813    
## DRBp         -0.78913    1.82528  -0.432   0.6655    
## ASTp         -4.11813    3.11344  -1.323   0.1859    
## TOVp         -0.18623    5.41612  -0.034   0.9726    
## STLp         -0.23884    2.69505  -0.089   0.9294    
## BLKp         -2.72197    3.08408  -0.883   0.3775    
## PPS           1.21058    5.77532   0.210   0.8340    
## FICFourty     5.43463    7.15904   0.759   0.4478    
## ORtg         61.29412  208.22266   0.294   0.7685    
## DRtg        -97.11651  192.92663  -0.503   0.6147    
## eDiff       -56.36802  116.64461  -0.483   0.6289    
## PossperMin  -30.14783   80.34693  -0.375   0.7075    
## Pace          6.42223   81.03950   0.079   0.9368    
## FGM           2.58022    2.21417   1.165   0.2439    
## FGA           1.54042    5.00435   0.308   0.7582    
## FGp           0.42026    0.54636   0.769   0.4418    
## ThreePM      -0.06769    1.11954  -0.060   0.9518    
## ThreePA       2.22392    1.42305   1.563   0.1181    
## ThreePp       0.52344    0.99569   0.526   0.5991    
## FTM           0.21179    1.67954   0.126   0.8997    
## FTA           0.03107    2.23953   0.014   0.9889    
## FTp          -0.44569    1.11109  -0.401   0.6883    
## TOV          -0.52650    1.90060  -0.277   0.7818    
## PF            0.65872    1.29338   0.509   0.6105    
## ORB           3.60287    2.85135   1.264   0.2064    
## DRB          -1.82647    2.77412  -0.658   0.5103    
## AST           0.36288    1.68996   0.215   0.8300    
## STL          -0.41853    1.14258  -0.366   0.7141    
## BLK          -0.19150    1.36230  -0.141   0.8882    
## PTS          10.70134    4.25449   2.515   0.0119 *  
## Winp          8.78273    1.78369   4.924 8.48e-07 ***
## MOV         -10.74449   15.16861  -0.708   0.4787    
## SOS           1.83820   11.12307   0.165   0.8687    
## OSRS         16.34379   16.01635   1.020   0.3075    
## DSRS         12.59463   15.28674   0.824   0.4100    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 509.44  on 668  degrees of freedom
## Residual deviance: 264.61  on 630  degrees of freedom
## AIC: 342.61
## 
## Number of Fisher Scoring iterations: 8
pred.glm.train <- predict(seasonstatsmodel.glm, type = "response")
pred.glm.valid <- predict(seasonstatsmodel.glm, newdata = seasonstatsmodel.valid, type = "response")
confusionMatrix(as.factor(ifelse(pred.glm.train >= 0.5, "1", "0")), as.factor(seasonstatsmodel.train$IsEliteEight), 
                positive = "1")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   0   1
##          0 565  36
##          1  19  49
##                                           
##                Accuracy : 0.9178          
##                  95% CI : (0.8943, 0.9375)
##     No Information Rate : 0.8729          
##     P-Value [Acc > NIR] : 0.0001528       
##                                           
##                   Kappa : 0.5948          
##                                           
##  Mcnemar's Test P-Value : 0.0309714       
##                                           
##             Sensitivity : 0.57647         
##             Specificity : 0.96747         
##          Pos Pred Value : 0.72059         
##          Neg Pred Value : 0.94010         
##              Prevalence : 0.12706         
##          Detection Rate : 0.07324         
##    Detection Prevalence : 0.10164         
##       Balanced Accuracy : 0.77197         
##                                           
##        'Positive' Class : 1               
## 

Initial model has low sensitivity so need to change that:

Define a cost function with input “obs” being the observed response,

“pred.p” being predicted probability, and “pcut” being the threshold

Allows us to weight getting high sensitivity vs high specficity

costfunc <- function(obs, pred.p, pcut){
  weight1 <- 50 # define the weight for "true=1 but pred=0" (false negative)
  weight0 <- 1 # define the weight for "true=0 but pred=1" (false positive)
  c1 <- (obs == 1) & (pred.p < pcut) # count for "true=1 but pred=0" (false negative)
  c0 <- (obs == 0) & (pred.p >= pcut) # count for "true=0 but pred=1" (false positive)
  cost <- mean(weight1 * c1 + weight0 * c0) # misclassification with weight
  return(cost)
} 
#Define a sequence from 0.01 to 1 by 0.01
p.seq <- seq(from = 0.01, to = 1, by = 0.01)
# Loop for all potential cutoff values to see which provides the smallest cost
# Define a 0 vector first to save the values of cost from all cutoffs
cost <- rep(0, length(p.seq))
for (i in 1:length(p.seq)) {cost[i] <- costfunc(obs = seasonstatsmodel$IsEliteEight, pred.p = pred.glm.train, pcut = p.seq[i])
}
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 1) & (pred.p < pcut): longer object length is not a multiple
## of shorter object length
## Warning in (obs == 0) & (pred.p >= pcut): longer object length is not a multiple
## of shorter object length
#Find optimal pcut
optimal.pcut.glm <- p.seq[which(cost == min(cost))]
#Higher sensitivity seen - will try this cutoff with logistic model(s)
confusionMatrix(as.factor(ifelse(pred.glm.train >= optimal.pcut.glm, "1", "0")), as.factor(seasonstatsmodel.train$IsEliteEight), 
                positive = "1")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   0   1
##          0 282   1
##          1 302  84
##                                           
##                Accuracy : 0.5471          
##                  95% CI : (0.5085, 0.5853)
##     No Information Rate : 0.8729          
##     P-Value [Acc > NIR] : 1               
##                                           
##                   Kappa : 0.1875          
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.9882          
##             Specificity : 0.4829          
##          Pos Pred Value : 0.2176          
##          Neg Pred Value : 0.9965          
##              Prevalence : 0.1271          
##          Detection Rate : 0.1256          
##    Detection Prevalence : 0.5770          
##       Balanced Accuracy : 0.7356          
##                                           
##        'Positive' Class : 1               
## 
cost <- costfunc(obs = seasonstatsmodel.train$IsEliteEight, pred.p = pred.glm.train, pcut = optimal.pcut.glm)

Perform forward selection,backward selection, and stepwise selection

#Perform forward selection,backward selection, and stepwise selection
#Forward - best model (same as stepwise)
seasonstatsmodel.glm.null <- glm(IsEliteEight ~ 1, data = seasonstatsmodel.train, family = "binomial")
seasonstatsmodel.glm.full <- glm(IsEliteEight ~ ., data = seasonstatsmodel.train, family = "binomial")
seasonstatsmodel.glm.fwd <- step(seasonstatsmodel.glm.null, scope = list(seasonstatsmodel.glm.null, upper = seasonstatsmodel.glm), direction = "forward")
## Start:  AIC=511.44
## IsEliteEight ~ 1
## 
##              Df Deviance    AIC
## + Winp        1   390.59 394.59
## + MOV         1   406.23 410.23
## + SOS         1   427.63 431.63
## + OSRS        1   435.25 439.25
## + eDiff       1   435.91 439.91
## + IsPowerSix  1   449.26 453.26
## + FICFourty   1   454.33 458.33
## + DSRS        1   457.69 461.69
## + DRtg        1   478.56 482.56
## + FGM         1   479.94 483.94
## + PTS         1   480.73 484.73
## + ORBp        1   490.51 494.51
## + ORtg        1   491.53 495.53
## + BLKp        1   491.57 495.57
## + BLK         1   492.17 496.17
## + FGA         1   494.01 498.01
## + FGp         1   494.57 498.57
## + eFGp        1   497.05 501.05
## + ORB         1   498.29 502.29
## + TOVp        1   498.93 502.93
## + AST         1   500.10 504.10
## + ThreePp     1   502.43 506.43
## + TSp         1   504.13 508.13
## + DRB         1   505.16 509.16
## + PF          1   505.32 509.32
## + Pace        1   506.18 510.18
## + PossperMin  1   506.28 510.28
## + PPS         1   506.62 510.62
## + STL         1   506.84 510.84
## + STLp        1   507.19 511.19
## <none>            509.44 511.44
## + TOV         1   508.00 512.00
## + ThreePM     1   508.42 512.42
## + DRBp        1   508.96 512.96
## + ThreePA     1   509.13 513.13
## + FTp         1   509.19 513.19
## + FTA         1   509.21 513.21
## + FTM         1   509.28 513.28
## + ASTp        1   509.41 513.41
## 
## Step:  AIC=394.59
## IsEliteEight ~ Winp
## 
##              Df Deviance    AIC
## + SOS         1   295.10 301.10
## + IsPowerSix  1   321.07 327.07
## + OSRS        1   357.10 363.10
## + DSRS        1   376.56 382.56
## + FGA         1   382.49 388.49
## + ORB         1   383.35 389.35
## + FICFourty   1   384.91 390.91
## + FGM         1   384.93 390.93
## + BLK         1   385.79 391.79
## + MOV         1   385.80 391.80
## + ORBp        1   385.92 391.92
## + PTS         1   386.15 392.15
## + BLKp        1   386.68 392.68
## + Pace        1   386.79 392.79
## + PossperMin  1   386.82 392.82
## + DRBp        1   388.43 394.43
## <none>            390.59 394.59
## + ASTp        1   388.84 394.84
## + PPS         1   389.08 395.08
## + TSp         1   389.47 395.47
## + DRB         1   389.60 395.60
## + TOVp        1   389.74 395.74
## + FGp         1   390.09 396.09
## + FTp         1   390.25 396.25
## + eFGp        1   390.37 396.37
## + STL         1   390.38 396.38
## + AST         1   390.40 396.40
## + ThreePp     1   390.47 396.47
## + DRtg        1   390.49 396.49
## + TOV         1   390.53 396.53
## + FTA         1   390.53 396.53
## + eDiff       1   390.56 396.56
## + FTM         1   390.57 396.57
## + ORtg        1   390.58 396.58
## + STLp        1   390.58 396.58
## + ThreePA     1   390.58 396.58
## + ThreePM     1   390.59 396.59
## + PF          1   390.59 396.59
## 
## Step:  AIC=301.1
## IsEliteEight ~ Winp + SOS
## 
##              Df Deviance    AIC
## + ORB         1   289.40 297.40
## + ORBp        1   291.21 299.21
## + FTp         1   292.78 300.78
## <none>            295.10 301.10
## + TOVp        1   293.35 301.35
## + DRtg        1   293.57 301.57
## + DRBp        1   293.90 301.90
## + MOV         1   294.19 302.19
## + TOV         1   294.24 302.24
## + STLp        1   294.26 302.26
## + IsPowerSix  1   294.29 302.29
## + FGM         1   294.29 302.29
## + FGp         1   294.32 302.32
## + PPS         1   294.44 302.44
## + OSRS        1   294.50 302.50
## + TSp         1   294.51 302.51
## + eDiff       1   294.60 302.60
## + ASTp        1   294.64 302.64
## + FTM         1   294.69 302.69
## + FGA         1   294.71 302.71
## + ORtg        1   294.79 302.79
## + PTS         1   294.79 302.79
## + BLK         1   294.80 302.80
## + STL         1   294.97 302.97
## + eFGp        1   294.97 302.97
## + ThreePp     1   294.98 302.98
## + DRB         1   294.99 302.99
## + Pace        1   294.99 302.99
## + PossperMin  1   295.00 303.00
## + PF          1   295.01 303.01
## + BLKp        1   295.04 303.04
## + DSRS        1   295.05 303.05
## + AST         1   295.05 303.05
## + FICFourty   1   295.08 303.08
## + ThreePA     1   295.09 303.09
## + ThreePM     1   295.10 303.10
## + FTA         1   295.10 303.10
## 
## Step:  AIC=297.4
## IsEliteEight ~ Winp + SOS + ORB
## 
##              Df Deviance    AIC
## <none>            289.40 297.40
## + DRtg        1   287.67 297.67
## + FTM         1   287.78 297.78
## + FTp         1   288.06 298.06
## + FGp         1   288.26 298.26
## + DRB         1   288.38 298.38
## + ORtg        1   288.40 298.40
## + FTA         1   288.74 298.74
## + ASTp        1   288.75 298.75
## + TOVp        1   288.84 298.84
## + IsPowerSix  1   288.90 298.90
## + MOV         1   288.91 298.91
## + ThreePM     1   288.94 298.94
## + ThreePp     1   288.94 298.94
## + FICFourty   1   288.96 298.96
## + DRBp        1   288.97 298.97
## + FGM         1   289.00 299.00
## + ThreePA     1   289.01 299.01
## + eFGp        1   289.23 299.23
## + PPS         1   289.23 299.23
## + STLp        1   289.24 299.24
## + PF          1   289.31 299.31
## + eDiff       1   289.33 299.33
## + ORBp        1   289.33 299.33
## + OSRS        1   289.34 299.34
## + DSRS        1   289.35 299.35
## + TOV         1   289.36 299.36
## + BLK         1   289.36 299.36
## + PTS         1   289.36 299.36
## + TSp         1   289.37 299.37
## + Pace        1   289.37 299.37
## + PossperMin  1   289.38 299.38
## + BLKp        1   289.38 299.38
## + AST         1   289.39 299.39
## + STL         1   289.39 299.39
## + FGA         1   289.40 299.40
summary(seasonstatsmodel.glm.fwd)
## 
## Call:
## glm(formula = IsEliteEight ~ Winp + SOS + ORB, family = "binomial", 
##     data = seasonstatsmodel.train)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9169  -0.3367  -0.1541  -0.0242   3.1765  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -16.8206     1.7991  -9.350  < 2e-16 ***
## Winp          8.7272     0.9705   8.993  < 2e-16 ***
## SOS          11.5636     1.7116   6.756 1.42e-11 ***
## ORB           3.0045     1.2632   2.379   0.0174 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 509.44  on 668  degrees of freedom
## Residual deviance: 289.40  on 665  degrees of freedom
## AIC: 297.4
## 
## Number of Fisher Scoring iterations: 7
sum.fwd <- summary(seasonstatsmodel.glm.fwd)
dim(sum.fwd$coefficients)
## [1] 4 4
AIC(seasonstatsmodel.glm.fwd)
## [1] 297.3989
pred.glm.train2 <- predict(seasonstatsmodel.glm.fwd, type = "response")
pred.glm.valid2 <- predict(seasonstatsmodel.glm.fwd, newdata = seasonstatsmodel.valid, type = "response")
confusionMatrix(as.factor(ifelse(pred.glm.train2 >= optimal.pcut.glm, "1", "0")), as.factor(seasonstatsmodel.train$IsEliteEight), 
                positive = "1")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   0   1
##          0 229   1
##          1 355  84
##                                           
##                Accuracy : 0.4679          
##                  95% CI : (0.4295, 0.5065)
##     No Information Rate : 0.8729          
##     P-Value [Acc > NIR] : 1               
##                                           
##                   Kappa : 0.1369          
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.9882          
##             Specificity : 0.3921          
##          Pos Pred Value : 0.1913          
##          Neg Pred Value : 0.9957          
##              Prevalence : 0.1271          
##          Detection Rate : 0.1256          
##    Detection Prevalence : 0.6562          
##       Balanced Accuracy : 0.6902          
##                                           
##        'Positive' Class : 1               
## 
#Perform backward elimination - 3rd best
seasonstatsmodel.glm.back <- step(seasonstatsmodel.glm.full, direction = "backward")
## Start:  AIC=342.61
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     TOVp + STLp + BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + 
##     PossperMin + Pace + FGM + FGA + FGp + ThreePM + ThreePA + 
##     ThreePp + FTM + FTA + FTp + TOV + PF + ORB + DRB + AST + 
##     STL + BLK + PTS + Winp + MOV + SOS + OSRS + DSRS
## 
##              Df Deviance    AIC
## - FTA         1   264.61 340.61
## - TOVp        1   264.61 340.61
## - ThreePM     1   264.62 340.62
## - Pace        1   264.62 340.62
## - STLp        1   264.62 340.62
## - FTM         1   264.63 340.63
## - BLK         1   264.63 340.63
## - SOS         1   264.64 340.64
## - PPS         1   264.66 340.66
## - AST         1   264.66 340.66
## - IsPowerSix  1   264.67 340.67
## - TOV         1   264.69 340.69
## - TSp         1   264.69 340.69
## - ORtg        1   264.70 340.70
## - FGA         1   264.71 340.71
## - eFGp        1   264.71 340.71
## - STL         1   264.75 340.75
## - FTp         1   264.77 340.77
## - PossperMin  1   264.80 340.80
## - DRBp        1   264.80 340.80
## - eDiff       1   264.85 340.85
## - DRtg        1   264.87 340.87
## - PF          1   264.87 340.87
## - ThreePp     1   264.89 340.89
## - DRB         1   265.05 341.05
## - MOV         1   265.13 341.13
## - FICFourty   1   265.19 341.19
## - FGp         1   265.21 341.21
## - DSRS        1   265.33 341.33
## - ORBp        1   265.38 341.38
## - BLKp        1   265.40 341.40
## - OSRS        1   265.74 341.74
## - FGM         1   265.98 341.98
## - ORB         1   266.22 342.22
## - ASTp        1   266.38 342.38
## <none>            264.61 342.61
## - ThreePA     1   267.10 343.09
## - PTS         1   271.27 347.27
## - Winp        1   293.09 369.09
## 
## Step:  AIC=340.61
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     TOVp + STLp + BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + 
##     PossperMin + Pace + FGM + FGA + FGp + ThreePM + ThreePA + 
##     ThreePp + FTM + FTp + TOV + PF + ORB + DRB + AST + STL + 
##     BLK + PTS + Winp + MOV + SOS + OSRS + DSRS
## 
##              Df Deviance    AIC
## - TOVp        1   264.61 338.61
## - ThreePM     1   264.62 338.62
## - Pace        1   264.62 338.62
## - STLp        1   264.62 338.62
## - FTM         1   264.63 338.63
## - BLK         1   264.63 338.63
## - SOS         1   264.64 338.64
## - AST         1   264.66 338.66
## - PPS         1   264.66 338.66
## - IsPowerSix  1   264.67 338.67
## - TOV         1   264.69 338.69
## - TSp         1   264.69 338.69
## - ORtg        1   264.70 338.70
## - FGA         1   264.71 338.71
## - eFGp        1   264.72 338.72
## - STL         1   264.75 338.75
## - FTp         1   264.79 338.79
## - PossperMin  1   264.80 338.80
## - DRBp        1   264.81 338.80
## - eDiff       1   264.85 338.85
## - DRtg        1   264.87 338.87
## - PF          1   264.87 338.87
## - ThreePp     1   264.89 338.89
## - DRB         1   265.05 339.05
## - MOV         1   265.13 339.13
## - FICFourty   1   265.20 339.20
## - FGp         1   265.21 339.21
## - DSRS        1   265.35 339.35
## - ORBp        1   265.39 339.39
## - BLKp        1   265.40 339.40
## - OSRS        1   265.75 339.75
## - FGM         1   265.99 339.99
## - ORB         1   266.23 340.23
## - ASTp        1   266.40 340.40
## <none>            264.61 340.61
## - ThreePA     1   267.11 341.11
## - PTS         1   271.30 345.30
## - Winp        1   293.10 367.10
## 
## Step:  AIC=338.61
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     STLp + BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     Pace + FGM + FGA + FGp + ThreePM + ThreePA + ThreePp + FTM + 
##     FTp + TOV + PF + ORB + DRB + AST + STL + BLK + PTS + Winp + 
##     MOV + SOS + OSRS + DSRS
## 
##              Df Deviance    AIC
## - ThreePM     1   264.62 336.62
## - Pace        1   264.62 336.62
## - STLp        1   264.62 336.62
## - FTM         1   264.63 336.63
## - BLK         1   264.63 336.63
## - SOS         1   264.64 336.64
## - AST         1   264.66 336.66
## - PPS         1   264.66 336.66
## - IsPowerSix  1   264.67 336.67
## - ORtg        1   264.70 336.70
## - FGA         1   264.71 336.71
## - TSp         1   264.72 336.72
## - eFGp        1   264.72 336.72
## - TOV         1   264.72 336.72
## - STL         1   264.75 336.75
## - FTp         1   264.79 336.79
## - PossperMin  1   264.80 336.80
## - DRBp        1   264.81 336.81
## - eDiff       1   264.85 336.85
## - DRtg        1   264.87 336.87
## - PF          1   264.87 336.87
## - ThreePp     1   264.89 336.89
## - DRB         1   265.12 337.12
## - MOV         1   265.15 337.15
## - FICFourty   1   265.20 337.20
## - FGp         1   265.22 337.22
## - DSRS        1   265.36 337.36
## - BLKp        1   265.40 337.40
## - OSRS        1   265.78 337.78
## - FGM         1   265.99 337.99
## - ORBp        1   266.38 338.38
## - ASTp        1   266.40 338.40
## - ORB         1   266.44 338.44
## <none>            264.61 338.61
## - ThreePA     1   267.11 339.11
## - PTS         1   271.31 343.31
## - Winp        1   293.23 365.23
## 
## Step:  AIC=336.62
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     STLp + BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     Pace + FGM + FGA + FGp + ThreePA + ThreePp + FTM + FTp + 
##     TOV + PF + ORB + DRB + AST + STL + BLK + PTS + Winp + MOV + 
##     SOS + OSRS + DSRS
## 
##              Df Deviance    AIC
## - Pace        1   264.62 334.62
## - STLp        1   264.63 334.63
## - FTM         1   264.64 334.64
## - BLK         1   264.64 334.64
## - SOS         1   264.64 334.64
## - PPS         1   264.67 334.67
## - AST         1   264.67 334.67
## - IsPowerSix  1   264.67 334.67
## - ORtg        1   264.70 334.70
## - FGA         1   264.71 334.71
## - eFGp        1   264.72 334.72
## - TSp         1   264.72 334.72
## - TOV         1   264.73 334.73
## - STL         1   264.75 334.75
## - FTp         1   264.80 334.80
## - PossperMin  1   264.80 334.80
## - DRBp        1   264.81 334.81
## - eDiff       1   264.85 334.85
## - DRtg        1   264.87 334.87
## - PF          1   264.88 334.88
## - ThreePp     1   264.89 334.90
## - DRB         1   265.14 335.14
## - MOV         1   265.17 335.17
## - FICFourty   1   265.22 335.22
## - FGp         1   265.24 335.24
## - DSRS        1   265.36 335.36
## - BLKp        1   265.41 335.41
## - OSRS        1   265.79 335.78
## - FGM         1   266.00 336.00
## - ORBp        1   266.39 336.39
## - ORB         1   266.44 336.44
## - ASTp        1   266.47 336.47
## <none>            264.62 336.62
## - ThreePA     1   267.82 337.82
## - PTS         1   271.31 341.32
## - Winp        1   293.23 363.23
## 
## Step:  AIC=334.62
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     STLp + BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     FGM + FGA + FGp + ThreePA + ThreePp + FTM + FTp + TOV + PF + 
##     ORB + DRB + AST + STL + BLK + PTS + Winp + MOV + SOS + OSRS + 
##     DSRS
## 
##              Df Deviance    AIC
## - STLp        1   264.64 332.64
## - FTM         1   264.64 332.64
## - BLK         1   264.65 332.65
## - SOS         1   264.65 332.65
## - PPS         1   264.67 332.67
## - AST         1   264.67 332.67
## - IsPowerSix  1   264.68 332.68
## - ORtg        1   264.72 332.72
## - FGA         1   264.72 332.72
## - eFGp        1   264.73 332.72
## - TSp         1   264.73 332.73
## - TOV         1   264.74 332.74
## - STL         1   264.76 332.76
## - FTp         1   264.80 332.80
## - DRBp        1   264.82 332.82
## - eDiff       1   264.87 332.87
## - DRtg        1   264.89 332.89
## - ThreePp     1   264.90 332.90
## - PF          1   264.90 332.90
## - DRB         1   265.14 333.14
## - MOV         1   265.18 333.18
## - FICFourty   1   265.23 333.23
## - FGp         1   265.25 333.25
## - DSRS        1   265.38 333.37
## - BLKp        1   265.42 333.42
## - OSRS        1   265.80 333.80
## - FGM         1   266.06 334.06
## - ORBp        1   266.42 334.42
## - ORB         1   266.44 334.44
## - ASTp        1   266.47 334.47
## <none>            264.62 334.62
## - ThreePA     1   267.84 335.84
## - PTS         1   271.42 339.42
## - PossperMin  1   273.12 341.12
## - Winp        1   293.25 361.25
## 
## Step:  AIC=332.64
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     FGM + FGA + FGp + ThreePA + ThreePp + FTM + FTp + TOV + PF + 
##     ORB + DRB + AST + STL + BLK + PTS + Winp + MOV + SOS + OSRS + 
##     DSRS
## 
##              Df Deviance    AIC
## - FTM         1   264.65 330.65
## - BLK         1   264.66 330.66
## - SOS         1   264.66 330.66
## - PPS         1   264.68 330.68
## - AST         1   264.68 330.68
## - IsPowerSix  1   264.69 330.69
## - ORtg        1   264.73 330.73
## - eFGp        1   264.74 330.74
## - FGA         1   264.75 330.75
## - TSp         1   264.75 330.75
## - TOV         1   264.75 330.75
## - DRBp        1   264.82 330.82
## - FTp         1   264.82 330.82
## - eDiff       1   264.88 330.88
## - DRtg        1   264.90 330.90
## - PF          1   264.91 330.91
## - ThreePp     1   264.91 330.91
## - STL         1   264.93 330.93
## - DRB         1   265.19 331.19
## - MOV         1   265.19 331.19
## - FGp         1   265.25 331.25
## - FICFourty   1   265.31 331.31
## - DSRS        1   265.41 331.41
## - BLKp        1   265.46 331.46
## - OSRS        1   265.84 331.84
## - FGM         1   266.06 332.06
## - ORB         1   266.44 332.44
## - ORBp        1   266.49 332.49
## - ASTp        1   266.54 332.54
## <none>            264.64 332.64
## - ThreePA     1   267.84 333.84
## - PTS         1   271.49 337.49
## - PossperMin  1   273.25 339.25
## - Winp        1   293.82 359.82
## 
## Step:  AIC=330.65
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     FGM + FGA + FGp + ThreePA + ThreePp + FTp + TOV + PF + ORB + 
##     DRB + AST + STL + BLK + PTS + Winp + MOV + SOS + OSRS + DSRS
## 
##              Df Deviance    AIC
## - SOS         1   264.68 328.68
## - BLK         1   264.68 328.68
## - AST         1   264.70 328.70
## - IsPowerSix  1   264.71 328.71
## - PPS         1   264.72 328.72
## - eFGp        1   264.74 328.74
## - ORtg        1   264.74 328.74
## - FGA         1   264.75 328.75
## - TOV         1   264.76 328.76
## - TSp         1   264.80 328.80
## - DRBp        1   264.82 328.82
## - FTp         1   264.84 328.84
## - eDiff       1   264.88 328.88
## - DRtg        1   264.90 328.90
## - PF          1   264.91 328.91
## - ThreePp     1   264.91 328.91
## - STL         1   264.94 328.94
## - MOV         1   265.19 329.19
## - DRB         1   265.20 329.20
## - FGp         1   265.26 329.26
## - FICFourty   1   265.31 329.31
## - DSRS        1   265.42 329.42
## - BLKp        1   265.46 329.47
## - OSRS        1   265.85 329.84
## - FGM         1   266.06 330.06
## - ORBp        1   266.50 330.50
## - ORB         1   266.53 330.53
## - ASTp        1   266.55 330.54
## <none>            264.65 330.65
## - ThreePA     1   267.84 331.84
## - PTS         1   271.50 335.50
## - PossperMin  1   274.00 338.00
## - Winp        1   294.21 358.21
## 
## Step:  AIC=328.68
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     FGM + FGA + FGp + ThreePA + ThreePp + FTp + TOV + PF + ORB + 
##     DRB + AST + STL + BLK + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - BLK         1   264.70 326.70
## - AST         1   264.73 326.73
## - IsPowerSix  1   264.74 326.74
## - PPS         1   264.75 326.75
## - ORtg        1   264.76 326.76
## - FGA         1   264.77 326.77
## - eFGp        1   264.78 326.78
## - TOV         1   264.79 326.79
## - TSp         1   264.81 326.81
## - DRBp        1   264.84 326.84
## - FTp         1   264.86 326.86
## - eDiff       1   264.91 326.91
## - DRtg        1   264.93 326.93
## - ThreePp     1   264.94 326.94
## - STL         1   264.95 326.95
## - PF          1   264.95 326.95
## - DRB         1   265.22 327.22
## - FGp         1   265.27 327.27
## - FICFourty   1   265.33 327.33
## - BLKp        1   265.48 327.48
## - FGM         1   266.11 328.11
## - ORB         1   266.54 328.54
## - ORBp        1   266.56 328.56
## - ASTp        1   266.58 328.58
## <none>            264.68 328.68
## - MOV         1   267.20 329.20
## - ThreePA     1   267.84 329.84
## - PTS         1   271.54 333.54
## - PossperMin  1   274.01 336.01
## - DSRS        1   280.49 342.49
## - OSRS        1   286.88 348.88
## - Winp        1   294.27 356.27
## 
## Step:  AIC=326.7
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     FGM + FGA + FGp + ThreePA + ThreePp + FTp + TOV + PF + ORB + 
##     DRB + AST + STL + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - AST         1   264.75 324.75
## - IsPowerSix  1   264.77 324.77
## - PPS         1   264.78 324.78
## - ORtg        1   264.78 324.78
## - FGA         1   264.80 324.80
## - TOV         1   264.81 324.82
## - eFGp        1   264.82 324.82
## - TSp         1   264.83 324.83
## - DRBp        1   264.86 324.86
## - FTp         1   264.87 324.87
## - eDiff       1   264.93 324.93
## - DRtg        1   264.95 324.95
## - STL         1   264.97 324.97
## - ThreePp     1   264.97 324.97
## - PF          1   264.98 324.98
## - DRB         1   265.23 325.23
## - FGp         1   265.30 325.30
## - FICFourty   1   265.34 325.34
## - BLKp        1   265.75 325.74
## - FGM         1   266.12 326.12
## - ORBp        1   266.57 326.57
## - ORB         1   266.58 326.58
## - ASTp        1   266.58 326.58
## <none>            264.70 326.70
## - MOV         1   267.24 327.24
## - ThreePA     1   267.87 327.87
## - PTS         1   271.61 331.61
## - PossperMin  1   274.05 334.05
## - DSRS        1   280.49 340.49
## - OSRS        1   286.88 346.88
## - Winp        1   294.27 354.27
## 
## Step:  AIC=324.75
## IsEliteEight ~ IsPowerSix + TSp + eFGp + ORBp + DRBp + ASTp + 
##     BLKp + PPS + FICFourty + ORtg + DRtg + eDiff + PossperMin + 
##     FGM + FGA + FGp + ThreePA + ThreePp + FTp + TOV + PF + ORB + 
##     DRB + STL + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - IsPowerSix  1   264.81 322.81
## - ORtg        1   264.82 322.82
## - PPS         1   264.83 322.83
## - FGA         1   264.86 322.86
## - TOV         1   264.86 322.86
## - TSp         1   264.86 322.86
## - eFGp        1   264.89 322.89
## - FTp         1   264.91 322.91
## - DRBp        1   264.92 322.92
## - eDiff       1   264.95 322.95
## - DRtg        1   264.97 322.97
## - STL         1   264.99 322.99
## - ThreePp     1   264.99 322.99
## - PF          1   265.03 323.03
## - DRB         1   265.26 323.26
## - FGp         1   265.38 323.38
## - FICFourty   1   265.39 323.39
## - BLKp        1   265.80 323.80
## - FGM         1   266.21 324.21
## - ORB         1   266.61 324.61
## - ORBp        1   266.70 324.70
## <none>            264.75 324.75
## - ASTp        1   267.09 325.09
## - MOV         1   267.28 325.28
## - ThreePA     1   267.97 325.97
## - PTS         1   271.74 329.74
## - PossperMin  1   274.10 332.10
## - DSRS        1   280.60 338.60
## - OSRS        1   286.93 344.93
## - Winp        1   294.42 352.42
## 
## Step:  AIC=322.81
## IsEliteEight ~ TSp + eFGp + ORBp + DRBp + ASTp + BLKp + PPS + 
##     FICFourty + ORtg + DRtg + eDiff + PossperMin + FGM + FGA + 
##     FGp + ThreePA + ThreePp + FTp + TOV + PF + ORB + DRB + STL + 
##     PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - PPS         1   264.89 320.89
## - ORtg        1   264.91 320.91
## - eFGp        1   264.94 320.94
## - TOV         1   264.94 320.94
## - FGA         1   264.94 320.94
## - TSp         1   264.95 320.95
## - FTp         1   264.98 320.98
## - DRBp        1   265.01 321.01
## - ThreePp     1   265.06 321.06
## - eDiff       1   265.06 321.07
## - STL         1   265.08 321.08
## - PF          1   265.08 321.08
## - DRtg        1   265.09 321.09
## - DRB         1   265.31 321.31
## - FICFourty   1   265.44 321.44
## - FGp         1   265.46 321.46
## - BLKp        1   265.89 321.89
## - FGM         1   266.25 322.25
## - ORB         1   266.73 322.73
## <none>            264.81 322.81
## - ORBp        1   266.85 322.85
## - ASTp        1   267.11 323.11
## - MOV         1   267.61 323.61
## - ThreePA     1   268.03 324.03
## - PTS         1   271.75 327.75
## - PossperMin  1   274.12 330.12
## - Winp        1   294.67 350.67
## - DSRS        1   295.74 351.74
## - OSRS        1   306.44 362.44
## 
## Step:  AIC=320.89
## IsEliteEight ~ TSp + eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     ORtg + DRtg + eDiff + PossperMin + FGM + FGA + FGp + ThreePA + 
##     ThreePp + FTp + TOV + PF + ORB + DRB + STL + PTS + Winp + 
##     MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - ORtg        1   264.98 318.98
## - eFGp        1   264.99 318.99
## - FGA         1   264.99 318.99
## - TOV         1   265.01 319.01
## - FTp         1   265.09 319.09
## - DRBp        1   265.11 319.11
## - eDiff       1   265.13 319.13
## - ThreePp     1   265.13 319.13
## - TSp         1   265.14 319.14
## - DRtg        1   265.15 319.15
## - PF          1   265.17 319.17
## - STL         1   265.18 319.18
## - DRB         1   265.37 319.37
## - FICFourty   1   265.46 319.46
## - FGp         1   265.56 319.56
## - BLKp        1   265.90 319.90
## - FGM         1   266.36 320.36
## - ORB         1   266.75 320.75
## <none>            264.89 320.89
## - ORBp        1   266.92 320.91
## - ASTp        1   267.13 321.14
## - MOV         1   267.66 321.66
## - ThreePA     1   268.07 322.07
## - PTS         1   271.95 325.95
## - PossperMin  1   274.16 328.16
## - Winp        1   295.27 349.27
## - DSRS        1   296.44 350.44
## - OSRS        1   306.45 360.45
## 
## Step:  AIC=318.98
## IsEliteEight ~ TSp + eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     DRtg + eDiff + PossperMin + FGM + FGA + FGp + ThreePA + ThreePp + 
##     FTp + TOV + PF + ORB + DRB + STL + PTS + Winp + MOV + OSRS + 
##     DSRS
## 
##              Df Deviance    AIC
## - FGA         1   265.06 317.06
## - TOV         1   265.09 317.09
## - eFGp        1   265.09 317.09
## - FTp         1   265.17 317.17
## - ThreePp     1   265.20 317.20
## - DRBp        1   265.21 317.21
## - TSp         1   265.21 317.21
## - STL         1   265.24 317.24
## - PF          1   265.28 317.28
## - DRB         1   265.46 317.46
## - FICFourty   1   265.62 317.62
## - FGp         1   265.63 317.63
## - BLKp        1   266.07 318.07
## - FGM         1   266.40 318.40
## - ORB         1   266.86 318.86
## <none>            264.98 318.98
## - ORBp        1   267.10 319.10
## - ASTp        1   267.45 319.45
## - MOV         1   267.70 319.70
## - ThreePA     1   268.15 320.15
## - PTS         1   272.10 324.10
## - eDiff       1   272.88 324.88
## - PossperMin  1   274.47 326.47
## - DRtg        1   275.89 327.89
## - Winp        1   295.28 347.28
## - DSRS        1   296.65 348.65
## - OSRS        1   306.51 358.51
## 
## Step:  AIC=317.06
## IsEliteEight ~ TSp + eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     DRtg + eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + 
##     FTp + TOV + PF + ORB + DRB + STL + PTS + Winp + MOV + OSRS + 
##     DSRS
## 
##              Df Deviance    AIC
## - TOV         1   265.18 315.18
## - FTp         1   265.21 315.21
## - TSp         1   265.21 315.21
## - eFGp        1   265.26 315.26
## - DRBp        1   265.29 315.29
## - STL         1   265.30 315.30
## - ThreePp     1   265.31 315.31
## - PF          1   265.35 315.35
## - DRB         1   265.56 315.56
## - FGp         1   265.70 315.70
## - FICFourty   1   265.71 315.71
## - BLKp        1   266.16 316.16
## - FGM         1   266.66 316.66
## - ORB         1   266.93 316.93
## <none>            265.06 317.06
## - ORBp        1   267.19 317.19
## - ASTp        1   267.48 317.48
## - MOV         1   267.74 317.74
## - ThreePA     1   268.23 318.23
## - PTS         1   272.11 322.11
## - eDiff       1   272.95 322.95
## - PossperMin  1   275.30 325.30
## - DRtg        1   276.17 326.17
## - Winp        1   295.37 345.37
## - DSRS        1   296.71 346.71
## - OSRS        1   307.17 357.17
## 
## Step:  AIC=315.18
## IsEliteEight ~ TSp + eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     DRtg + eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + 
##     FTp + PF + ORB + DRB + STL + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - TSp         1   265.30 313.30
## - FTp         1   265.35 313.35
## - eFGp        1   265.35 313.35
## - DRBp        1   265.39 313.39
## - STL         1   265.39 313.39
## - PF          1   265.43 313.43
## - ThreePp     1   265.45 313.45
## - DRB         1   265.67 313.67
## - FICFourty   1   265.75 313.75
## - FGp         1   265.84 313.84
## - BLKp        1   266.18 314.18
## - FGM         1   266.83 314.83
## - ORB         1   266.98 314.98
## <none>            265.18 315.18
## - ORBp        1   267.21 315.21
## - ASTp        1   267.54 315.54
## - MOV         1   267.77 315.77
## - ThreePA     1   268.34 316.34
## - PTS         1   272.26 320.26
## - eDiff       1   272.95 320.95
## - PossperMin  1   275.62 323.62
## - DRtg        1   276.59 324.59
## - Winp        1   295.40 343.40
## - DSRS        1   296.98 344.98
## - OSRS        1   307.79 355.79
## 
## Step:  AIC=313.3
## IsEliteEight ~ eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     DRtg + eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + 
##     FTp + PF + ORB + DRB + STL + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - FTp         1   265.38 311.38
## - STL         1   265.50 311.50
## - DRBp        1   265.53 311.53
## - PF          1   265.56 311.56
## - ThreePp     1   265.56 311.56
## - DRB         1   265.69 311.69
## - FICFourty   1   265.76 311.76
## - FGp         1   265.96 311.96
## - BLKp        1   266.20 312.20
## - FGM         1   266.83 312.83
## - ORB         1   267.12 313.12
## - ORBp        1   267.22 313.22
## <none>            265.30 313.30
## - eFGp        1   267.44 313.44
## - ASTp        1   267.55 313.55
## - MOV         1   267.77 313.77
## - ThreePA     1   268.41 314.41
## - PTS         1   272.31 318.31
## - eDiff       1   272.95 318.95
## - PossperMin  1   275.63 321.63
## - DRtg        1   277.27 323.27
## - Winp        1   296.58 342.58
## - DSRS        1   300.36 346.36
## - OSRS        1   310.62 356.62
## 
## Step:  AIC=311.38
## IsEliteEight ~ eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     DRtg + eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + 
##     PF + ORB + DRB + STL + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - STL         1   265.57 309.57
## - DRBp        1   265.58 309.59
## - ThreePp     1   265.61 309.61
## - PF          1   265.63 309.63
## - DRB         1   265.76 309.76
## - FICFourty   1   265.85 309.85
## - FGp         1   266.14 310.14
## - BLKp        1   266.26 310.26
## - FGM         1   266.94 310.94
## - ORB         1   267.26 311.27
## <none>            265.38 311.38
## - ORBp        1   267.56 311.56
## - ASTp        1   267.63 311.63
## - eFGp        1   267.66 311.66
## - MOV         1   267.85 311.85
## - ThreePA     1   268.78 312.78
## - PTS         1   272.46 316.46
## - eDiff       1   273.47 317.47
## - PossperMin  1   275.96 319.96
## - DRtg        1   278.33 322.33
## - Winp        1   296.59 340.59
## - DSRS        1   300.38 344.37
## - OSRS        1   310.65 354.65
## 
## Step:  AIC=309.57
## IsEliteEight ~ eFGp + ORBp + DRBp + ASTp + BLKp + FICFourty + 
##     DRtg + eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + 
##     PF + ORB + DRB + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - DRBp        1   265.73 307.73
## - PF          1   265.75 307.75
## - ThreePp     1   265.84 307.84
## - DRB         1   265.87 307.87
## - FICFourty   1   265.93 307.93
## - BLKp        1   266.29 308.29
## - FGp         1   266.34 308.34
## - FGM         1   267.16 309.16
## - ORB         1   267.44 309.43
## <none>            265.57 309.57
## - ASTp        1   267.63 309.63
## - ORBp        1   267.79 309.79
## - eFGp        1   267.83 309.83
## - MOV         1   267.91 309.91
## - ThreePA     1   268.87 310.87
## - PTS         1   272.81 314.81
## - eDiff       1   273.64 315.64
## - PossperMin  1   276.19 318.19
## - DRtg        1   278.43 320.43
## - Winp        1   296.66 338.66
## - DSRS        1   300.65 342.65
## - OSRS        1   310.68 352.68
## 
## Step:  AIC=307.73
## IsEliteEight ~ eFGp + ORBp + ASTp + BLKp + FICFourty + DRtg + 
##     eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + PF + 
##     ORB + DRB + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - PF          1   265.93 305.93
## - ThreePp     1   265.98 305.98
## - FICFourty   1   266.17 306.17
## - DRB         1   266.38 306.38
## - BLKp        1   266.39 306.39
## - FGp         1   266.47 306.47
## - FGM         1   267.25 307.25
## <none>            265.73 307.73
## - ORB         1   267.75 307.75
## - ORBp        1   267.95 307.95
## - ASTp        1   268.04 308.04
## - eFGp        1   268.15 308.15
## - MOV         1   268.23 308.23
## - ThreePA     1   268.94 308.94
## - PTS         1   272.86 312.86
## - eDiff       1   273.81 313.81
## - PossperMin  1   276.45 316.45
## - DRtg        1   278.90 318.90
## - Winp        1   297.11 337.11
## - DSRS        1   301.20 341.20
## - OSRS        1   314.94 354.94
## 
## Step:  AIC=305.93
## IsEliteEight ~ eFGp + ORBp + ASTp + BLKp + FICFourty + DRtg + 
##     eDiff + PossperMin + FGM + FGp + ThreePA + ThreePp + ORB + 
##     DRB + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - FICFourty   1   266.19 304.19
## - ThreePp     1   266.22 304.22
## - BLKp        1   266.43 304.43
## - DRB         1   266.45 304.45
## - FGp         1   266.58 304.58
## - FGM         1   267.51 305.51
## <none>            265.93 305.93
## - ASTp        1   268.04 306.04
## - ORBp        1   268.08 306.08
## - MOV         1   268.30 306.30
## - eFGp        1   268.30 306.30
## - ORB         1   268.39 306.39
## - ThreePA     1   269.09 307.09
## - PTS         1   272.88 310.88
## - eDiff       1   273.90 311.90
## - PossperMin  1   276.99 314.99
## - DRtg        1   279.83 317.83
## - Winp        1   297.16 335.16
## - DSRS        1   301.49 339.49
## - OSRS        1   314.98 352.98
## 
## Step:  AIC=304.19
## IsEliteEight ~ eFGp + ORBp + ASTp + BLKp + DRtg + eDiff + PossperMin + 
##     FGM + FGp + ThreePA + ThreePp + ORB + DRB + PTS + Winp + 
##     MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - ThreePp     1   266.40 302.40
## - BLKp        1   266.43 302.43
## - DRB         1   266.46 302.46
## - FGp         1   266.95 302.95
## - ORBp        1   268.10 304.10
## <none>            266.19 304.19
## - ASTp        1   268.30 304.30
## - MOV         1   268.30 304.30
## - eFGp        1   268.41 304.41
## - FGM         1   268.42 304.42
## - ORB         1   269.22 305.22
## - ThreePA     1   269.45 305.45
## - PTS         1   273.04 309.04
## - eDiff       1   273.92 309.92
## - PossperMin  1   276.99 312.99
## - DRtg        1   282.32 318.32
## - Winp        1   298.05 334.05
## - DSRS        1   301.52 337.52
## - OSRS        1   318.14 354.14
## 
## Step:  AIC=302.4
## IsEliteEight ~ eFGp + ORBp + ASTp + BLKp + DRtg + eDiff + PossperMin + 
##     FGM + FGp + ThreePA + ORB + DRB + PTS + Winp + MOV + OSRS + 
##     DSRS
## 
##              Df Deviance    AIC
## - DRB         1   266.65 300.65
## - BLKp        1   266.69 300.69
## - FGp         1   267.23 301.23
## - ORBp        1   268.29 302.29
## <none>            266.40 302.40
## - MOV         1   268.41 302.41
## - FGM         1   268.50 302.50
## - ASTp        1   268.59 302.59
## - eFGp        1   269.18 303.18
## - ORB         1   269.61 303.61
## - ThreePA     1   269.93 303.93
## - PTS         1   273.27 307.27
## - eDiff       1   274.31 308.31
## - PossperMin  1   277.25 311.25
## - DRtg        1   282.49 316.49
## - Winp        1   298.42 332.42
## - DSRS        1   301.83 335.83
## - OSRS        1   318.77 352.77
## 
## Step:  AIC=300.65
## IsEliteEight ~ eFGp + ORBp + ASTp + BLKp + DRtg + eDiff + PossperMin + 
##     FGM + FGp + ThreePA + ORB + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - BLKp        1   266.99 298.99
## - FGp         1   267.45 299.45
## - MOV         1   268.55 300.55
## <none>            266.65 300.65
## - FGM         1   268.77 300.77
## - ASTp        1   269.16 301.16
## - ORBp        1   269.25 301.25
## - eFGp        1   269.48 301.48
## - ORB         1   269.61 301.61
## - ThreePA     1   270.58 302.58
## - PTS         1   273.41 305.41
## - eDiff       1   275.18 307.18
## - PossperMin  1   278.15 310.15
## - DRtg        1   283.36 315.36
## - Winp        1   299.55 331.55
## - DSRS        1   302.13 334.13
## - OSRS        1   319.91 351.91
## 
## Step:  AIC=298.99
## IsEliteEight ~ eFGp + ORBp + ASTp + DRtg + eDiff + PossperMin + 
##     FGM + FGp + ThreePA + ORB + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - FGp         1   267.79 297.79
## - MOV         1   268.88 298.88
## <none>            266.99 298.99
## - FGM         1   269.05 299.05
## - ASTp        1   269.34 299.34
## - ORBp        1   269.39 299.39
## - eFGp        1   269.65 299.65
## - ORB         1   269.85 299.85
## - ThreePA     1   271.21 301.21
## - PTS         1   273.70 303.70
## - eDiff       1   275.32 305.32
## - PossperMin  1   278.68 308.68
## - DRtg        1   283.43 313.43
## - Winp        1   299.72 329.72
## - DSRS        1   302.55 332.55
## - OSRS        1   319.95 349.95
## 
## Step:  AIC=297.79
## IsEliteEight ~ eFGp + ORBp + ASTp + DRtg + eDiff + PossperMin + 
##     FGM + ThreePA + ORB + PTS + Winp + MOV + OSRS + DSRS
## 
##              Df Deviance    AIC
## - MOV         1   269.67 297.67
## <none>            267.79 297.79
## - FGM         1   270.06 298.06
## - ORBp        1   270.17 298.17
## - ASTp        1   270.19 298.19
## - ORB         1   270.85 298.85
## - ThreePA     1   271.29 299.29
## - eFGp        1   272.68 300.68
## - PTS         1   274.53 302.53
## - eDiff       1   276.36 304.36
## - PossperMin  1   279.49 307.49
## - DRtg        1   284.56 312.56
## - Winp        1   300.50 328.50
## - DSRS        1   303.01 331.01
## - OSRS        1   320.33 348.33
## 
## Step:  AIC=297.67
## IsEliteEight ~ eFGp + ORBp + ASTp + DRtg + eDiff + PossperMin + 
##     FGM + ThreePA + ORB + PTS + Winp + OSRS + DSRS
## 
##              Df Deviance    AIC
## <none>            269.67 297.67
## - ORBp        1   272.12 298.12
## - FGM         1   272.35 298.35
## - ASTp        1   272.35 298.35
## - ORB         1   272.63 298.63
## - ThreePA     1   273.38 299.38
## - eFGp        1   273.81 299.81
## - PTS         1   276.70 302.70
## - PossperMin  1   284.92 310.92
## - DRtg        1   285.81 311.81
## - eDiff       1   298.66 324.66
## - Winp        1   300.77 326.77
## - DSRS        1   303.75 329.75
## - OSRS        1   320.38 346.38
summary(seasonstatsmodel.glm.back)
## 
## Call:
## glm(formula = IsEliteEight ~ eFGp + ORBp + ASTp + DRtg + eDiff + 
##     PossperMin + FGM + ThreePA + ORB + PTS + Winp + OSRS + DSRS, 
##     family = "binomial", data = seasonstatsmodel.train)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9911  -0.3063  -0.1203  -0.0175   3.1685  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -1.677      5.543  -0.302 0.762280    
## eFGp           5.511      2.737   2.013 0.044095 *  
## ORBp           3.270      2.104   1.554 0.120244    
## ASTp          -2.607      1.613  -1.617 0.105946    
## DRtg         -31.012      8.380  -3.701 0.000215 ***
## eDiff        -25.852      5.455  -4.739 2.15e-06 ***
## PossperMin   -23.661      6.370  -3.714 0.000204 ***
## FGM            3.089      1.903   1.623 0.104658    
## ThreePA        1.958      1.027   1.906 0.056686 .  
## ORB            3.902      2.295   1.700 0.089111 .  
## PTS           10.301      3.974   2.592 0.009529 ** 
## Winp           8.405      1.623   5.178 2.25e-07 ***
## OSRS          19.016      3.360   5.660 1.51e-08 ***
## DSRS          13.246      2.663   4.974 6.56e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 509.44  on 668  degrees of freedom
## Residual deviance: 269.67  on 655  degrees of freedom
## AIC: 297.67
## 
## Number of Fisher Scoring iterations: 8
dim(seasonstatsmodel.glm.back)
## NULL
sum.back <- summary(seasonstatsmodel.glm.back)
dim(sum.back$coefficients)
## [1] 14  4
AIC(seasonstatsmodel.glm.back)
## [1] 297.672
pred.glm3.train <- predict(seasonstatsmodel.glm.back, type = "response")
pred.glm3.valid <- predict(seasonstatsmodel.glm.back, newdata = seasonstatsmodel.valid, type = "response")
confusionMatrix(as.factor(ifelse(pred.glm3.train >= optimal.pcut.glm, "1", "0")), as.factor(seasonstatsmodel.train$IsEliteEight), 
                positive = "1")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   0   1
##          0 271   1
##          1 313  84
##                                         
##                Accuracy : 0.5306        
##                  95% CI : (0.492, 0.569)
##     No Information Rate : 0.8729        
##     P-Value [Acc > NIR] : 1             
##                                         
##                   Kappa : 0.1761        
##                                         
##  Mcnemar's Test P-Value : <2e-16        
##                                         
##             Sensitivity : 0.9882        
##             Specificity : 0.4640        
##          Pos Pred Value : 0.2116        
##          Neg Pred Value : 0.9963        
##              Prevalence : 0.1271        
##          Detection Rate : 0.1256        
##    Detection Prevalence : 0.5934        
##       Balanced Accuracy : 0.7261        
##                                         
##        'Positive' Class : 1             
## 
#Perform stepwise regression - best model (Same as forward)
seasonstatsmodel.glm.step <- step(seasonstatsmodel.glm.null, scope = list(seasonstatsmodel.glm.null, upper = seasonstatsmodel.glm), 
                          direction = "both")
## Start:  AIC=511.44
## IsEliteEight ~ 1
## 
##              Df Deviance    AIC
## + Winp        1   390.59 394.59
## + MOV         1   406.23 410.23
## + SOS         1   427.63 431.63
## + OSRS        1   435.25 439.25
## + eDiff       1   435.91 439.91
## + IsPowerSix  1   449.26 453.26
## + FICFourty   1   454.33 458.33
## + DSRS        1   457.69 461.69
## + DRtg        1   478.56 482.56
## + FGM         1   479.94 483.94
## + PTS         1   480.73 484.73
## + ORBp        1   490.51 494.51
## + ORtg        1   491.53 495.53
## + BLKp        1   491.57 495.57
## + BLK         1   492.17 496.17
## + FGA         1   494.01 498.01
## + FGp         1   494.57 498.57
## + eFGp        1   497.05 501.05
## + ORB         1   498.29 502.29
## + TOVp        1   498.93 502.93
## + AST         1   500.10 504.10
## + ThreePp     1   502.43 506.43
## + TSp         1   504.13 508.13
## + DRB         1   505.16 509.16
## + PF          1   505.32 509.32
## + Pace        1   506.18 510.18
## + PossperMin  1   506.28 510.28
## + PPS         1   506.62 510.62
## + STL         1   506.84 510.84
## + STLp        1   507.19 511.19
## <none>            509.44 511.44
## + TOV         1   508.00 512.00
## + ThreePM     1   508.42 512.42
## + DRBp        1   508.96 512.96
## + ThreePA     1   509.13 513.13
## + FTp         1   509.19 513.19
## + FTA         1   509.21 513.21
## + FTM         1   509.28 513.28
## + ASTp        1   509.41 513.41
## 
## Step:  AIC=394.59
## IsEliteEight ~ Winp
## 
##              Df Deviance    AIC
## + SOS         1   295.10 301.10
## + IsPowerSix  1   321.07 327.07
## + OSRS        1   357.10 363.10
## + DSRS        1   376.56 382.56
## + FGA         1   382.49 388.49
## + ORB         1   383.35 389.35
## + FICFourty   1   384.91 390.91
## + FGM         1   384.93 390.93
## + BLK         1   385.79 391.79
## + MOV         1   385.80 391.80
## + ORBp        1   385.92 391.92
## + PTS         1   386.15 392.15
## + BLKp        1   386.68 392.68
## + Pace        1   386.79 392.79
## + PossperMin  1   386.82 392.82
## + DRBp        1   388.43 394.43
## <none>            390.59 394.59
## + ASTp        1   388.84 394.84
## + PPS         1   389.08 395.08
## + TSp         1   389.47 395.47
## + DRB         1   389.60 395.60
## + TOVp        1   389.74 395.74
## + FGp         1   390.09 396.09
## + FTp         1   390.25 396.25
## + eFGp        1   390.37 396.37
## + STL         1   390.38 396.38
## + AST         1   390.40 396.40
## + ThreePp     1   390.47 396.47
## + DRtg        1   390.49 396.49
## + TOV         1   390.53 396.53
## + FTA         1   390.53 396.53
## + eDiff       1   390.56 396.56
## + FTM         1   390.57 396.57
## + ORtg        1   390.58 396.58
## + STLp        1   390.58 396.58
## + ThreePA     1   390.58 396.58
## + ThreePM     1   390.59 396.59
## + PF          1   390.59 396.59
## - Winp        1   509.44 511.44
## 
## Step:  AIC=301.1
## IsEliteEight ~ Winp + SOS
## 
##              Df Deviance    AIC
## + ORB         1   289.40 297.40
## + ORBp        1   291.21 299.21
## + FTp         1   292.78 300.78
## <none>            295.10 301.10
## + TOVp        1   293.35 301.35
## + DRtg        1   293.57 301.57
## + DRBp        1   293.90 301.90
## + MOV         1   294.19 302.19
## + TOV         1   294.23 302.23
## + STLp        1   294.26 302.26
## + IsPowerSix  1   294.29 302.29
## + FGM         1   294.29 302.29
## + FGp         1   294.32 302.32
## + PPS         1   294.44 302.44
## + OSRS        1   294.50 302.50
## + TSp         1   294.52 302.52
## + eDiff       1   294.60 302.60
## + ASTp        1   294.64 302.64
## + FTM         1   294.70 302.70
## + FGA         1   294.71 302.71
## + ORtg        1   294.79 302.79
## + PTS         1   294.79 302.79
## + BLK         1   294.80 302.80
## + STL         1   294.97 302.97
## + eFGp        1   294.97 302.97
## + ThreePp     1   294.97 302.97
## + DRB         1   294.99 302.99
## + Pace        1   294.99 302.99
## + PossperMin  1   295.00 303.00
## + PF          1   295.01 303.01
## + BLKp        1   295.04 303.04
## + DSRS        1   295.05 303.05
## + AST         1   295.05 303.05
## + FICFourty   1   295.08 303.08
## + ThreePA     1   295.09 303.09
## + ThreePM     1   295.10 303.10
## + FTA         1   295.10 303.10
## - SOS         1   390.59 394.59
## - Winp        1   427.63 431.63
## 
## Step:  AIC=297.4
## IsEliteEight ~ Winp + SOS + ORB
## 
##              Df Deviance    AIC
## <none>            289.40 297.40
## + DRtg        1   287.67 297.67
## + FTM         1   287.78 297.78
## + FTp         1   288.06 298.06
## + FGp         1   288.26 298.26
## + DRB         1   288.38 298.38
## + ORtg        1   288.40 298.40
## + FTA         1   288.74 298.74
## + ASTp        1   288.75 298.75
## + TOVp        1   288.84 298.84
## + IsPowerSix  1   288.90 298.90
## + MOV         1   288.91 298.91
## + ThreePM     1   288.94 298.94
## + ThreePp     1   288.94 298.94
## + FICFourty   1   288.96 298.96
## + DRBp        1   288.97 298.97
## + FGM         1   289.00 299.00
## + ThreePA     1   289.01 299.01
## + eFGp        1   289.23 299.23
## + PPS         1   289.23 299.23
## + STLp        1   289.24 299.24
## + PF          1   289.31 299.31
## + eDiff       1   289.33 299.33
## + ORBp        1   289.33 299.33
## + OSRS        1   289.34 299.34
## + DSRS        1   289.35 299.35
## + TOV         1   289.36 299.36
## + BLK         1   289.36 299.36
## + PTS         1   289.36 299.36
## + TSp         1   289.37 299.37
## + Pace        1   289.37 299.37
## + PossperMin  1   289.38 299.38
## + BLKp        1   289.38 299.38
## + AST         1   289.39 299.39
## + STL         1   289.39 299.39
## + FGA         1   289.40 299.40
## - ORB         1   295.10 301.10
## - SOS         1   383.35 389.35
## - Winp        1   416.64 422.64
summary(seasonstatsmodel.glm.step)
## 
## Call:
## glm(formula = IsEliteEight ~ Winp + SOS + ORB, family = "binomial", 
##     data = seasonstatsmodel.train)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9169  -0.3367  -0.1541  -0.0242   3.1765  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -16.8206     1.7991  -9.350  < 2e-16 ***
## Winp          8.7272     0.9705   8.993  < 2e-16 ***
## SOS          11.5636     1.7116   6.756 1.42e-11 ***
## ORB           3.0045     1.2632   2.379   0.0174 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 509.44  on 668  degrees of freedom
## Residual deviance: 289.40  on 665  degrees of freedom
## AIC: 297.4
## 
## Number of Fisher Scoring iterations: 7
sum.step <- summary(seasonstatsmodel.glm.step)
dim(sum.step$coefficients)
## [1] 4 4
AIC(seasonstatsmodel.glm.step)
## [1] 297.3989
pred.glm4.train <- predict(seasonstatsmodel.glm.step, type = "response")
pred.glm4.valid <- predict(seasonstatsmodel.glm.step, newdata = seasonstatsmodel.valid, type = "response")
confusionMatrix(as.factor(ifelse(pred.glm4.train >= optimal.pcut.glm, "1", "0")), as.factor(seasonstatsmodel.train$IsEliteEight), 
                positive = "1")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   0   1
##          0 229   1
##          1 355  84
##                                           
##                Accuracy : 0.4679          
##                  95% CI : (0.4295, 0.5065)
##     No Information Rate : 0.8729          
##     P-Value [Acc > NIR] : 1               
##                                           
##                   Kappa : 0.1369          
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.9882          
##             Specificity : 0.3921          
##          Pos Pred Value : 0.1913          
##          Neg Pred Value : 0.9957          
##              Prevalence : 0.1271          
##          Detection Rate : 0.1256          
##    Detection Prevalence : 0.6562          
##       Balanced Accuracy : 0.6902          
##                                           
##        'Positive' Class : 1               
## 

Set-up data for largetree

# partition the data for CART
set.seed(1)
train.index <- sample(nrow(seasonstatsmodel), nrow(seasonstatsmodel) * 0.6)
seasonstatsmodel.train <- seasonstatsmodel[train.index, ]
seasonstatsmodel.valid <- seasonstatsmodel[-train.index, ]

#Ploting a largetree
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 3.6.3
## Loading required package: rpart
seasonstatsmodel.largetree <- rpart(IsEliteEight ~ ., data = seasonstatsmodel.train, cp = 0.0001, method = "class")
prp(seasonstatsmodel.largetree, digits = 4, type = 1, extra = 1, varlen = -10,
    box.col = ifelse(seasonstatsmodel.largetree$frame$var == "<leaf>", 'gray', 'white'))

plotcp(seasonstatsmodel.largetree)

printcp(seasonstatsmodel.largetree)
## 
## Classification tree:
## rpart(formula = IsEliteEight ~ ., data = seasonstatsmodel.train, 
##     method = "class", cp = 1e-04)
## 
## Variables actually used in tree construction:
## [1] BLKp       MOV        PossperMin SOS        Winp      
## 
## Root node error: 79/669 = 0.11809
## 
## n= 669 
## 
##         CP nsplit rel error  xerror     xstd
## 1 0.126582      0   1.00000 1.00000 0.105657
## 2 0.101266      1   0.87342 1.01266 0.106234
## 3 0.084388      2   0.77215 0.96203 0.103895
## 4 0.050633      5   0.51899 0.70886 0.090674
## 5 0.000100      6   0.46835 0.73418 0.092129
#Pruning
seasonstatsmodel.pruned <- prune(seasonstatsmodel.largetree, cp = 0.000100) 
seasonstatsmodel.pruned
## n= 669 
## 
## node), split, n, loss, yval, (yprob)
##       * denotes terminal node
## 
##  1) root 669 79 0 (0.88191330 0.11808670)  
##    2) MOV< 0.6858309 629 54 0 (0.91414944 0.08585056)  
##      4) SOS< 0.8138402 456  9 0 (0.98026316 0.01973684) *
##      5) SOS>=0.8138402 173 45 0 (0.73988439 0.26011561)  
##       10) Winp< 0.4817053 107  7 0 (0.93457944 0.06542056) *
##       11) Winp>=0.4817053 66 28 1 (0.42424242 0.57575758)  
##         22) BLKp< 0.3651079 38 14 0 (0.63157895 0.36842105)  
##           44) PossperMin>=0.5947503 28  7 0 (0.75000000 0.25000000) *
##           45) PossperMin< 0.5947503 10  3 1 (0.30000000 0.70000000) *
##         23) BLKp>=0.3651079 28  4 1 (0.14285714 0.85714286) *
##    3) MOV>=0.6858309 40 15 1 (0.37500000 0.62500000)  
##      6) SOS< 0.6516569 10  1 0 (0.90000000 0.10000000) *
##      7) SOS>=0.6516569 30  6 1 (0.20000000 0.80000000) *
prp(seasonstatsmodel.pruned, digits = 4, type = 1, extra = 1, varlen = -10,
    box.col = ifelse(seasonstatsmodel.pruned$frame$var == "<leaf>", 'gray', 'white'))

#confusion Matrix
library(caret)
library(e1071)
seasonstatsmodel.ct0 <- rpart(IsEliteEight ~ ., data = seasonstatsmodel.train, method = "class")
pred0 <- predict(seasonstatsmodel.ct0, type = "class")
confusionMatrix(pred0, as.factor(seasonstatsmodel.train$IsEliteEight), positive = "1")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction   0   1
##          0 577  24
##          1  13  55
##                                           
##                Accuracy : 0.9447          
##                  95% CI : (0.9246, 0.9608)
##     No Information Rate : 0.8819          
##     P-Value [Acc > NIR] : 2.424e-08       
##                                           
##                   Kappa : 0.7174          
##                                           
##  Mcnemar's Test P-Value : 0.1002          
##                                           
##             Sensitivity : 0.69620         
##             Specificity : 0.97797         
##          Pos Pred Value : 0.80882         
##          Neg Pred Value : 0.96007         
##              Prevalence : 0.11809         
##          Detection Rate : 0.08221         
##    Detection Prevalence : 0.10164         
##       Balanced Accuracy : 0.83708         
##                                           
##        'Positive' Class : 1               
## 

KNN Analysis (Clustering similar results to predict successful tournament teams vs others)

Validation with top 8 teams according to logistic regression - 7 of 8 teams in logistic model also

predicted to make Elite 8 using KNN (strong sign for validation purposes, with only team not being predicted

being OSU)

Discriminant Analaysis - commonly used analysis method to predict future data categorization based on historical

training data

Conclusion: Will utililze logistic regression for one model and large tree/KNN/discrimnant analysis to validate