Generalized additive models (GAMs, Hastie & Tibshirani, 1990; Wood, 2017) are an extension of the generalized linear model that allows the effects of covariates to be modelled as smooth functions. GAMs are increasingly used in many areas of science (e.g. Pedersen, Miller, Simpson, & Ross, 2019; Simpson, 2018) because the smooth functions allow nonlinear relationships between covariates and the response to be learned from the data through the use of penalized splines. Within the R (R Core Team, 2024) ecosystem, Simon Wood's mgcv package (Wood, 2017) is widely used to fit GAMs and is a Recommended package that ships with R as part of the default install. A growing number of other R packages build upon mgcv, for example as an engine to fit specialised models not handled by mgcv itself (e.g. GJMR, Marra & Radice, 2023), or to make use of the wide range of splines available in mgcv (e.g. brms, B\"urkner, 2017). The gratia package builds upon mgcv by providing functions that make working with GAMs easier. gratia takes a tidy approach (Wickham, 2014) providing ggplot2 (Wickham, 2016) replacements for mgcv's base graphics-based plots, functions for model diagnostics and exploration of fitted models, and a family of functions for drawing samples from the posterior distribution of a fitted GAM. Additional functionality is provided to facilitate the teaching and understanding of GAMs.
翻译:广义可加模型(GAMs,Hastie & Tibshirani, 1990; Wood, 2017)是广义线性模型的扩展,允许将协变量的效应建模为平滑函数。GAMs在科学领域的应用日益广泛(例如 Pedersen, Miller, Simpson, & Ross, 2019; Simpson, 2018),因为通过使用惩罚样条,平滑函数允许从数据中学习协变量与响应之间的非线性关系。在R(R Core Team, 2024)生态系统中,Simon Wood的mgcv包(Wood, 2017)被广泛用于拟合GAMs,它是一个推荐包,随R默认安装一同发布。越来越多的其他R包建立在mgcv之上,例如作为拟合mgcv本身未处理的专用模型的引擎(例如GJMR, Marra & Radice, 2023),或利用mgcv中提供的广泛样条类型(例如brms, B\"urkner, 2017)。gratia包建立在mgcv之上,提供了一系列使GAMs更易于使用的函数。gratia采用整洁化(tidy)方法(Wickham, 2014),为mgcv基于基础图形的绘图提供了ggplot2(Wickham, 2016)替代方案,提供了用于模型诊断和探索拟合模型的函数,以及一系列从拟合GAM的后验分布中抽取样本的函数。此外,该包还提供了额外功能以促进GAMs的教学与理解。