Skip to content
Prev 244086 / 398506 Next

mgcv package plot superimposing smoothers

Hi Jef,


I would extract the information about the smoothers and plot them using 
standard plotting routines. After

Mtest <- gam(outcome ~ s(age, by=as.numeric(gender==0)) +
s(age,by=as.numeric(gender==1))+factor(Gender))

run something similar to:

smoothers <- predict(s,type='terms')

and you get the values for the smoothers saved to "smoothers" (See 
?gam.predict). You may haave to tweak around a bit as I could not test 
the function. Another solution may be (also untested):

plot(Mtest,select=1)
par(new=TRUE)
plot(Mtest,select=2)


HTH
Jannis

Jef Vlegels schrieb: