Chapter 4 The Relation Between Runs and Wins

Learning objectives:

  • Introduce sabermetrics
  • Establish Pythagorean win-loss
  • Implement linear regression models
library("abdwr3edata")
library("ggrepel")
library("gt")
library("Lahman")
library("tidyverse")

crcblue <- "#2905A1"
Session Info
sessionInfo()
## R version 4.5.1 (2025-06-13)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.2 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
##  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
##  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
## [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
## 
## time zone: UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] gt_1.0.0          ggrepel_0.9.6     abdwr3edata_0.0.3 lubridate_1.9.4  
##  [5] forcats_1.0.0     stringr_1.5.1     dplyr_1.1.4       purrr_1.1.0      
##  [9] readr_2.1.5       tidyr_1.3.1       tibble_3.3.0      ggplot2_3.5.2    
## [13] tidyverse_2.0.0   Lahman_12.0-0    
## 
## loaded via a namespace (and not attached):
##  [1] sass_0.4.10        utf8_1.2.6         generics_0.1.4     xml2_1.3.8        
##  [5] stringi_1.8.7      hms_1.1.3          digest_0.6.37      magrittr_2.0.3    
##  [9] evaluate_1.0.4     grid_4.5.1         timechange_0.3.0   RColorBrewer_1.1-3
## [13] bookdown_0.43      fastmap_1.2.0      rprojroot_2.1.0    jsonlite_2.0.0    
## [17] promises_1.3.3     scales_1.4.0       jquerylib_0.1.4    cli_3.6.5         
## [21] shiny_1.11.1       rlang_1.1.6        withr_3.0.2        cachem_1.1.0      
## [25] yaml_2.3.10        tools_4.5.1        tzdb_0.5.0         httpuv_1.6.16     
## [29] here_1.0.1         vctrs_0.6.5        R6_2.6.1           mime_0.13         
## [33] lifecycle_1.0.4    pkgconfig_2.0.3    pillar_1.11.0      bslib_0.9.0       
## [37] later_1.4.2        gtable_0.3.6       glue_1.8.0         Rcpp_1.1.0        
## [41] xfun_0.52          tidyselect_1.2.1   rstudioapi_0.17.1  knitr_1.50        
## [45] farver_2.1.2       xtable_1.8-4       htmltools_0.5.8.1  labeling_0.4.3    
## [49] rmarkdown_2.29     compiler_4.5.1