Symbolize an mgcv gam / bam fit (additive grammar, v0.14 first slice)
Source:R/symbolize-mgcv.R
symbolize.gam.RdBuilds a symbolized_model from an
mgcv::gam() or mgcv::bam() fit. The first slice covers
gaussian / poisson / binomial / Gamma families with smooth
specifications s(x), s(x, by = factor), and te(x, z).
Arguments
- fit
A fitted statistical model object.
- symbols
Optional named character vector mapping variable names to user-supplied LaTeX symbols, e.g.
c(body_mass = "W_i", temperature = "T_i").- units
Optional named character vector mapping variable names to units, e.g.
c(body_mass = "g", temperature = "C").- context
Optional short character description of the model, e.g.
"avian body-size location-scale model".- ...
Reserved for method-specific extra arguments.
Details
For mgcv::gamm() or gamm4::gamm4(), both return a list with a
$gam component of class "gam". Pass that component to
symbolize():
Correlation structures and lme4-style random effects from gamm /
gamm4 are reflected via the $gam object's smooth and
parametric-coefficient blocks; the GAMM-specific covariance
structures are not separately rendered in v0.14.
Confidence intervals
Parametric (non-smooth) coefficients in fixed_effects carry
approximate Wald 95% CIs computed as estimate ± 1.96 * SE from
summary(fit)$p.coeff / summary(fit)$se. Smooth-term inference
is summarised separately in sym$metadata$smooths (basis
dimension, edf, p-value per smooth) rather than a single
coefficient row.
References
Wood, S. N. (2017). Generalized Additive Models: An Introduction with R (2nd ed.). Chapman and Hall/CRC.
Wood, S. N. (2011). Fast stable restricted maximum likelihood and marginal likelihood estimation of semiparametric generalized linear models. Journal of the Royal Statistical Society (B), 73(1), 3-36.