I'm fitting GAMs to avian survey data and have a mix of smooth (thin plate regression splines) and parametric terms in my models. I know about the integrated term selection available in mgcv via select = TRUE or bs = 'ts', but the only examples i can find of this approach is when all terms in the model were smooths. As far as i can tell, this extra penalty approach does not do anything with parametric terms, and so this seems like not the right approach when there is a mix of terms present (since parametric terms will be inherently favored due to their lack of penalty). At the same time, the reverse stepwise approach via estimated p values also seems a bit dicey, cause again, from my reading (eg. ANOVA table (and its interpretation) for a single GAM model), the estimation of the p values is not equivalent for smooths and parametric terms.

Any advice here?

  • $\begingroup$ What type of parametric terms are you thinking of; categorical or linear? $\endgroup$ Apr 13, 2018 at 16:32
  • $\begingroup$ there are both actually. categorical for different years, but there are also linear covariates to account for imperfect detection, such as start time of the survey. it's my habitat-related covariates that are smooths. $\endgroup$
    – ice_hawk10
    Apr 13, 2018 at 16:38

1 Answer 1


You could do what you want for linear terms using the paraPen argument to gam(), which allows penalties on parametric terms.

However, why not treat the linear terms as low-degree smooths (say k = 3) and let the double penalty work on it too?

For the categorical terms, I'd just leave them alone; I'm not sure it is possible to apply a group penalty to categories using paraPen. For something like year, it is highly unlikely that it will have a zero effect (all years exactly the same). I'd be inclined to either:

  1. treat year as categorical and just leave it alone penalty-wise, so you control for between year differences in the expectation of the response, or
  2. if you have enough years and you might expect a smooth trend in the data, treat it as smooth s(year).
  • $\begingroup$ thanks Gavin. i think, since the linear terms are associated with detection, that it may be best to leave them as is too, since in the response i'd obviously like to control for any differences across surveys based on things like weather conditions, time of survey, etc. so perhaps there's some value in leaving them unpenalized $\endgroup$
    – ice_hawk10
    Apr 16, 2018 at 22:24
  • $\begingroup$ it's also a bit more complicated, because a couple of those linear covariates are actually ordered factors that i've assumed are linear. i could transform them back to factors, but that increases the number of parameters that need to be estimated, and some levels of the factors are rather data sparse, which is why i linearized them to begin with $\endgroup$
    – ice_hawk10
    Apr 16, 2018 at 22:25
  • $\begingroup$ Hi, Gavin. is it correct in that when using the paraPen argument that this will be like adding a ridge penalty? I also have categorical variables which I am wanting to penalise, is this the appropriate formulation mtcars$cyl = factor(mtcars$cyl) ; m = gam(mpg ~ cyl, data=mtcars, paraPen = list(cyl=list(diag(2)))) (apologies on the fly-by question, but I have been unable to find much on the paraPen argument) $\endgroup$ Jun 15, 2018 at 20:37
  • 1
    $\begingroup$ @user2957945 Yes, that's my understanding $\endgroup$ Jun 19, 2018 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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