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)

Residual x fitted

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.

Box-plot of NDVI by LOCAL and pixels. Box-plot of NDVI by season (3 months).

  • $\begingroup$ "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). $\endgroup$ – Roland Mar 5 '18 at 15:43
  • $\begingroup$ 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. $\endgroup$ – Kol Rocket Mar 5 '18 at 23:01
  • $\begingroup$ Also, I'll look into gam function, $\endgroup$ – Kol Rocket Mar 5 '18 at 23:10

And you should add the term LOCAL as a covariate too.

But without seeing the data and/or data exploration graphs you might as well ask Gandalf from Lord of the Rings.

Alain Zuur

  • $\begingroup$ Sorry, I forgot completely. And that was funny. I included some graphics in the original post. Data is included in the url provided in the beginning too. Thanks for replying. $\endgroup$ – Kol Rocket Mar 5 '18 at 23:00

I'm pretty sure that we somewhere mention in the book that you need at least 20 or 25 unique values for a smoother. You shouldn't fit a smoother on a covariate like quarter with only 4 unique values.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.