# Gamm residuals patterns: temporal and spatial

I'm trying to fit a GAMM model with this dataset, which can be downloaded here: https://ufile.io/8umh6 . The dataset consists of 60 pixels sampled in two different areas: BAR and MON, 30 for each one. Each pixel has its (X,Y) coordinate in X and Y colums, NDVI values, which are between -1 and 1, through 1984-2017 ANO. The QUADRIMESTRE (named incorrectly) variable refers to a three-month period, that is, 1 refers to January, February and March, 2 to April, May, June, etc.

I'm using the approach suggested in Zuur et al, 2009, chapter 18, this. So, the model is something like:

M3<-gamm(NDVI~   s(ANO,by=LOCAL,bs="cr")+s(QUADRIMESTRE,  by = LOCAL,k=3) +
s(X, Y), random=list(PIXEL=~1),data=samplesg2)


That is, I'm trying to extract a long-trend component through years (ANO) by LOCAL, the seasonality using QUADRIMESTRE plus spatial component (X,Y). The random intercept is because I would like to not keep the conclusions to only those 60 pixels, but similar pixels by place.

The idea is to extract the trends and compare with other variables' trends by local (BAR and MON), same idea proposed by Zuur (2009).

However, the residuals showed this pattern.

E <- resid(M3$lme, type = "normalized") F <- fitted(M3$lme)
plot(x = F, y = E, xlab = "Fitted values", ylab = "Residuals",
cex = 0.3)


In the book, one solution is to apply weights=varIdent(form=~1|...)) but this keeps the pattern. What can I do to remove this (possible) pattern presented by residuals? Does the fact that my response variable's values being between -1 and 1 part of the problem?

EDIT: Sorry, in the hurry, I forgot to include some graphs.

The first one is the box-plot of NDVI by LOCAL, for each one of the 60 pixels. Second is the box-plot of NDVI by season (3 months). So I can conclude that the NDVI values are different from MON and BAR. Also, the second box-plot showed some small(?) seasonality and different values by LOCAL.

• "Does the fact that my response variable's values being between -1 and 1 part of the problem?" Yes, that's at least one issue. What exactly are these values? You need to find an appropriate transformation / family to model this. The 'G' in GAMM is important here. Also, instead of gamm I'd use gam and a smoother of bs = "re". I think I'd also rather use te(x, y). – Roland Mar 5 '18 at 15:43
• NDVI is a index that represents vegetation. If its >= 0.4, approximately, it's indicating vegetation. Else, the pixel can be classified as water. Thanks for the comment. – Kol Rocket Mar 5 '18 at 23:01
• Also, I'll look into gam function, – Kol Rocket Mar 5 '18 at 23:10