This was code originally written by Nick Golding, in August 2022.
It was initially written to demonstrate using symmetrical terms and the benefit of them in conmat.
They handily demonstrate a nice plot of the different terms in a gam - effectively giving us a "contact matrix" of the effect of each term. The part where that happens is where predict
is used inside mutate.
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.