[R-sig-ME] gamm shifting points locations in plots: corrected post
Vinicius Maia
v|n|c|u@@@@m@|@ @end|ng |rom hotm@||@com
Fri Jan 18 12:05:30 CET 2019
Hi folks!
When running a gamm and seing its plots I found the residuals locations are shifted, I presume its because the smooth is fitted after taking the random effects into account (obviously). But I am not understanding how its possible to change data points location in these plots. Oddly the fitted smooth changes with the residuals inclusion in the following zuur example. The same is valid for the lmer, I usually plot the fitted line whith the residuals, but I have never seen this discrepancy in a points positions with the fitted line before. The gamm and lmer with both random effects show a similar linear fitted line. I would appreciate if anyone could clarify what is happening.
plots are in the link: https://uploaddeimagens.com.br/imagens/rsigd-min-jpg/
my codes:
a) mod1=gamm(y1_r_prop~s(areia), random = list(area=~1,chave=~1),data=dadosest)
plot(mod1$gam,residuals=TRUE,pch=1.3,shift = coef(mod1$gam)[1])
b) mod2=gamm(y1_r_prop~s(areia), random = list(chave=~1),method="ML",data=dadosest)
plot(mod2$gam,residuals=TRUE,pch=1.3,shift = coef(mod2$gam)[1])
c) mod3=gamm(y1_r_prop~s(areia), random = list(area=~1),method="ML",data=dadosest)
plot(mod3$gam,residuals=TRUE,pch=1.3,shift = coef(mod3$gam)[1])
d) mod4=gam(y1_r_prop~s(areia),method="ML",data=dadosest)
plot(mod4,residuals=TRUE,pch=1.3,shift = coef(mod4)[1])
e) plot(y1_r_prop~areia)
curve(18.3048+-2.2142*x,add=TRUE) # coefficients from a lmer with both area and chave random effects
as you can see y1_r_prop ranges from 0 to 50, and in gamm plots 10 to 30 sometimes.
and point positions varies with random effects inclusion.
A reproduciple example with zuur chapter 13, were a similar situation happen
library(nlme)
library(lme4)
library(mgcv)
library(glmmTMB) ; data(Owls)
Owls$NCalls <- Owls$SiblingNegotiation
Owls$fNest <- factor(Owls$Nest)
plot(Owls$NCalls~Owls$ArrivalTime)
#NCalls ranges from 0 to 30
O4.gamm <- gamm(NCalls ~ s(ArrivalTime),random = list(fNest =~ 1), data = Owls, family = poisson)
plot(O4.gamm$gam,residuals=TRUE,pch=1,cex=0.7,shift=coef(O4.gamm$gam)[1])
plot(O4.gamm$gam,residuals=TRUE,pch=1,cex=0.7)
plot(O4.gamm$gam,shift=coef(O4.gamm$gam)[1])
plot(O4.gamm$gam)
#here NCalls range changes to 1 to 5
#the fitted line also changes a lot with the inclusion of residuals
mod1=gam(NCalls~s(ArrivalTime),family = poisson, data = Owls)
plot(mod1,residuals=TRUE,pch=1,cex=0.7,shift=coef(mod1)[1])
plot(mod1,residuals=TRUE,pch=1,cex=0.7)
plot(mod1,shift=coef(mod1)[1])
plot(mod1)
#here NCalls range changes to 1 to 12
# and the fitted line also changes a lot with the inclusion of residuals
Thank you all!
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list