Use R's predict() function to generate predictions from a fitted model for new data. The model and data are required; interval estimates are optional. section 5.7.7
A prediction workflow can:
- Estimate regular-season wins and return fitted values with lower and upper 95% confidence bounds. section 5.7.7
- Compare predictions with observed outcomes by calculating absolute differences such as wins_dif. section 5.7.7
- Return predicted probabilities from logistic regression with type = "response", then convert them into classifications using a threshold. section 14.6.2
- Support evaluation with confusion matrices, sensitivity, specificity, accuracy, and ROC curves. section 14.6.2
Predicting playoff qualification
A fitted logistic model can produce probabilities for test records: predicted_fit3 <- predict(fit3, test, type = "response"). Convert those probabilities into outcomes with predictions %>% mutate(predicted_values2 = ifelse(predicted_values >= 0.50, 1, 0)). Comparing these classifications with actual playoff results produced 73.75% accuracy, 0.80 sensitivity, and 0.63 specificity. section 14.6.2
fit2_pred <- predict(fit2, data.frame(test), interval = "confidence") print(fit2_pred) ## fit lwr upr ## 1 44.03632 37.33518 50.73746 ## 2 32.32559 27.22836 37.42282 ## 3 36.66966 31.99864 41.34067 ## 4 33.97327 29.54744 38.39910 ## 5 34.30091 28.39030 40.21152 ## 6 43.32909 35.93216 50.72603 ## 7 41.24102 35.64396 46.83807 ## 8 44.46051 40.78216 48.13886 ## 9 38.46246 34.58980 42.33511 ## 10 41.12360 36.88138 45.36582 ## 11 44.69284 40.73769 48.64799 ## 12 37.34022 33.95924 40.72119 ## 13 45.32616 39.41971 51.23261 ## 14 50.02897 43.31042 56.74753 ## 15 37.18162 33.31884 41.04439 ## 16 42.25199 35.84835 48.65562 ## 17 33.46908 27.89836 39.03979 ## 18 34.15238 26.87326 41.43151 ## 19 41.70479 36.39175 47.01783 ## 20 34.30830 28.03565 40.58094 ## 21 33.20151 27.19351 39.20951 ## 22 43.30823 36.75603 49.86043 ## 23 36.77234 29.78770 43.75698
Inspect the returned fit, lwr, and upr columns to see how prediction estimates and confidence bounds are organized. section 5.7.7



















