11
$\begingroup$

Apologies in advance I new to this forum and to GAM models.

I am trying to model complex ecological data. I have programmed a lot of GAM models using the mgcv package but am struggling to select a model and struggling to evaluate which models are the best.

At best (across roughly 20 models) I am achieving R-sq(adj) = 0.40 with an average deviance explained = 38%-45%.

I am wondering what is the best process for selecting a best GAM model in R.

Some of the models I built had significant predictor variables and a significant intercept but lower R-sq(adj) and deviance explained than models with no significant terms.

Can any one provide some guidance on how to select a model ?

$\endgroup$

1 Answer 1

20
$\begingroup$

If you want to select from among a group of covariates, then a principled way of doing this is to put some additional shrinkage on each of the smoothers in the model so that they can be penalised out of the model entirely if needed.

In the typical setting the wiggliness penalty is based on the curvature (the second derivative) of the estimated function. This penalty affects the wiggly basis functions as they have a non-constant second derivative. The basis expansion that is performed on each covariate results in basis functions that live either in the null space or the range space of the penalty. Those in the range space are the wiggly functions that can be penalised and shrunk to ~zero effect if we don't need to fit such a wiggly function.

The basis functions in the null space are a flat function (which is removed via an identifiability constraint as it is confounded with the model intercept) and a linear function, which have zero curvature. As such the penalty doesn't affect them. This is why you can estimate a linear effect in a GAM fitted via mgcv but you can't get rid of the linear part because it is totally unaffected by the penalty as it has no wiggliness.

Giampiero Marra and Simon Wood (2011) showed that through an additional penalty targeted specifically at the penalty null space components, effective model selection could be performed in a GAM. The extra penalty only affects the perfectly smooth terms, but it has the effect of shrinking linear effect back to zero effects and thus entirely out of the model if that is justified.

There are two options in mgcv for this:

  1. shrinkage smoothers, and
  2. the double penalty approach.

Shrinkage smoothers are special versions of the ordinary basis types but they are subject to an eigen decomposition during formation of the penalty matrix in which those basis functions which are perfectly smooth return zero eigenvalues. The shrinkage smoother just adds a very small value to terms with zero eigenvalue, which results in the terms now being affected by the usual wiggliness penalty used to select the smoothness parameters. This approach says that the wiggly functions should be shrunk more than the functions in the null space as the small addition to the zero-eigenvalue terms means those terms are less affected by the wiggliness penalty than the functions in the range space.

Shrinkage smoothers can be selected for some or all smooths by changing the basis type to one of the following:

  • bs = 'ts' — for the shrinkage version of the thin plate regression spline basis,
  • bs = 'cs' — for the shrinkage version of the cubic regression spline basis.

This argument is added to whichever s() functions you want to shrink in the formula for the model.

The double penalty approach simply adds a second penalty that only affects the functions in the null space. Now there are two penalties in effect;

  1. the usual wiggliness penalty that affects functions in the range space, and
  2. the shrinkage penalty that affects functions in the penalty null space.

The second penalty allow the linear term to be shrunk also and together, both penalties can be result in a smooth function being entirely removed from the model.

The advantage of the double penalty approach is that the null space and the range space functions are treated the same way from the point of view of shrinkage. In the shrinkage smoother approach, we are a priori expecting the wiggly terms to be shrunk more than the smooth terms. In the double penalty approach, we do not make that assumption and just let all the functions be shrunk.

The disadvantage of the double penalty approach is that each smooth now requires two "smoothness" parameters to be estimated; the usual smoothness parameter associated with the wiggliness penalty, and the smoothness parameter that controls the shrinkage that applies to the functions in the null space.

This option is activated in mgcv via the select = TRUE argument to gam(); and which means it is turned on for all smooths in the model formula.

Marra and Wood's (2011) results suggested that the double penalty approach worked slightly better than the shrinkage smother approach.

Marra, G., and S. N. Wood. 2011. Practical variable selection for generalized additive models. Comput. Stat. Data Anal. 55: 2372–2387. doi:10.1016/j.csda.2011.02.004

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.