Dear all,
I'm using gam models to test for a by-factor interaction and then plotting
the results using vis.gam(). The y variable is binomial and I use models of this
sort:
Mod1<-gam(y~Factor+te(x1,x2, by=Factor)
+s(Group,bs="re"),data=mydata,family=binomial(link=logit),method="REML")
Mod2<-gam(y~Factor+te(x1,x2)+te(x1,x2,by=as.numeric(Factor==1))+
te(x1,x2,by=as.numeric(Factor==2))+s(Group,bs="re"),data=mydata,family=binomial(link=logit),method="REML")
With Mod1, I use vis.gam to visualize the 2D-smooth obtained for each level of
my Factor (3 levels):
vis.gam(Mod1,
view=c("x1","x2"),cond=list(Factor=0),plot.type="contour",color="heat")
vis.gam(Mod1,
view=c("x1","x2"),cond=list(Factor=1),plot.type="contour",color="heat")
vis.gam(Mod1,
view=c("x1","x2"),cond=list(Factor=2),plot.type="contour",color="heat")
For Mod2 however, I try to plot with vis.gam() the 2D-smooth for the reference
level and then the 2D-smooths showing the difference between reference level (0)
and level 1, and the difference between reference level(0) and level 2. Those
are the three plots usually obtained when using plot(Mod2) but that I would like
to plot with vis.gam() in order to add nice colors to the plot.
I have tried several options but don't manage to get those plots with
vis.gam(). Does anyone has any idea of some coding I could write to obtain
those??
Thanks if anyone can help,
Geraldine