Wow, quite an old question!
Regarding interaction
While the weekly pattern itself is very stable over the year, its amplitude also varies with the seasons.
The use of tensor product spline basis te
is the right way for interaction, although a more decent constructor is ti
. You said that te
returns you many parameters. Of course. You have k = 52
for the first margin, and k = 5
for the second, then you end up with 52 * 5 - 1
coefficients for this tensor term. But this is just the way an interaction is created.
Note that in mgcv
GAM formula, :
or *
is only valid for interaction between parametric terms. Interaction between smooths are handled by te
or ti
.
If this is not what you hope for, then what do you expect the "product" to be? A Hadamard product of two marginal design matrices? Then what's the sense of that? By the way, a Hadamard product requires two matrices of the same dimension. However, your two margins do not have the same number of columns.
If you don't understand why I keep talking about matrices, then you need to read Simon's book in 2006. Though GAM estimation explained there is rather outdated now, the construction / setup of GAM (like design matrices and penalty matrices) explained in Chapter 4 does not change at all even after a decade.
OK , let me give you one more hint. The row wise Kronecker product used for construction of te
/ ti
design matrix is not a new invention.
A smooth term s(x)
is quite like a factor variable g
, as though they appear to be a single variable, they are constructed to be a design matrix with many columns. For g
it is a dummy matrix, while for f(x)
it is a basis matrix. So, interaction between two smooth functions is constructed in the same way that interaction between two factors is constructed.
If you have a factor g1
of 5 levels, and another factor g2
of 10 levels, their marginal design matrix (after contrasts) have 4 columns and 9 columns, then the interaction g1:g2
would have 36 columns. Such design matrix, is just the row wise Kronecker product of the design matrix of g1
and g2
.
Regarding overfitting
As you said, you only have few years of data, maybe 2 or 3? In that case, your model have been over-parametrized by using k = 52
for day_in_year
. Try reduces it to for example k = 30
.
If overfitting is still evident, here are a few ways to address it.
Way 1: You are using GCV for smoothness selection. Try method = "REML"
. GCV always inclines to overfit data.
Way 2: Staying with GCV, manually inflate smoothing parameters for a heavier penalization. gamma
parameter of gam
is useful here. Try gamma = 1.5
for example.
A typo in your code?
The knots location, should it be day_in_year = c(0, 365)
?