[R-sig-ME] gamm plots in lattice

Maria Lathouri mlathouri at yahoo.gr
Thu Jun 8 12:15:59 CEST 2017

Dear all, 
I am new in list. I hope that you can help me on this. 
I am running a generalised mixed effect model, gamm4, for an ecology project. Below is the code for the model:
model<-gamm4(LIFE.OE_spring~s(Q95, by=super.end.group)+Year+Hms_Rsctned+Hms_Poaching+X.broadleaved_woodland             +X.urban.suburban+X.CapWks, data=spring, random=~(1|WATERBODY_ID/SITE_ID))
I am trying to plot the results in lattice for publication purposes so I need to figure this out. I have been struggling but I think I have reached a dead end. 

Here is what I have been able to code:
upr<- M$fit + (1.96 * M$se.fit)lwr<- M$fit - (1.96 * M$se.fit)
library(lattice)xyplot(fitted(model$gam) ~ Q95 |super.end.group, data = spring, gm=model,       prepanel=function (x,y,...)list(ylim=c(min(upr),max(lwr))),       panel = function(x,y, gm, ...){              panel.xyplot(x,y, type="smooth")         panel.lines(upr,lty=2, col="red")         panel.lines(lwr,lty=2, col="red")         panel.loess(x,y,...)         panel.rug(x = x[is.na(y)],                   y = y[is.na(x)])       }       )
But, unfortunately, this is not what I get when I have the simple plot(model$gam). 

I have also attached a reproducible example in case you want to see for yourself. I hope that someone here has come up with a similar problem and can help me on this.
Thank you very much for your time.
Kind regards,Maria 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example.txt
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20170608/ac10b235/attachment-0001.txt>

More information about the R-sig-mixed-models mailing list