I’m trying to define a nested random effect where the id corresponds to the sensor id and the site of sampling, so certain ids are related to one site; so I define this as a nested random effect: site/id.
Besides, the sensors take data every day and there’s a temporal auto-correlation of the data within every sensor. To correct that, I used the corAR1() function with (form = ~ doy|id), because the data is grouped by sensor and the order that it follows is the day of the year. humidity and temp are explanatory variables.
I tried to define this model with nlme:
lme(log10(response + 1) ~ humidity + temp, random = ~ 1|(site/id), correlation=corAR1(form = ~doy|id), data = df, method = "ML")
But it throws the following error:
Error in lme.formula(log10(response + 1) ~ max.vwc + mean.temp, random = ~1 | :
incompatible formulas for groups in 'random' and 'correlation'
If I substitute the corAR1 part by the default correction: correlation=corAR1(); then it works; but, from my point of view, it doesn’t take the right definition of the correlation structure.