- mgcv is an R package for estimating penalized Generalized Linear models including Generalized Additive Models and Generalized Additive Mixed Models.
- 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 terms.
- Smoothness selection in 'gam' is by GCV, AIC/Mallows' Cp, GACV, REML or ML.
- 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 datasets.
- 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 performed.
- 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 2009: short-gam.zip
- Here is the course material file-by-file. First the slides:
- gam-theory.pdf a brief tour of GAM theory.
- smooth-toolbox.pdf an introduction to the smooths available for model building.
- check-select.pdf checking and selecting models.

Here are slides from a longer course (Tampere, 2010).

- statistical-models.pdf . Some background theory.
- linear-models.pdf . Revision of linear models.
- glm.pdf . Revision of generalized linear models.
- mixed.pdf . Mixed effects models.
- basis-penalty.pdf . Smoothers based on quadratically penalized basis expansions: the basic idea.
- smoothness.pdf . Selecting the degree of smoothness.
- gam.pdf . Generalized Additive Models.
- smooth-toolbox.pdf . Smooths from which to build a GAM.
- mgcv.pdf . How to use mgcv.
- mgcv-advanced.pdf . More stuff you can do with mgcv.

Henric Nilsson has kindly donated code that substantially improved summary.gam 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; Peter Dalgaard; 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 useful suggestions 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.)