I'm currently trying to create a model for my data. The model contains some linear terms, some smooth functions, and some tensor product interactions. After reducing my model to only the significant terms, it looks like this:
model.5 <- gam(response ~ x1 +x2 +s(x3, bs="tp") + s(x4, bs="tp") + ti(x3, x5, bs="tp") + s(x4, by=x1), family=poisson, method = "GCV.CP")
The factors x1 and x2 are binary variables.
I'm trying to assess if the number of basis functions is appropriate and for previous models that I've built I've been using k.check. These previous models only contained smoothing functions of the form s(variable1, varaible2, bs="tp"). However, for my model.5, if I use the k.check function or the gam.check function I receive the following error:
Error in names(dat) <- object$term :
'names' attribute [2] must be the same length as the vector [0]
Is this an issue with my coding or is this because I'm now using tensor product interactions in my model. If the issue is to do with the fact that they are tensor product interactions, is there another way to check how well these smooth functions model the data and if the number of basis functions is appropriate?
Thanks!