Graceful 'ggplot'-Based Graphics and Other Functions for GAMs Fitted Using 'mgcv'
Overview
Graceful 'ggplot'-based graphics and utility functions for working with generalized additive models (GAMs) fitted using the 'mgcv' package. Provides a reimplementation of the plot() method for GAMs that 'mgcv' provides, as well as 'tidyverse' compatible representations of estimated smooths.
User visible changes
- *gratia* now only handles shape constrained models fitted using *scam* version 1.2-21 or later. This is due to breaking changes in *scam*, and new functionality in that package, which simplifies *gratia*.
- *gratia* also now depends on *dplyr* version 1.2.0 or later.
- Histogram bars drawn by
residuals_hist_plot()and points inqq_plot(),residuals_linpred_plot(),observed_fitted_plot(), andworm_plot(), and henceappraise(), are now filled with a dark shade of grey and use a light colour for the border of the bars.
New features
derivatives()now works for constrained factor smooths (bs = "sz"), treating them in the same way as random factor smooths (bs = "fs"). Lack of support reported by @vrest-png #362 Also handles higher orderbs = "sz"terms.
Show all changes in 0.11.2Hide the rest of the changes in 0.11.2
draw.derivatives()can now differentiate random and constrained factor smooths through the colour aesthetic via new argumentdifferentiate_factor_smooths.model_terms()returns the names of all terms in a model. #388
Bug fixes
conditional_values()would fail if supplied a numeric vector of data to condition on via theconditionargument. #366- *gratia* worked inconsistently with tensor product smooths containing a random effect
bs = "re"marginal. Reported #358 and fixed by @asgersvenning #360, with additional changes by Gavin Simpson. - Argument
mvn_methodwas not being passed on to the lower workhorse functions that did the sampling. #381 response_derivatives()would fail if there were no other terms in the model but the focal term.
From NEWS.md in the release
Install
Health
NOTERd contentsr-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc
Rd files without \usage: ‘fixef.Rd’ \arguments should not be documented without \usage.
- NOTE11 OK, 2 NOTENow
- NOTE12 OK, 1 NOTE2026-07-11
- OK14 OK2026-03-10
Documentation
The repository also keeps web-only articles.
- Help pages
- 146 (11 internal)includes a package overview page
- Examples that run
- 100%64 run in a plain check
- Exported functions with examples
- 46%
- Documented parameters
- 97%
- Return-value docs
- 47%
- Help pages citing references
- 5%
Downloads
Repository
- PRs merged (all time)
- 73%
- Median days to close, 50 most recently updated closed issues
- 935
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
16 development-tooling and community-health practices detected across 9 families in the upstream repository
Checks run against github.com/gavinsimpson/gratia on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
Funding links: GitHub Sponsors, Buy Me a Coffee
The repository owner accepts GitHub Sponsors
GitHub Pages site last deployed 2026-10-11 · The repository has a site deploy workflow
pkgdown site last built 2026-10-11
Show all practicesHide 5 practices
Dependencies
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 0.11.2Latest
- 0.11.12025-08-25 · diff ↗
- 0.11.02025-08-18 · diff ↗ ·
added 6 exports
assemble, is_mgcv_family, is_multivariate_y, quantile_residuals, rtw, scale_fill_partial_effect - RR 4.5.0 released · 2025-04-11
- 0.10.0
- 0.9.22024-06-25 · diff ↗
- RR 4.4.0 released · 2024-04-24
- 0.9.02024-03-27 · diff ↗ ·
added 20 exports
add_fitted_samples, add_posterior_samples, add_predicted_samples, add_sizer, add_smooth_samples, basis_size, boundary, derivative_samples, gaussian_draws, generate_draws, mh_draws, model_constant, null_deviance, post_draws, response_derivatives, smooth_label, smooth_terms, spline_values, spline_values2, user_draws - 0.8.22024-01-09 · diff ↗
- RR 4.3.0 released · 2023-04-21
- 0.8.12023-02-02 · diff ↗ ·
removed 1 export
seq_min_maxadded 12 exports
check_is_mgcv_smooth, evenly, level, lp_matrix, model_vars, overview, partial_derivatives, ref_level, smooth_coef_indices, smooth_type, stop_if_not_mgcv_smooth, tidy_basis - 0.7.32022-05-09 · diff ↗
- RR 4.2.0 released · 2022-04-22
- 0.7.22022-03-17 · diff ↗ ·
added 8 exports
concrvity, gw_f0, gw_f1, gw_f2, gw_f3, model_concurvity, smooth_data, transform_fun - 0.7.02022-02-07 · diff ↗ ·
added 20 exports
add_constant, data_combos, factor_combos, family_name, family_type, fitted_values, fixed_effects, fixef, has_theta, model_edf, nb_theta, parametric_effects, rootogram, term_names, term_variables, theta, to_na, too_far, too_far_to_na, typical_values
Show 14 earlier eventsHide 14 earlier events
- RR 4.1.0 released · 2021-05-18
- 0.6.02021-04-18 · diff ↗ ·
added 6 exports
add_confint, compare_smooths, edf, extract_link, variance_comp, worm_plot - 0.5.1
- 0.5.02021-01-11 · diff ↗ ·
removed 1 export
data_classadded 4 exports
add_partial_residuals, eval_smooth, partial_residuals, smooth_estimates - 0.4.12020-05-31 · diff ↗ ·
removed 1 export
datagenadded 6 exports
add_fitted, add_residuals, data_sim, difference_smooths, is_factor_term, vars_from_label - RR 4.0.0 released · 2020-04-24
- 0.3.1
- unarchivedReturned to CRAN2020-01-19
- 0.3.02020-01-19 · diff ↗ ·
added 7 exports
basis, fitted_samples, load_mgcv, posterior_samples, predicted_samples, smooth_coefs, smooth_samples - archivedRemoved from CRAN2020-01-16check issues were not corrected in time 'Additional issues'
- RR 3.6.0 released · 2019-04-26
- 0.2-82019-03-13 · diff ↗
- 0.2-12019-02-01
- RR 3.5.0 released · 2018-04-23
Package metadata
- First published
- 2019-02-01
- Total releases
- 19 / 7 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 134 KB / 5 files
- Download size
- 4.1 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("gratia")The package provides a citation file that builds its entry when R runs it. Run citation() to see it.
The repository also keeps a CITATION.cff.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.