Logistic regression predicts the probability of a binary outcome from one or more predictors. The target is coded as two classes, commonly 0/1 or No/Yes, and predicted probabilities always remain between 0 and 1. A probability of 0.50 or higher can be used to classify a case as Yes. section 14.6 section 14.6.2
Unlike linear regression, which can produce impossible probabilities below 0 or above 1, logistic regression uses maximum likelihood estimation. It models log odds—the log of p divided by 1 minus p—as a linear combination of an intercept and predictor coefficient. section 14.6.2
A practical workflow is to:
- Create a binary target and split the data into training and prediction subsets. section 14.6
- Fit a binomial model with base R’s glm(), using one predictor for a simple logistic regression. section 14.6.2
- Convert predicted probabilities to classes, then assess a confusion matrix, sensitivity, specificity, error rate, accuracy, and ROC AUC. section 14.6.2
Predicting NBA playoff qualification
A pair of simple models predicts whether an NBA team reaches the postseason: one uses standardized points allowed and the other standardized points scored. Both predictors are statistically significant; the points-allowed model has stronger pseudo-R², lower AIC, and higher sensitivity, while the models have essentially equal AUCs. section 14.6.2 section 14.8
fit3 <- glm(playoffs2 ~ z_o_pts, family = "binomial", data = train) summary(fit3) ## ## Call: ## glm(formula = playoffs2 ~ z_o_pts, family = "binomial", data = train) ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -2.17428 -0.77250 -0.01473 0.76694 2.13669 ## ## Coefficients: ## Estimate Std. Error z value Pr(>|z|) ## (Intercept) 0.1998 0.1727 1.157 0.247 ## z_o_pts -1.7210 0.2317 -7.428 0.00000000000011 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## (Dispersion parameter for binomial family taken to be 1) ## ## Null deviance: 304.98 on 219 degrees of freedom ## Residual deviance: 210.91 on 218 degrees of freedom ## AIC: 214.91 ## ## Number of Fisher Scoring iterations: 5
This glm() call fits a binomial model for playoff qualification from standardized opponent points allowed and prints coefficients, deviance, AIC, and significance output. section 14.6.2











