gam
formula using s
, te
, ti
and t2
terms.
Various smooth classes are available, for different modelling tasks, and users can add smooth classes
(see user.defined.smooth
). What defines a smooth class is the basis used to represent
the smooth function and quadratic penalty (or multiple penalties) used to penalize
the basis coefficients in order to control the degree of smoothness. Smooth classes are
invoked directly by s
terms, or as building blocks for tensor product smoothing
via te
, ti
or t2
terms (only smooth classes with single penalties can be used in tensor products). The smooths
built into the mgcv
package are all based one way or another on low rank versions of splines. For the full rank
versions see Wahba (1990).Note that smooths can be used rather flexibly in gam
models. In particular the linear predictor of the GAM can
depend on (a discrete approximation to) any linear functional of a smooth term, using by
variables and the
`summation convention' explained in linear.functional.terms
.
The single penalty built in smooth classes are summarized as follows [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Broadly speaking the default penalized thin plate regression splines tend to give the best MSE performance, but they are slower to set up than the other bases. The knot based penalized cubic regression splines (with derivative based penalties) usually come next in MSE performance, with the P-splines doing just a little worse. However the P-splines are useful in non-standard situations.
All the preceding classes (and any user defined smooths with single penalties) may be used as marginal
bases for tensor product smooths specified via te
, ti
or t2
terms. Tensor
product smooths are smooth functions
of several variables where the basis is built up from tensor products of bases for smooths of fewer (usually one)
variable(s) (marginal bases). The multiple penalties for these smooths are produced automatically from the
penalties of the marginal smooths. Wood (2006b) and Wood, Scheipl and Faraway (2012), give the general recipe for these constructions. The te
construction results in fewer, more interpretable, penalties, while the t2
construction is more natural if you are interested in functional ANOVA decompositions. t2
works with the
gamm4
package.
Tensor product smooths often perform better than isotropic smooths when the covariates of a smooth are not naturally
on the same scale, so that their relative scaling is arbitrary. For example, if smoothing with repect to time and
distance, an isotropic smoother will give very different results if the units are cm and minutes compared to if the units are metres and seconds: a tensor product smooth will give the same answer in both cases (see te
for an example of this). Note that te
terms are knot based, and the thin plate splines seem to offer no advantage over cubic or P-splines as marginal bases.
Some further specialist smoothers that are not suitable for use in tensor products are also available.
[object Object],[object Object]
Wahba (1990) Spline Models of Observational Data. SIAM
Wood, S.N. (2003) Thin plate regression splines. J.R.Statist.Soc.B 65(1):95-114
Wood, S.N. (2006a) Generalized Additive Models: an introduction with R, CRC
Wood, S.N. (2006b) Low rank scale invariant tensor product smooths for generalized additive mixed models. Biometrics 62(4):1025-1036
Wood S.N., F. Scheipl and J.J. Faraway (2012) Straightforward intermediate rank tensor product smoothing in mixed models. Statistical Computing.
s
, te
, t2
tprs
,Duchon.spline
,
cubic.regression.spline
,p.spline
, mrf
, code{soap},
code{Spherical.Spline}, adaptive.smooth
, user.defined.smooth
,
code{smooth.construct.re.smooth.spec}, code{factor.smooth.interaction}## see examples for gam and gamm
Run the code above in your browser using DataLab