In R, I would like to fit a gam model with categorical variables. I thought I could do it like with (cat is the categorical variable).
lm(data = df, formula = y ~ x1*cat + x2 + x3);
But I can't do things like :
gam(data = df, formula = y ~ s(x1)*cat + s(x2) + x3)
but the following works:
gam(data = df, formula = y ~ cat + s(x1) + s(x2) + x3)
How do I add a categorical variable to just one of the splines?