'Interaction consider in gam() fitting with R

I am fitting data using gam() function. At this time, there is an interaction in opposite directions between the two variables. Is smoothing possible considering this?

For example, fitting the equation y~s(x0)+s(x1)+s(x2), when the Pearson coefficients of x1 and x2 are '-1', how can I do gam() fitting while considering this?

Thank you!

################################################################ '''R gam.whole <- gam(y~s(x0)+s(x1)+s(x2)+s(x3), data=data.df) '''

In here, x2 and x3 has opposite correlation. Like as follow:

enter image description here

Thus, I trie to constructing my R script like this. '''R gam.whole <- gam(y~s(x0)+s(x1)+s(x2)+s(x3)+s(x2,x3), data=data.df) '''

But, I am not sure it is right way for considering correlation between x2 and x3.

################################################################



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source