I am trying to model a varible (maximum depth) as a function of type of dive and diel changes (day,night) with the individuals (whales in this case) as a random factor in R.
I tried first to apply a linear mixed model (lme) and I had a problem of autocorrelation and non-normality of residuals.
Next, I tried to apply a GLM with Poisson and negative binomial distribution. Both had the same problem of autocorrelation and/or non-normality of residuals.
What can I do after to model these variables or to correct these issues?
Thank you
Update
I tried using corAR1 (correlation = corAR1(form = ~ 1 | whale)) but when I plot ACF there is still a strong autocorrelation.
What can this mean and how could I proceed to solve it?
I could not include time in the corAR1 function because of repeated diel values (Error in Initialize.corAR1(X[[i]], …) : covariate must have unique values within groups for "corAR1" objects)
Thanks!
Best Answer
Mixed models are often a good choice when you have repeated measures, such as here, within whales.
lme
from thenlme
package can fit mixed models and also handle autocorrelation based on a AR(1) process, where values of $X$ at $t-1$ determine the values of $X$ at $t$.$$ X_{t}=c+\varphi X_{{t-1}}+\varepsilon _{t} $$
The function
corAR1
handles discrete time andcorCAR1
handles continuous time. For example:with equally spaced time intervals or:
where the time intervals are supplied by the
time
variable.From your description, the outcome is continuous so a count model such as Poisson or negative binomial would not make sense