eric-pedersen / mixed-effect-gams

Repo for tutorial/paper on mixed-effect GAMs
MIT License
122 stars 32 forks source link

smooth terms in HGAMs #56

Closed bryansmclean closed 4 years ago

bryansmclean commented 4 years ago

Hi,

First off - the paper on HGAMs is really instructive and super well written! So thanks. This isnt an issue per se, but I have a question about smooth terms that other users might be interested in. For Model types GS and S, is it required that the "fs" smooth term be used? I have a model consisting of a single predictor and single class of random effects for which I want to evaluate fit of group-level smoothers. However, these are phenology data where I wish to always use the cyclic cubic smoother (bs="cc").

Thanks, Bryan

gavinsimpson commented 4 years ago

The fs part is really not a basis in and of itself and there is a need to specify what underlying basis to use. This can be specified by passing a list to the xt argument of s():

s(x, fac, bs = "fs", xt = list(bs = "cc"))

would set up a cyclic cubic spline basis for use in this factor-smooth interaction. You can also specify the knots by passing the two end points/boundary knots for x (in the above example) by passing a list to the knots argument to gam() etc.

bryansmclean commented 4 years ago

That helps alot. Just to clarify - it is only model types GS and S (where a common smoothing parameter specifying wiggliness is being estimated) where the equation would take this fs basis, correct?

eric-pedersen commented 4 years ago

That's right. The fs basis assumes a single smoothing parameter for all group levels.