# GAM selection when both smooth and parametric terms are present

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.

• What type of parametric terms are you thinking of; categorical or linear? – Gavin Simpson Apr 13 '18 at 16:32
• 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. – ice_hawk10 Apr 13 '18 at 16:38

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).
• 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) – user2957945 Jun 15 '18 at 20:37