Below is an example using mtcars.
par(mfrow=c(1,2))
plot(mtcars$disp,mtcars$mpg)
plot(mtcars$hp,mtcars$mpg)
library(mgcv)
gam1 <- gam(mtcars$mpg ~ s(mtcars$disp) + s(mtcars$hp), family = Gamma)
plot(gam1, page = 1)
The strange thing is that if I draw the relationship between disp & mpg, or hp & mpg, they are negatively related (Fig1). But after using GAM, their relation became positive (Fig2). How can they contradict?
