#rstats question for mgcv
If I want to test whether there is support for a smooth x factor effect, I can just include the smooth and the smooth x factor as separate terms to create nested models, right? As in
library(mgcv)
set.seed(0)
dat<-gamSim(5,n=200,scale=2)
##make explicit factor
dat$fac = factor(letters[dat$x0])
m = gam(y ~ s(x1) + fac + s(x1, by = fac), data = dat)
m1 = gam(y ~ s(x1) + fac, data = dat)
anova(m, m1, test = "F")