How to remove tensor interaction in gam function? #198
-
Dear Gavin, I have a question about removing the tensor interaction in gam function, and I would appreciate it if you could help me. How should I change the gam function if I want that gam just consider the pure effects of these three variables without their interaction? Some references said that if there is interaction between variables, removing ti() may cause repeating same covariates multiple times. I tried fit <- gam(Y ~ s(X1) + s(X2) + s(X3) +s(X4) + ti(X1,X2,X3 , np=FALSE) , data=data), and compared it by "np=TRUE" but nothing changed in results. Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Instead of opening an Issue (which is for bug reports or feature requests) please use the Discussions tab. Technically, your model should be m1 <- gam(Y ~ s(X1) + s(X2) + s(X3) + s(X4) + # first order terms
ti(X1, X2) + ti(X1, X3) + ti(X2, X3) + # second order terms
ti(X1, X2, X3), # third order term
data=data, family = FOO, method = "REML") Now you can consider dropping the Adding If your question is, can you fit m2 <- gam(Y ~ s(X1) + s(X2) + s(X3) + s(X4),
data=data, family = FOO, method = "REML") and compare it with the above, yes, you can. However, if you believe there may be interactions between your covariates and you have sufficient data to estimate those higher order terms, and if you are interested in anything other than prediction (i.e. you want to estimate effects or do inference), I would just fit the full model (with or without Either the sources you mention are confused or you have misunderstood. It would be a problem to fit a simpler version of your model (without the third order term) using m3 <- gam(Y ~ s(X4) +
te(X1, X2) + te(X1, X3) + te(X2, X3), # second order terms
data=data, family = FOO, method = "REML") because in m4 <- gam(Y ~ s(X1) + s(X2) + s(X3) + s(X4) + # first order terms
ti(X1, X2) + ti(X1, X3) + ti(X2, X3), # second order terms
data=data, family = FOO, method = "REML") and except for some additional smoothing parameters we would get the model implied by |
Beta Was this translation helpful? Give feedback.
Instead of opening an Issue (which is for bug reports or feature requests) please use the Discussions tab.
Technically, your model should be
Now you can consider dropping the
ti(X1, X2, X3)
, and from there consider if you need any of the second order interactions.Adding
select = TRUE
to the model if you want to do model selection.If your question is, can you fit