- mgcv is an R package for estimating penalized Generalized Linear
models including Generalized Additive Models and Generalized Additive
- mgcv includes an implementation of 'gam', based on penalized
regression splines with automatic smoothness estimation.
- mgcv implements tensor product smooths, reduced rank thin plate
splines, P-splines and adaptive smoothers. It also allows users to add
smoother classes, and to add quadratic penalties on parametric model
- Smoothness selection in 'gam' is by GCV, AIC/Mallows' Cp, GACV, REML
- Interval estimation in mgcv is based on a Bayesian smoothing model.
This has the side effect of allowing simulation from the posterior
distribution of the model coefficients, in order to obtain ccredible
intervals for any quantity predicted by the model.
- mgcv also provides a routine 'gamm' for generalized additive mixed
model estimation by PQL and 'bam' for estiamtion of GAMs for very large
- The linear preditor of a model in `mgcv' can depend on any bounded
linear functional of a smooth, via a summation convention used in model
specification. This allows, e.g. scalar-on-function regression to be
- mgcv should be obtained from the CRAN mgcv page.
It is usually worth having the latest version.
- Each mgcv release has to run a lengthy set of test examples correctly
before release (not just the make checks for CRAN), but please report
anything that is broken.
- Do check the mgcv Changlog
to find out what's new in a release.
- If you find mgcv useful, and use it for published science, then
please cite the most relevant papers listed in mgcv
citation file. This helps
me justify wasting all that time on writing and maintaining software (the
papers help slightly more than the book in this regard).
- Please let me know if you have any problems installing or using
mgcv: it's intended to work, so I'd like to know if it doesn't! My
email is: simon.wood _at_ bath.edu
- Here are the slides from a series of lectures on smooth modelling given at the the Swedish Winter Conference 2017.
- Here is material from a half day course on GAMs and mgcv from late
- Here is the course material file-by-file. First the slides:
Then the exercises/examples...
Here are slides from a longer course (Tampere, 2010).
Henric Nilsson has kindly donated code that substantially improved
and related functions and plot.gam.
Thanks to the following (incomplete list of) people for bug reports suggestions and help.
Nicole Augustin; Mark Bravington; Louise Burt; Liz Clarke; Mark Clements;
Anthony Davison;Sharon Hedley;
Kurt Hornik;Pierre Joyet; Andy Liaw; Thomas Maiwald;
Henric Nilsson; Jari Oksanen; Charles Paxton; Greg Ridgeway; Brian Ripley;
Evi Samoli; John Szumiloski;
Alain Le Tertre; Luke Tierney; Brian Williams; Jim Young.
Finally, I am particularly grateful to David Borchers and Chong Gu (anonymously!) for first suggesting
making these methods available in S and Mike Lonergan for a good deal of helpful discussion and many
about numerous aspects of the package (including the idea for and earlier code for vis.gam, and the
earlier versions of the negative binomial code.)