I am using the gam
function (from the mgcv
package) to model a continuous response (a soil nutrient) in relation to a continuous predictor plus categorical predictors plus site random effects (modest number of sites) with:
gam(log(y) ~ s(x, bs = "cr", by = fac1) +
fac1 + fac2 + s(site, bs = "re", by = flag),
method = "REML")
The data come from a landscape study where sampling was challenging (to say the least), so the number of samples is small and the coverage of the range of $x$ values is quite patchy in the upper part of the range.
Use of a cubic spline for $x$, as above, results in quite a different shape for the fitted function compared to the default thin-plate spline for that part of the space where $x$ values are sparse. However, both models have almost identical results in terms of deviance explained and pattern of residuals. The shape of the function produced by the cubic spline is much preferred by my colleagues who conducted the study because they feel they can reconcile it with theory more readily than the alternative. However, I am wondering if:
- There are other criteria that I can investigate to choose between the models?
- Any theoretical reason to choose between using "cr" or "tp" for a univariate smooth with patchy data?
Update: plots of the alternative models
qqplot
and graphing against fitted values and predictors.gam.check
showed that EDFs were well below k' values. Unfortunately, the x variable has only a small number of unique values (18) so there's not much room for adjustment above the default k=10. I agree with your view that the best course is to present both results, assuming both survive scrutiny here. $\endgroup$