# --- Instalar (solo los que falten) ------------------------------------
paquetes <- c("tidyverse", # ggplot2, dplyr, tidyr, purrr, tibble
"GLMsData", # datos del libro: danishlc, kstones, pock, hcrabs ...
"statmod", # qresid(): residuos cuantílicos aleatorizados
"broom", # tidy(): tablas de coeficientes
"patchwork", # combinar gráficas
"MASS", # glm.nb() (se usa siempre como MASS::)
"sandwich", "lmtest") # errores estándar robustos (opcional)
faltan <- setdiff(paquetes, rownames(installed.packages()))
if (length(faltan) > 0) install.packages(faltan)
# --- Cargar -------------------------------------------------------------
library(tidyverse)
library(GLMsData)
library(statmod)
library(broom)
library(patchwork)
theme_set(theme_minimal(base_size = 14))
col1 <- "#2BA8E0"; col2 <- "#C45BC4"; col3 <- "#E8A33D"
set.seed(2026)