In R, I would like to fit a gamma model with categorical variables. I thought I could do this as with (cat is a categorical variable).
lm(data = df, formula = y ~ x1*cat + x2 + x3);
But I can not 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 to add a categorical variable to only one of the splines?
source
share