Chapter 12 Poisson & Negative Binomial Regression
Learning objectives:
- Apply Bayesian models to nonnegative counts
- Broaden scope for overdispersed data
# Load packages
library("bayesplot")
library("bayesrules")
library("broom.mixed")
library("patchwork")
library("rstanarm")
library("tidybayes")
library("tidyverse")
sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.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.20.so; LAPACK version 3.10.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] tidybayes_3.0.4 rstanarm_2.21.4 Rcpp_1.0.11
## [4] broom.mixed_0.2.9.4 patchwork_1.1.2 bayesplot_1.10.0
## [7] rstan_2.21.8 StanHeaders_2.26.27 latex2exp_0.9.6
## [10] gt_0.9.0 janitor_2.2.0 bayesrules_0.0.2
## [13] lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0
## [16] dplyr_1.1.2 purrr_1.0.1 readr_2.1.4
## [19] tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2
## [22] tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] RColorBrewer_1.1-3 tensorA_0.36.2 rstudioapi_0.15.0
## [4] jsonlite_1.8.7 magrittr_2.0.3 farver_2.1.1
## [7] nloptr_2.0.3 rmarkdown_2.23 vctrs_0.6.3
## [10] minqa_1.2.5 base64enc_0.1-3 htmltools_0.5.5
## [13] distributional_0.3.2 broom_1.0.5 parallelly_1.36.0
## [16] sass_0.4.6 bslib_0.5.0 htmlwidgets_1.6.2
## [19] plyr_1.8.8 zoo_1.8-12 cachem_1.0.8
## [22] igraph_1.5.0 mime_0.12 lifecycle_1.0.3
## [25] pkgconfig_2.0.3 colourpicker_1.2.0 Matrix_1.5-4.1
## [28] R6_2.5.1 fastmap_1.1.1 future_1.33.0
## [31] shiny_1.7.4.1 snakecase_0.11.0 digest_0.6.33
## [34] colorspace_2.1-0 furrr_0.3.1 ps_1.7.5
## [37] crosstalk_1.2.0 labeling_0.4.2 fansi_1.0.4
## [40] timechange_0.2.0 mgcv_1.8-42 abind_1.4-5
## [43] compiler_4.3.1 proxy_0.4-27 withr_2.5.0
## [46] backports_1.4.1 inline_0.3.19 shinystan_2.6.0
## [49] pkgbuild_1.4.2 highr_0.10 MASS_7.3-60
## [52] gtools_3.9.4 loo_2.6.0 tools_4.3.1
## [55] httpuv_1.6.11 threejs_0.3.3 glue_1.6.2
## [58] DiagrammeR_1.0.10 callr_3.7.3 nlme_3.1-162
## [61] promises_1.2.0.1 grid_4.3.1 checkmate_2.2.0
## [64] reshape2_1.4.4 generics_0.1.3 gtable_0.3.3
## [67] tzdb_0.4.0 class_7.3-22 hms_1.1.3
## [70] xml2_1.3.5 utf8_1.2.3 ggdist_3.3.0
## [73] pillar_1.9.0 markdown_1.7 posterior_1.4.1
## [76] later_1.3.1 splines_4.3.1 lattice_0.21-8
## [79] survival_3.5-5 tidyselect_1.2.0 miniUI_0.1.1.1
## [82] knitr_1.43 arrayhelpers_1.1-0 gridExtra_2.3
## [85] bookdown_0.34 groupdata2_2.0.3 stats4_4.3.1
## [88] xfun_0.39 matrixStats_1.0.0 DT_0.28
## [91] visNetwork_2.1.2 stringi_1.7.12 yaml_2.3.7
## [94] boot_1.3-28.1 evaluate_0.21 codetools_0.2-19
## [97] cli_3.6.1 RcppParallel_5.1.7 shinythemes_1.2.0
## [100] xtable_1.8-4 munsell_0.5.0 processx_3.8.2
## [103] jquerylib_0.1.4 globals_0.16.2 coda_0.19-4
## [106] png_0.1-8 svUnit_1.0.6 parallel_4.3.1
## [109] rstantools_2.3.1 ellipsis_0.3.2 prettyunits_1.1.1
## [112] dygraphs_1.1.1.6 listenv_0.9.0 lme4_1.1-34
## [115] ggthemes_4.2.4 ggridges_0.5.4 scales_1.2.1
## [118] xts_0.13.1 e1071_1.7-13 crayon_1.5.2
## [121] rlang_1.1.1 shinyjs_2.1.0