Rev 7872 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{gam.selection}\alias{gam.selection}%- Also NEED an `\alias' for EACH other topic documented here.\title{Generalized Additive Model Selection}\description{ This page is intended to provide some more information onhow to select GAMs. In particular, it gives a brief overview of smoothnessselection, and then discusses how this can be extended to select inclusion/exclusionof terms. Hypothesis testing approaches to the latter problem are also discussed.}\section{Smoothness selection criteria}{Given a model structure specified by a gam model formula,\code{gam()} attempts to find the appropriate smoothness for each applicable modelterm using prediction error criteria or likelihood based methods. The prediction errorcriteria used are Generalized (Approximate) Cross Validation (GCV or GACV) when the scaleparameter is unknown or an Un-Biased Risk Estimator (UBRE) when it is known. UBRE is essentiallyscaled AIC (Generalized case) or Mallows' Cp (additive model case).GCV and UBRE are covered in Craven and Wahba (1979) and Wahba (1990).Alternatively REML of maximum likelihood (ML) may be used for smoothnessselection, by viewing the smooth components as random effects (in this case the variance component for eachsmooth random effect will be given by the scale parameter divided by the smoothing parameter --- forsmooths with multiple penalties, there will be multiple variance components).The \code{method} argument to \code{\link{gam}} selects the smoothness selection criterion.Automatic smoothness selection is unlikely to be successful with few data, particularly withmultiple terms to be selected. In addition GCV and UBRE/AIC score can occasionallydisplay local minima that can trap the minimisation algorithms. GCV/UBRE/AICscores become constant with changing smoothing parameters at very low or veryhigh smoothing parameters, and on occasion these `flat' regions can beseparated from regions of lower score by a small `lip'. This seems to be themost common form of local minimum, but is usually avoidable by avoidingextreme smoothing parameters as starting values in optimization, and byavoiding big jumps in smoothing parameters while optimizing. Never the less, if you aresuspicious of smoothing parameter estimates, try changing fit method (see\code{\link{gam}} arguments \code{method} and \code{optimizer}) and see if the estimates change, or try changingsome or all of the smoothing parameters `manually' (argument \code{sp} of \code{\link{gam}},or \code{sp} arguments to \code{\link{s}} or \code{\link{te}}).REML and ML are less prone to local minima than the other criteria, and may therefore be preferable.}\section{Automatic term selection}{Unmodified smoothness selection by GCV, AIC, REML etc. will not usually removea smooth from a model. This is because most smoothing penalties view some spaceof (non-zero) functions as `completely smooth' and once a term is penalized heavilyenough that it is in this space, further penalization does not change it.However it is straightforward to modify smooths so that under heavy penalization theyare penalized to the zero function and thereby `selected out' of the model. There aretwo approaches.The first approach is to modify the smoothing penalty with an additional shrinkage term.Smooth classes\code{cs.smooth} and \code{tprs.smooth} (specified by \code{"cs"} and\code{"ts"} respectively) have smoothness penalties which include a smallshrinkage component, so that for large enough smoothing parameters the smoothbecomes identically zero. This allows automatic smoothing parameter selectionmethods to effectively remove the term from the model altogether. Theshrinkage component of the penalty is set at a level that usually makes negligablecontribution to the penalization of the model, only becoming effective whenthe term is effectively `completely smooth' according to the conventional penalty.The second approach leaves the original smoothing penalty unchanged, but constructs anadditional penalty for each smooth, which penalizes only functions in the null space of theoriginal penalty (the `completely smooth' functions). Hence, if all the smoothing parametersfor a term tend to infinity, the term will be selected out of the model. This latter approachis more expensive computationally, but has the advantage that it can be applied automaticallyto any smooth term. The \code{select} argument to \code{\link{gam}} turns on this method.In fact, as implemented, both approaches operate by eigen-decomposiong the original penalty matrix.A new penalty is created on the null space: it is the matrix with the same eigenvectors as theoriginal penalty, but with the originally postive egienvalues set to zero, and the originallyzero eigenvalues set to something positive. The first approach just addes a multiple of thispenalty to the original penalty, where the multiple is chosen so that the new penalty can notdominate the original. The second approach treats the new penalty as an extra penalty, with itsown smoothing parameter.Of course, as with all model selection methods, some care must be take to ensure that theautomatic selection is sensible, and a decision about the effective degrees of freedom atwhich to declare a term `negligible' has to be made.}\section{Interactive term selection}{In general the most logically consistent method to use for deciding whichterms to include in the model is to compare GCV/UBRE/ML scores for models withand without the term (REML scores should not be used to compare models withdifferent fixed effects structures). When UBRE is the smoothness selection method this willgive the same result as comparing by \code{\link{AIC}} (the AIC in this caseuses the model EDF in place of the usual model DF). Similarly, comparison viaGCV score and via AIC seldom yields different answers. Note that the negativebinomial with estimated \code{theta} parameter is a special case: the GCVscore is not informative, because of the \code{theta} estimationscheme used. More generally the score for the model with a smoothterm can be compared to the score for the model withthe smooth term replaced by appropriate parametric terms. Candidates forreplacement by parametric terms are smooth terms with estimateddegrees of freedom close to their minimum possible.Candidates for removal can also be identified by reference to theapproximate p-values provided by \code{summary.gam}, and by looking at theextent to which the confidence band for an estimated term includes the zerofunction. It is perfectly possible to perform backwards selection using p-valuesin the usual way: that is by sequentially dropping the single term with the highestnon-significant p-value from the model and re-fitting, until all terms aresignificant. This suffers from the same problems as stepwise procedures for anyGLM/LM, with the additional caveat that the p-values are only approximate. If adoptingthis approach, it is probably best to use ML smoothness selection.Note that GCV and UBRE are not appropriate for comparing models using different families:in that case AIC should be used.}\section{Caveats/platitudes}{Formal model selection methods are only appropriate for selecting between reasonable models.If formal model selection is attempted starting from a model that simply doesn't fit the data,then it is unlikely to provide meaningful results.The more thought is given to appropriate model structure up front, the more successful modelselection is likely to be. Simply starting with a hugely flexible model with `everything in'and hoping that automatic selection will find the right structure is not often successful.}\author{ Simon N. Wood \email{simon.wood@r-project.org}}\references{Marra, G. and S.N. Wood (2011) Practical variable selection for generalized additive models.Computational Statistics and Data Analysis 55,2372-2387.Craven and Wahba (1979) Smoothing Noisy Data with Spline Functions. Numer. Math. 31:377-403Venables and Ripley (1999) Modern Applied Statistics with S-PLUSWahba (1990) Spline Models of Observational Data. SIAM.Wood, S.N. (2003) Thin plate regression splines. J.R.Statist.Soc.B 65(1):95-114Wood, S.N. (2008) Fast stable direct fitting and smoothness selection forgeneralized additive models. J.R.Statist. Soc. B 70(3):495-518Wood, S.N. (2011) Fast stable restricted maximum likelihoodand marginal likelihood estimation of semiparametric generalized linearmodels. Journal of the Royal Statistical Society (B) 73(1):3-36}\seealso{\code{\link{gam}}, \code{\link{step.gam}}}\examples{## an example of automatic model selection via null space penalizationlibrary(mgcv)set.seed(3);n<-200dat <- gamSim(1,n=n,scale=.15,dist="poisson") ## simulate datadat$x4 <- runif(n, 0, 1);dat$x5 <- runif(n, 0, 1) ## spuriousb<-gam(y~s(x0)+s(x1)+s(x2)+s(x3)+s(x4)+s(x5),data=dat,family=poisson,select=TRUE,method="REML")summary(b)plot(b,pages=1)}\keyword{models} \keyword{regression}%-- one or more ..