Some sample scripts
Author

Sir Panda

Published

November 11, 2018

Code
library(mgcv) # Fit and interrogate GAMs
library(tidyverse) # Tidy and flexible data manipulation
library(marginaleffects) # Compute conditional and marginal effects
library(ggplot2) # Flexible plotting
library(patchwork) # Combining ggplot objects


plant <- CO2 |>
  as_tibble() |>
  rename(plant = Plant, type = Type, treatment = Treatment) |>
  mutate(plant = factor(plant, ordered = FALSE))

Code
model_1 <- gam(
  uptake ~ treatment * type +
    s(plant, bs = "re") +
    s(conc, by = treatment, k = 7),
  data = plant,
  method = "REML",
  family = Gamma(link = "log")
)
summary(model_1)
#> 
#> Family: Gamma 
#> Link function: log 
#> 
#> Formula:
#> uptake ~ treatment * type + s(plant, bs = "re") + s(conc, by = treatment, 
#>     k = 7)
#> 
#> Parametric coefficients:
#>                                  Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)                        3.5161     0.0638   55.14  < 2e-16 ***
#> treatmentchilled                  -0.1132     0.0902   -1.26  0.21399    
#> typeMississippi                   -0.3120     0.0902   -3.46  0.00098 ***
#> treatmentchilled:typeMississippi  -0.3604     0.1275   -2.83  0.00631 ** 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Approximate significance of smooth terms:
#>                              edf Ref.df     F p-value    
#> s(plant)                    7.03   8.00  8.02  <2e-16 ***
#> s(conc):treatmentnonchilled 5.19   5.68 83.89  <2e-16 ***
#> s(conc):treatmentchilled    5.01   5.55 58.97  <2e-16 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> R-sq.(adj) =  0.957   Deviance explained = 95.5%
#> -REML = 239.08  Scale est. = 0.010327  n = 84
coef(model_1)
#>                      (Intercept)                 treatmentchilled                  typeMississippi 
#>                          3.51609                         -0.11321                         -0.31196 
#> treatmentchilled:typeMississippi                       s(plant).1                       s(plant).2 
#>                         -0.36041                         -0.04123                         -0.01529 
#>                       s(plant).3                       s(plant).4                       s(plant).5 
#>                          0.05652                         -0.04010                          0.02693 
#>                       s(plant).6                       s(plant).7                       s(plant).8 
#>                          0.01317                         -0.05593                          0.04989 
#>                       s(plant).9                      s(plant).10                      s(plant).11 
#>                          0.00604                         -0.21558                          0.09712 
#>                      s(plant).12    s(conc):treatmentnonchilled.1    s(conc):treatmentnonchilled.2 
#>                          0.11846                          5.23232                          1.13324 
#>    s(conc):treatmentnonchilled.3    s(conc):treatmentnonchilled.4    s(conc):treatmentnonchilled.5 
#>                         -1.90483                          0.12919                          0.23606 
#>    s(conc):treatmentnonchilled.6       s(conc):treatmentchilled.1       s(conc):treatmentchilled.2 
#>                          1.20260                          3.69059                          2.11750 
#>       s(conc):treatmentchilled.3       s(conc):treatmentchilled.4       s(conc):treatmentchilled.5 
#>                         -2.36770                          0.06347                          0.23654 
#>       s(conc):treatmentchilled.6 
#>                          0.96775

Code
plot(model_1, select = 2, shade = TRUE)
abline(h = 0, lty = "dashed")


Code
plot_predictions(model_1,
  condition = "conc",
  type = "link"
) +
  labs(
    y = "Linear predictor (link scale)",
    title = "Average smooth effect of concentration",
    subtitle = "Aggregated across treatments and types"
  )


Code
plot_predictions(model_1,
  condition = c("conc", "treatment", "type"),
  type = "link"
) +
  labs(
    y = "Linear predictor (link scale)",
    title = "Average smooth effect of concentration",
    subtitle = "Per treatment, per type"
  )


Code
plot_slopes(model_1,
  variables = "conc",
  condition = c("conc", "treatment"),
  type = "link"
) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  labs(
    y = "1st derivative of the linear predictor",
    title = "Conditional slopes of the concentration effect",
    subtitle = "Per treatment, per type"
  )

Code
plot_predictions(model_1,
  condition = "conc",
  type = "response", points = 0.5,
  rug = TRUE
) +
  labs(
    y = "Expected response",
    title = "Average smooth effect of concentration",
    subtitle = "Aggregated across treatments and types"
  )

Code
plot_predictions(model_1,
  condition = c("conc", "treatment", "type"),
  type = "response", points = 0.5,
  rug = TRUE
) +
  labs(
    y = "Expected response",
    title = "Average smooth effect of concentration",
    subtitle = "Per treatment, per type"
  )

Code
plot_slopes(model_1,
  variables = "conc",
  condition = c("conc", "treatment", "type"),
  type = "response"
) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  labs(
    y = "1st derivative of the expected response",
    title = "Conditional slopes of the concentration effect",
    subtitle = "Per treatment, per type"
  )


Code
Xp <- predict(model_1, type = "lpmatrix")
dim(Xp)
#> [1] 84 28
colnames(Xp)
#>  [1] "(Intercept)"                      "treatmentchilled"                 "typeMississippi"                 
#>  [4] "treatmentchilled:typeMississippi" "s(plant).1"                       "s(plant).2"                      
#>  [7] "s(plant).3"                       "s(plant).4"                       "s(plant).5"                      
#> [10] "s(plant).6"                       "s(plant).7"                       "s(plant).8"                      
#> [13] "s(plant).9"                       "s(plant).10"                      "s(plant).11"                     
#> [16] "s(plant).12"                      "s(conc):treatmentnonchilled.1"    "s(conc):treatmentnonchilled.2"   
#> [19] "s(conc):treatmentnonchilled.3"    "s(conc):treatmentnonchilled.4"    "s(conc):treatmentnonchilled.5"   
#> [22] "s(conc):treatmentnonchilled.6"    "s(conc):treatmentchilled.1"       "s(conc):treatmentchilled.2"      
#> [25] "s(conc):treatmentchilled.3"       "s(conc):treatmentchilled.4"       "s(conc):treatmentchilled.5"      
#> [28] "s(conc):treatmentchilled.6"
beta <- coef(model_1)
all.equal(names(beta), colnames(Xp))
#> [1] TRUE

Code
preds <- as.vector(Xp %*% beta)
all.equal(fitted(model_1), exp(preds))
#> [1] TRUE
newXp <- predict(model_1,
  type = "lpmatrix",
  newdata = data.frame(
    plant = "Qn1",
    treatment = "nonchilled",
    type = "Mississippi",
    conc = 278
  )
)
dim(newXp)
#> [1]  1 28
exp(newXp %*% beta)
#>   [,1]
#> 1 27.6

Code
conc_seq <- seq(from = min(plant$conc), max(plant$conc), length.out = 500)
newdat <- data.frame(
  conc = conc_seq,
  plant = "Qn1",
  treatment = "nonchilled",
  type = "Mississippi"
)
newXp <- predict(model_1, type = "lpmatrix", newdata = newdat)
conc_coefs <- model_1$smooth[[2]]$first.para:model_1$smooth[[2]]$last.para
conc_coefs
#> [1] 17 18 19 20 21 22

Trace plot of imputed datasets.

Python


Code
model_2 <- glm(
  uptake ~ treatment * type +
    poly(conc, 4) * treatment + plant,
  data = plant,
  family = Gamma(link = "log")
)
plot_predictions(model_1,
  condition = c("conc", "treatment", "type"),
  type = "response", points = 0.5,
  rug = TRUE
) +
  labs(
    y = "Expected response",
    title = "Average smooth effect of concentration",
    subtitle = "Per treatment, per type"
  )

Code
plot_predictions(model_2,
  condition = c("conc", "treatment", "type"),
  type = "response", points = 0.5,
  rug = TRUE
) +
  labs(
    y = "Expected response",
    title = "Average smooth effect of concentration",
    subtitle = "Per treatment, per type"
  )


R


Code
avg_comparisons(model_1,
  newdata = datagrid(
    conc = conc_seq,
    treatment = unique,
    type = unique
  ),
  variables = "treatment",
  by = "type"
)
#> 
#>         type Estimate Std. Error     z Pr(>|z|)    S 2.5 % 97.5 %
#>  Quebec         -4.76       3.04 -1.57    0.117  3.1 -10.7   1.19
#>  Mississippi   -10.71       2.20 -4.87   <0.001 19.8 -15.0  -6.40
#> 
#> Term: treatment
#> Type: response
#> Comparison: chilled - nonchilled
avg_comparisons(model_1,
  newdata = datagrid(
    conc = conc_seq,
    treatment = unique,
    type = unique
  ),
  variables = "treatment",
  by = c("conc", "type")
)
#> 
#>    conc        type Estimate Std. Error      z Pr(>|z|)    S  2.5 % 97.5 %
#>    95.0 Quebec         0.413       1.60  0.258  0.79644  0.3  -2.73   3.55
#>    95.0 Mississippi   -3.114       1.02 -3.057  0.00224  8.8  -5.11  -1.12
#>    96.8 Quebec         0.373       1.61  0.232  0.81662  0.3  -2.78   3.53
#>    96.8 Mississippi   -3.183       1.03 -3.102  0.00192  9.0  -5.19  -1.17
#>    98.6 Quebec         0.332       1.62  0.205  0.83731  0.3  -2.84   3.51
#> --- 990 rows omitted. See ?print.marginaleffects ---
#>   996.4 Mississippi  -11.426       2.75 -4.156  < 0.001 14.9 -16.81  -6.04
#>   998.2 Quebec        -4.436       3.97 -1.119  0.26334  1.9 -12.21   3.34
#>   998.2 Mississippi  -11.427       2.76 -4.147  < 0.001 14.9 -16.83  -6.03
#>  1000.0 Quebec        -4.435       3.98 -1.115  0.26467  1.9 -12.23   3.36
#>  1000.0 Mississippi  -11.428       2.76 -4.138  < 0.001 14.8 -16.84  -6.02
#> Term: treatment
#> Type: response
#> Comparison: chilled - nonchilled
plot_comparisons(model_1,
  newdata = datagrid(
    conc = conc_seq,
    treatment = unique,
    type = unique
  ),
  variables = "treatment",
  by = c("conc", "type"),
  type = "link"
) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  labs(
    y = "Estimated difference",
    title = "Difference between treatment levels",
    subtitle = "Chilled - nonchilled, per type"
  )


Stata


Code
max_growth <- function(hi, lo, x) {
  dydx <- (hi - lo) / 1e-6
  dydx_max <- max(dydx)
  x[dydx == dydx_max][1]
}

comparisons(model_1,
  newdata = datagrid(
    conc = conc_seq,
    treatment = unique,
    type = unique
  ),
  variables = list("conc" = 1e-6),
  vcov = FALSE,
  by = "treatment",
  comparison = max_growth
)
#> 
#>   treatment Estimate
#>  nonchilled      157
#>  chilled         151
#> 
#> Term: conc
#> Type: response
#> Comparison: +1e-06
hypotheses(slopes(model_1,
  newdata = datagrid(
    conc = conc_seq,
    treatment = unique,
    type = unique
  ),
  variables = "conc",
  by = c("conc", "treatment"),
  type = "link"
)) %>%
  dplyr::filter(p.value <= 0.05)
#> 
#>  Estimate Std. Error    z Pr(>|z|)    S    2.5 %  97.5 %
#>   0.00809   0.000877 9.23   <0.001 65.0 6.37e-03 0.00981
#>   0.00647   0.000830 7.80   <0.001 47.2 4.84e-03 0.00810
#>   0.00809   0.000878 9.21   <0.001 64.7 6.36e-03 0.00981
#>   0.00647   0.000828 7.81   <0.001 47.3 4.85e-03 0.00809
#>   0.00808   0.000874 9.25   <0.001 65.2 6.37e-03 0.00980
#> --- 196 rows omitted. See ?print.marginaleffects ---
#>   0.00127   0.000504 2.52   0.0116  6.4 2.84e-04 0.00226
#>   0.00122   0.000515 2.37   0.0178  5.8 2.12e-04 0.00223
#>   0.00117   0.000521 2.25   0.0243  5.4 1.52e-04 0.00219
#>   0.00113   0.000529 2.13   0.0334  4.9 8.84e-05 0.00216
#>   0.00108   0.000545 1.98   0.0476  4.4 1.15e-05 0.00215
#> Term: conc

Computational Environments


Overall Platforms


Code
sessioninfo::session_info(info = c("platform", "external"))
#> ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.2 (2025-10-31)
#>  os       macOS Tahoe 26.3
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       America/New_York
#>  date     2026-01-30
#>  pandoc   3.8.3 @ /opt/homebrew/bin/ (via rmarkdown)
#>  quarto   1.8.27 @ /Applications/quarto/bin/quarto
#> 
#> ─ External software ────────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting        value
#>  cairo          1.17.6
#>  cairoFT
#>  pango          1.50.14
#>  png            1.6.44
#>  jpeg           9.5
#>  tiff           LIBTIFF, Version 4.5.0
#>  tcl            8.6.13
#>  curl           8.7.1
#>  zlib           1.2.12
#>  bzlib          1.0.8, 13-Jul-2019
#>  xz             5.6.3
#>  deflate        1.23
#>  PCRE           10.44 2024-06-07
#>  ICU            76.1
#>  TRE            TRE 0.8.0 R_fixes (BSD)
#>  iconv          Apple or GNU libiconv 1.11 /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libR.dylib
#>  readline       5.2
#>  BLAS           /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
#>  lapack         /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib
#>  lapack_version 3.12.1
#> 
#> ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

R Packages


Code
sessioninfo::session_info(info = "packages")
#> ═ Session info ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════
#> ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  package           * version    date (UTC) lib source
#>  abind               1.4-8      2024-09-12 [1] CRAN (R 4.5.0)
#>  Amelia            * 1.8.3      2024-11-08 [1] CRAN (R 4.5.0)
#>  arm                 1.14-4     2024-04-01 [1] CRAN (R 4.5.0)
#>  arrayhelpers        1.1-0      2020-02-04 [1] CRAN (R 4.5.0)
#>  askpass             1.2.1      2024-10-04 [1] CRAN (R 4.5.0)
#>  backports           1.5.0      2024-05-23 [1] CRAN (R 4.5.0)
#>  base64enc           0.1-3      2015-07-28 [1] CRAN (R 4.5.0)
#>  bayesplot         * 1.15.0     2025-12-12 [1] CRAN (R 4.5.2)
#>  bbotk               1.8.1      2025-11-26 [1] CRAN (R 4.5.2)
#>  bcaboot             0.2-3      2021-05-09 [1] CRAN (R 4.5.0)
#>  bitops              1.0-9      2024-10-03 [1] CRAN (R 4.5.0)
#>  blogdown          * 1.23       2026-01-18 [1] CRAN (R 4.5.2)
#>  boot              * 1.3-32     2025-08-29 [1] CRAN (R 4.5.0)
#>  bootImpute        * 1.3.0      2025-12-15 [1] CRAN (R 4.5.2)
#>  bridgesampling      1.2-1      2025-11-19 [1] CRAN (R 4.5.2)
#>  brms              * 2.23.0     2025-09-09 [1] CRAN (R 4.5.0)
#>  Brobdingnag         1.2-9      2022-10-19 [1] CRAN (R 4.5.0)
#>  broom             * 1.0.12     2026-01-27 [1] CRAN (R 4.5.2)
#>  broom.mixed       * 0.2.9.6    2024-10-15 [1] CRAN (R 4.5.0)
#>  Cairo             * 1.7-0      2025-10-29 [1] CRAN (R 4.5.0)
#>  callr               3.7.6      2024-03-25 [1] CRAN (R 4.5.0)
#>  car               * 3.1-3      2024-09-27 [1] CRAN (R 4.5.0)
#>  carData           * 3.0-5      2022-01-06 [1] CRAN (R 4.5.0)
#>  caTools             1.18.3     2024-09-04 [1] CRAN (R 4.5.0)
#>  checkmate         * 2.3.3      2025-08-18 [1] CRAN (R 4.5.0)
#>  class               7.3-23     2025-01-01 [1] CRAN (R 4.5.0)
#>  cli                 3.6.5      2025-04-23 [1] CRAN (R 4.5.0)
#>  clipr               0.8.0      2022-02-22 [1] CRAN (R 4.5.0)
#>  cluster             2.1.8.1    2025-03-12 [1] CRAN (R 4.5.0)
#>  coda              * 0.19-4.1   2024-01-31 [1] CRAN (R 4.5.0)
#>  codetools           0.2-20     2024-03-31 [1] CRAN (R 4.5.0)
#>  colorspace        * 2.1-2      2025-09-22 [1] CRAN (R 4.5.0)
#>  concurve          * 3.0.0      2026-01-30 [1] local
#>  cowplot           * 1.2.0      2025-07-07 [1] CRAN (R 4.5.0)
#>  crayon              1.5.3      2024-06-20 [1] CRAN (R 4.5.0)
#>  curl                7.0.0      2025-08-19 [1] CRAN (R 4.5.0)
#>  data.table          1.18.2.1   2026-01-27 [1] CRAN (R 4.5.2)
#>  DBI                 1.2.3      2024-06-02 [1] CRAN (R 4.5.0)
#>  DEoptimR            1.1-4      2025-07-27 [1] CRAN (R 4.5.0)
#>  desc                1.4.3      2023-12-10 [1] CRAN (R 4.5.0)
#>  details             0.4.0      2025-02-09 [1] CRAN (R 4.5.0)
#>  dichromat           2.0-0.1    2022-05-02 [1] CRAN (R 4.5.0)
#>  digest              0.6.39     2025-11-19 [1] CRAN (R 4.5.2)
#>  distributional      0.6.0      2026-01-14 [1] CRAN (R 4.5.2)
#>  doParallel        * 1.0.17     2022-02-07 [1] CRAN (R 4.5.0)
#>  doRNG               1.8.6.2    2025-04-02 [1] CRAN (R 4.5.0)
#>  dplyr             * 1.1.4      2023-11-17 [1] CRAN (R 4.5.0)
#>  e1071               1.7-17     2025-12-18 [1] CRAN (R 4.5.2)
#>  emmeans             2.0.1      2025-12-16 [1] CRAN (R 4.5.2)
#>  estimability        1.5.1      2024-05-12 [1] CRAN (R 4.5.0)
#>  evaluate            1.0.5      2025-08-27 [1] CRAN (R 4.5.0)
#>  extremevalues       2.4.1      2024-12-17 [1] CRAN (R 4.5.0)
#>  farver              2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
#>  fastmap             1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
#>  flextable           0.9.10     2025-08-24 [1] CRAN (R 4.5.0)
#>  fontBitstreamVera   0.1.1      2017-02-01 [1] CRAN (R 4.5.0)
#>  fontLiberation      0.1.0      2016-10-15 [1] CRAN (R 4.5.0)
#>  fontquiver          0.2.1      2017-02-01 [1] CRAN (R 4.5.0)
#>  forcats           * 1.0.1      2025-09-25 [1] CRAN (R 4.5.0)
#>  foreach           * 1.5.2      2022-02-02 [1] CRAN (R 4.5.0)
#>  foreign             0.8-90     2025-03-31 [1] CRAN (R 4.5.0)
#>  Formula             1.2-5      2023-02-24 [1] CRAN (R 4.5.0)
#>  fs                  1.6.6      2025-04-12 [1] CRAN (R 4.5.0)
#>  furrr               0.3.1      2022-08-15 [1] CRAN (R 4.5.0)
#>  future            * 1.69.0     2026-01-16 [1] CRAN (R 4.5.2)
#>  future.apply      * 1.20.1     2025-12-09 [1] CRAN (R 4.5.2)
#>  gamlss            * 5.5-0      2025-08-19 [1] CRAN (R 4.5.0)
#>  gamlss.data       * 6.0-7      2025-09-04 [1] CRAN (R 4.5.0)
#>  gamlss.dist       * 6.1-1      2023-08-23 [1] CRAN (R 4.5.0)
#>  gdtools             0.4.4      2025-10-06 [1] CRAN (R 4.5.0)
#>  generics            0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
#>  ggcorrplot        * 0.1.4.1    2023-09-05 [1] CRAN (R 4.5.0)
#>  ggdist              3.3.3      2025-04-23 [1] CRAN (R 4.5.0)
#>  ggplot2           * 4.0.1      2025-11-14 [1] CRAN (R 4.5.2)
#>  ggpubr              0.6.2      2025-10-17 [1] CRAN (R 4.5.0)
#>  ggsignif            0.6.4      2022-10-13 [1] CRAN (R 4.5.0)
#>  ggtext            * 0.1.2      2022-09-16 [1] CRAN (R 4.5.0)
#>  glmnet              4.1-10     2025-07-17 [1] CRAN (R 4.5.0)
#>  globals             0.18.0     2025-05-08 [1] CRAN (R 4.5.0)
#>  glue                1.8.0      2024-09-30 [1] CRAN (R 4.5.0)
#>  gridExtra           2.3        2017-09-09 [1] CRAN (R 4.5.0)
#>  gridtext            0.1.5      2022-09-16 [1] CRAN (R 4.5.0)
#>  gtable              0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
#>  here              * 1.0.2      2025-09-15 [1] CRAN (R 4.5.0)
#>  Hmisc             * 5.2-5      2026-01-09 [1] CRAN (R 4.5.2)
#>  hms                 1.1.4      2025-10-17 [1] CRAN (R 4.5.0)
#>  htmlTable           2.4.3      2024-07-21 [1] CRAN (R 4.5.0)
#>  htmltools         * 0.5.9      2025-12-04 [1] CRAN (R 4.5.2)
#>  htmlwidgets         1.6.4      2023-12-06 [1] CRAN (R 4.5.0)
#>  httr                1.4.7      2023-08-15 [1] CRAN (R 4.5.0)
#>  ImputeRobust      * 1.3-1      2018-11-30 [1] CRAN (R 4.5.0)
#>  inline              0.3.21     2025-01-09 [1] CRAN (R 4.5.0)
#>  insight             1.4.5      2026-01-26 [1] CRAN (R 4.5.2)
#>  iterators         * 1.0.14     2022-02-05 [1] CRAN (R 4.5.0)
#>  itertools           0.1-3      2014-03-12 [1] CRAN (R 4.5.0)
#>  jomo                2.7-6      2023-04-15 [1] CRAN (R 4.5.0)
#>  jsonlite            2.0.0      2025-03-27 [1] CRAN (R 4.5.0)
#>  JuliaCall         * 0.17.6     2024-12-07 [1] CRAN (R 4.5.0)
#>  kableExtra        * 1.4.0      2024-01-24 [1] CRAN (R 4.5.0)
#>  km.ci               0.5-6      2022-04-06 [1] CRAN (R 4.5.0)
#>  KMsurv              0.1-6      2025-05-20 [1] CRAN (R 4.5.0)
#>  knitr             * 1.51       2025-12-20 [1] CRAN (R 4.5.2)
#>  labeling            0.4.3      2023-08-29 [1] CRAN (R 4.5.0)
#>  laeken              0.5.3      2024-01-25 [1] CRAN (R 4.5.0)
#>  latex2exp         * 0.9.8      2026-01-09 [1] CRAN (R 4.5.2)
#>  lattice           * 0.22-7     2025-04-02 [1] CRAN (R 4.5.0)
#>  lgr                 0.5.0      2025-07-23 [1] CRAN (R 4.5.0)
#>  lifecycle           1.0.5      2026-01-08 [1] CRAN (R 4.5.2)
#>  listenv             0.10.0     2025-11-02 [1] CRAN (R 4.5.0)
#>  lme4                1.1-38     2025-12-02 [1] CRAN (R 4.5.2)
#>  lmtest              0.9-40     2022-03-21 [1] CRAN (R 4.5.0)
#>  loo               * 2.9.0      2025-12-23 [1] CRAN (R 4.5.2)
#>  lubridate         * 1.9.4      2024-12-08 [1] CRAN (R 4.5.0)
#>  magick              2.9.0      2025-09-08 [1] CRAN (R 4.5.0)
#>  magrittr          * 2.0.4      2025-09-12 [1] CRAN (R 4.5.0)
#>  marginaleffects   * 0.31.0     2025-11-15 [1] CRAN (R 4.5.2)
#>  MASS              * 7.3-65     2025-02-28 [1] CRAN (R 4.5.0)
#>  mathjaxr            2.0-0      2025-12-01 [1] CRAN (R 4.5.2)
#>  Matrix            * 1.7-4      2025-08-28 [1] CRAN (R 4.5.0)
#>  MatrixModels        0.5-4      2025-03-26 [1] CRAN (R 4.5.0)
#>  matrixStats         1.5.0      2025-01-07 [1] CRAN (R 4.5.0)
#>  mcmc                0.9-8      2023-11-16 [1] CRAN (R 4.5.0)
#>  MCMCpack          * 1.7-1      2024-08-27 [1] CRAN (R 4.5.0)
#>  metadat             1.4-0      2025-02-04 [1] CRAN (R 4.5.0)
#>  metafor             4.8-0      2025-01-28 [1] CRAN (R 4.5.0)
#>  mgcv              * 1.9-4      2025-11-07 [1] CRAN (R 4.5.0)
#>  mi                * 1.2        2025-09-02 [1] CRAN (R 4.5.0)
#>  mice              * 3.19.0     2025-12-10 [1] CRAN (R 4.5.2)
#>  miceadds          * 3.18-36    2025-09-12 [1] CRAN (R 4.5.0)
#>  miceFast          * 0.8.5      2025-02-03 [1] CRAN (R 4.5.0)
#>  minqa               1.2.8      2024-08-17 [1] CRAN (R 4.5.0)
#>  missForest        * 1.6.1      2025-10-26 [1] CRAN (R 4.5.0)
#>  mitml             * 0.4-5      2023-03-08 [1] CRAN (R 4.5.0)
#>  mitools             2.4        2019-04-26 [1] CRAN (R 4.5.0)
#>  mlr3                1.3.0      2025-12-03 [1] CRAN (R 4.5.2)
#>  mlr3learners        0.14.0     2025-12-13 [1] CRAN (R 4.5.2)
#>  mlr3misc            0.19.0     2025-09-12 [1] CRAN (R 4.5.0)
#>  mlr3pipelines       0.10.0     2025-11-07 [1] CRAN (R 4.5.0)
#>  mlr3tuning          1.5.1      2025-12-14 [1] CRAN (R 4.5.2)
#>  multcomp            1.4-29     2025-10-20 [1] CRAN (R 4.5.0)
#>  mvtnorm           * 1.3-3      2025-01-10 [1] CRAN (R 4.5.0)
#>  nlme              * 3.1-168    2025-03-31 [1] CRAN (R 4.5.0)
#>  nloptr              2.2.1      2025-03-17 [1] CRAN (R 4.5.0)
#>  nnet                7.3-20     2025-01-01 [1] CRAN (R 4.5.0)
#>  numDeriv            2016.8-1.1 2019-06-06 [1] CRAN (R 4.5.0)
#>  officer             0.7.3      2026-01-16 [1] CRAN (R 4.5.2)
#>  opdisDownsampling   1.0.1      2024-04-15 [1] CRAN (R 4.5.0)
#>  openssl             2.3.4      2025-09-30 [1] CRAN (R 4.5.0)
#>  otel                0.2.0      2025-08-29 [1] CRAN (R 4.5.0)
#>  palmerpenguins      0.1.1      2022-08-15 [1] CRAN (R 4.5.0)
#>  pan                 1.9        2023-12-07 [1] CRAN (R 4.5.0)
#>  pander              0.6.6      2025-03-01 [1] CRAN (R 4.5.0)
#>  paradox             1.0.1      2024-07-09 [1] CRAN (R 4.5.0)
#>  parallelly        * 1.46.1     2026-01-08 [1] CRAN (R 4.5.2)
#>  patchwork         * 1.3.2      2025-08-25 [1] CRAN (R 4.5.0)
#>  pbmcapply         * 1.5.1      2022-04-28 [1] CRAN (R 4.5.0)
#>  performance       * 0.15.3.6   2026-01-29 [1] https://easystats.r-universe.dev (R 4.5.2)
#>  pillar              1.11.1     2025-09-17 [1] CRAN (R 4.5.0)
#>  pkgbuild            1.4.8.9000 2026-01-26 [1] Github (r-lib/pkgbuild@35af314)
#>  pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
#>  plyr                1.8.9      2023-10-02 [1] CRAN (R 4.5.0)
#>  png                 0.1-8      2022-11-29 [1] CRAN (R 4.5.0)
#>  polspline           1.1.25     2024-05-10 [1] CRAN (R 4.5.0)
#>  posterior         * 1.6.1      2025-02-27 [1] CRAN (R 4.5.0)
#>  pracma              2.4.6      2025-10-22 [1] CRAN (R 4.5.0)
#>  prettyunits         1.2.0      2023-09-24 [1] CRAN (R 4.5.0)
#>  processx            3.8.6      2025-02-21 [1] CRAN (R 4.5.0)
#>  ProfileLikelihood * 1.3        2023-08-25 [1] CRAN (R 4.5.0)
#>  progress          * 1.2.3      2023-12-06 [1] CRAN (R 4.5.0)
#>  proxy               0.4-29     2025-12-29 [1] CRAN (R 4.5.2)
#>  ps                  1.9.1      2025-04-12 [1] CRAN (R 4.5.0)
#>  purrr             * 1.2.1      2026-01-09 [1] CRAN (R 4.5.2)
#>  qqconf              1.3.2      2023-04-14 [1] CRAN (R 4.5.0)
#>  qqplotr           * 0.0.7      2025-09-05 [1] CRAN (R 4.5.0)
#>  quantreg          * 6.1        2025-03-10 [1] CRAN (R 4.5.0)
#>  QuickJSR            1.9.0      2026-01-25 [1] CRAN (R 4.5.2)
#>  R6                  2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
#>  ragg                1.5.0      2025-09-02 [1] CRAN (R 4.5.0)
#>  randomForest      * 4.7-1.2    2024-09-22 [1] CRAN (R 4.5.0)
#>  ranger              0.18.0     2026-01-16 [1] CRAN (R 4.5.2)
#>  rapportools         1.2        2025-02-28 [1] CRAN (R 4.5.0)
#>  rbibutils           2.4.1      2026-01-21 [1] CRAN (R 4.5.2)
#>  rcartocolor         2.1.2      2025-07-23 [1] CRAN (R 4.5.0)
#>  RColorBrewer        1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
#>  Rcpp              * 1.1.1      2026-01-10 [1] CRAN (R 4.5.2)
#>  RcppParallel        5.1.11-1   2025-08-27 [1] CRAN (R 4.5.0)
#>  Rdpack              2.6.5      2026-01-23 [1] CRAN (R 4.5.2)
#>  readr             * 2.1.6      2025-11-14 [1] CRAN (R 4.5.2)
#>  reformulas          0.4.3.1    2026-01-08 [1] CRAN (R 4.5.2)
#>  rematch2            2.1.2      2020-05-01 [1] CRAN (R 4.5.0)
#>  reshape2          * 1.4.5      2025-11-12 [1] CRAN (R 4.5.0)
#>  reticulate        * 1.44.1     2025-11-14 [1] CRAN (R 4.5.2)
#>  rlang               1.1.7      2026-01-09 [1] CRAN (R 4.5.2)
#>  rmarkdown         * 2.30       2025-09-28 [1] CRAN (R 4.5.0)
#>  rms               * 8.1-0      2025-10-14 [1] CRAN (R 4.5.0)
#>  rngtools            1.5.2      2021-09-20 [1] CRAN (R 4.5.0)
#>  robustbase          0.99-6     2025-09-04 [1] CRAN (R 4.5.0)
#>  rpart               4.1.24     2025-01-07 [1] CRAN (R 4.5.0)
#>  rprojroot           2.1.1      2025-08-26 [1] CRAN (R 4.5.0)
#>  rstan             * 2.32.7     2025-03-10 [1] CRAN (R 4.5.0)
#>  rstantools          2.6.0      2026-01-10 [1] CRAN (R 4.5.2)
#>  rstatix             0.7.3      2025-10-18 [1] CRAN (R 4.5.0)
#>  rstudioapi          0.18.0     2026-01-16 [1] CRAN (R 4.5.2)
#>  S7                  0.2.1      2025-11-14 [1] CRAN (R 4.5.2)
#>  sandwich            3.1-1      2024-09-15 [1] CRAN (R 4.5.0)
#>  scales              1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
#>  sessioninfo         1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
#>  shape               1.4.6.1    2024-02-23 [1] CRAN (R 4.5.0)
#>  showtext          * 0.9-7      2024-03-02 [1] CRAN (R 4.5.0)
#>  showtextdb        * 3.0        2020-06-04 [1] CRAN (R 4.5.0)
#>  sp                  2.2-0      2025-02-01 [1] CRAN (R 4.5.0)
#>  SparseM           * 1.84-2     2024-07-17 [1] CRAN (R 4.5.0)
#>  StanHeaders       * 2.32.10    2024-07-15 [1] CRAN (R 4.5.0)
#>  Statamarkdown     * 0.9.6      2026-01-06 [1] Github (Hemken/Statamarkdown@dc936d8)
#>  stringi             1.8.7      2025-03-27 [1] CRAN (R 4.5.0)
#>  stringr           * 1.6.0      2025-11-04 [1] CRAN (R 4.5.0)
#>  summarytools      * 1.1.5      2026-01-27 [1] CRAN (R 4.5.2)
#>  survival            3.8-6      2026-01-16 [1] CRAN (R 4.5.2)
#>  survminer           0.5.1      2025-09-02 [1] CRAN (R 4.5.0)
#>  survMisc            0.5.6      2022-04-07 [1] CRAN (R 4.5.0)
#>  svglite           * 2.2.2      2025-10-21 [1] CRAN (R 4.5.0)
#>  svgPanZoom          0.3.4      2020-02-15 [1] CRAN (R 4.5.0)
#>  svUnit              1.0.8      2025-08-26 [1] CRAN (R 4.5.0)
#>  sysfonts          * 0.8.9      2024-03-02 [1] CRAN (R 4.5.0)
#>  systemfonts         1.3.1      2025-10-01 [1] CRAN (R 4.5.0)
#>  tensorA             0.36.2.1   2023-12-13 [1] CRAN (R 4.5.0)
#>  texPreview        * 2.1.0      2024-01-24 [1] CRAN (R 4.5.0)
#>  textshaping         1.0.4      2025-10-10 [1] CRAN (R 4.5.0)
#>  TH.data             1.1-5      2025-11-17 [1] CRAN (R 4.5.2)
#>  tibble            * 3.3.1      2026-01-11 [1] CRAN (R 4.5.2)
#>  tidybayes         * 3.0.7      2024-09-15 [1] CRAN (R 4.5.0)
#>  tidyr             * 1.3.2      2025-12-19 [1] CRAN (R 4.5.2)
#>  tidyselect          1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
#>  tidyverse         * 2.0.0      2023-02-22 [1] CRAN (R 4.5.0)
#>  timechange          0.3.0      2024-01-18 [1] CRAN (R 4.5.0)
#>  tinytex           * 0.58       2025-11-19 [1] CRAN (R 4.5.2)
#>  twosamples          2.0.1      2023-06-23 [1] CRAN (R 4.5.0)
#>  tzdb                0.5.0      2025-03-15 [1] CRAN (R 4.5.0)
#>  uuid                1.2-2      2026-01-23 [1] CRAN (R 4.5.2)
#>  V8                  8.0.1      2025-10-10 [1] CRAN (R 4.5.0)
#>  vcd                 1.4-13     2024-09-16 [1] CRAN (R 4.5.0)
#>  vctrs               0.7.1      2026-01-23 [1] CRAN (R 4.5.2)
#>  VIM               * 7.0.0      2026-01-10 [1] CRAN (R 4.5.2)
#>  viridisLite         0.4.2      2023-05-02 [1] CRAN (R 4.5.0)
#>  wesanderson       * 0.3.7      2023-10-31 [1] CRAN (R 4.5.0)
#>  whisker             0.4.1      2022-12-05 [1] CRAN (R 4.5.0)
#>  withr               3.0.2      2024-10-28 [1] CRAN (R 4.5.0)
#>  xfun              * 0.56       2026-01-18 [1] CRAN (R 4.5.2)
#>  xml2                1.5.2      2026-01-17 [1] CRAN (R 4.5.2)
#>  xtable              1.8-4      2019-04-21 [1] CRAN (R 4.5.0)
#>  yaml                2.3.12     2025-12-10 [1] CRAN (R 4.5.2)
#>  yardstick         * 1.3.2      2025-01-22 [1] CRAN (R 4.5.0)
#>  zip                 2.3.3      2025-05-13 [1] CRAN (R 4.5.0)
#>  zoo                 1.8-15     2025-12-15 [1] CRAN (R 4.5.2)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
#>  * ── Packages attached to the search path.
#> 
#> ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

References


Citation

BibTeX citation:
@online{panda2018,
  author = {Panda, Sir and Panda, Sir},
  title = {GAMS},
  date = {2018-11-11},
  url = {https://lesslikely.com/posts/statistics/gams.html},
  langid = {en}
}
For attribution, please cite this work as:
1. Panda S, Panda S. (2018). ‘GAMS’. https://lesslikely.com/posts/statistics/gams.html.