Skip to contents

Builds 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).

Usage

# S3 method for class 'gam'
symbolize(fit, symbols = NULL, units = NULL, context = NULL, ...)

# S3 method for class 'bam'
symbolize(fit, symbols = NULL, units = NULL, context = NULL, ...)

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.

Value

A symbolized_model object.

Details

For mgcv::gamm() or gamm4::gamm4(), both return a list with a $gam component of class "gam". Pass that component to symbolize():

g <- mgcv::gamm(y ~ s(x), random = list(g = ~1), data = d)
sym <- symbolize(g$gam)

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.