Skip to content
Prev 4869 / 7420 Next

GAM - Cyclic splines

To the best of my knowledge this works as per mgcv::gam and mgcv::gamm (as
the only code in **gamm4** is that to fit the GAMM via **lme4** and nothing
else, so leveraging existing code in **mgcv**).

Whilst it would help to give more informative names than X1 and X2, and so
on to your variables, I think the following should work, for the `bs =
"cc"` term:

Model <- gamm4(Y ~ s(X1, k=5, bs="cc") + s(X2, bs="cr") + offset(log(X3)),
              random = ~(1 | X4), data = data, family = poisson,
              knots = list(X1 = c(1, 366)))

Not sure why you want c(0, 366) as wouldn't that be 367 days?

Anyway, you pass knots a list with components named as per the variables
used in the smooth terms. If you don't supply knots for a smooth term, the
default locations are used. In the case of cyclic cubic splines, one can
simply get by with passing the end points of the knots as I did above, and
the remaining knots (as determined by k) are distributed evenly across the
interior of the stated two boundary knots.

I don't see why, if suitably fitted, predictions for day 1 or day 366
should differ markedly. Were you predicting at the same values of X2, X3,
and X4 when you compared the outputs?

HTH

G
On 22 January 2015 at 13:40, SamiC <samantha.cox at plymouth.ac.uk> wrote: