0

Link to the data in question

I'm trying to make a GAMM of this data using smoothers for each of the "high1, low1, ...etc" variables, but when I input the following code, I get this singularity problem:

Error in MEestimate(lmeSt, grps) : Singularity in backsolve at level 0, block 1

The code in question:

Zones <-c(NDVI$High1, NDVI$Low1, NDVI$High2, 
     NDVI$Low2, NDVI$High3, NDVI$Low3, NDVI$High4, NDVI$Low4)
Time <- rep(NDVI$Time, 8)
Season <- rep(NDVI$Season, 8)
ID <- factor(rep(c("1.High", "1.Low", "2.High", "2.Low", "3.High",
     "3.Low", "4.High", "4.Low"), each = length(NDVI$Time)))
library(mgcv)
Change1 <- gamm(Zones ~ Season + ID + 
   s(Time, by = as.numeric(ID == “1.High”)) + 
   s(Time, by = as.numeric(ID == “1.Low”)) + 
   s(Time, by = as.numeric(ID == “2.High”)) + 
   s(Time, by = as.numeric(ID == “2.Low”)) + 
   s(Time, by = as.numeric(ID == “3.High”)) + 
   s(Time, by = as.numeric(ID == “3.Low”)) + 
   s(Time, by = as.numeric(ID == “4.High”)) + 
   s(Time, by = as.numeric(ID == “4.Low”)), 
   weights = varIdent(form =~1 | ID))
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Can you please cut and paste your data as a text/code block rather than as an (unusable) screen shot? See e.g. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Ben Bolker Feb 27 '21 at 00:34
  • I think you *might* want `Season + ID + s(Time, by=ID)` – Ben Bolker Feb 27 '21 at 00:35
  • also, if you get a chance please edit "smart quotes" in your code block to regular double quotes (`"`) – Ben Bolker Feb 27 '21 at 00:37
  • @BenBolker, the output of `...s(Time, by=ID)` may be different than the output of the original code. At the moment I'm working with a book "Mixed Effects Models and Extensions in Ecology with R", Zuur, Ieno et al.; the code in book is written in `s(Time, by = as.numeric(ID == “1.High”))` manner and it gives different output than `s(Time, by=ID)`. Why? Is it due to sequential testing? But then, the R=sq. (adj) differs too. – Jacek Mucha Aug 12 '21 at 08:01

0 Answers0