Skip to content
Prev 360908 / 398506 Next

physical constraint with gam

On 12/05/16 02:29, Dominik Schneider wrote:
- yes that's right, s(x1,x2) gives an isotropic smooth, which is usually 
only appropriate if x1 and x2 are naturally on the same scale.
predict returns s(x1)*x1 (plot.gam just plots s(x1), because in general 
s(x1,by=x2) is not smooth). If you want to get s(x1) on its own you need 
to do something like this:

x2 <- x1 ## copy x1
m <- gam(y~s(x1,by=x2)) ## model implementing s(x1,by=x1) using copy of x1
predict(m,data.frame(x1=x1,x2=rep(1,length(x2))),type="terms") ## now 
predicted s(x1)*x2 = s(x1)

best,
Simon