5

I am trying to model a variable (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 distributions. Both had the same problem of autocorrelation and/or non-normality of residuals.

What can I do 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.

enter image description here

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!

1 Answers1

5

Mixed models are often a good choice when you have repeated measures, such as here, within whales. lme from the nlme 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 and corCAR1 handles continuous time. For example:

mod <- lme(..., correlation = corAR1(form = ~ 1 | id))` 

with equally spaced time intervals or:

lme(..., correlation = corAR1(form = ~ time | id))

where the time intervals are supplied by the time variable.

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.

From your description, the outcome is continuous so a count model such as Poisson or negative binomial would not make sense

Robert Long
  • 60,630
  • 1
    Here you can find some comparative analysis https://bbolker.github.io/mixedmodels-misc/notes/corr_braindump.html –  Jul 07 '20 at 09:03
  • Hi Robert! Thanks for the input. I tried using corAR1 but it doesn't seem to solve the autocorrelation problem (if i'm interpreting the results well). I added the resulting acf plot to the post. If you have any other tip on how to proceed I would very much appreciate :) – Catarina Toscano Jul 07 '20 at 10:50
  • 1
    You're welcome. Please can you edit the question and include the model code and also include the acf plot from the original model (before you added corAR1. Also take a look at the link that @ping posted just above here – Robert Long Jul 07 '20 at 11:10
  • Hi Robert, I put all the models and graphs in this question (link below) and included an explanation of the dataset https://stats.stackexchange.com/questions/475950/autocorrelation-in-linear-mixed-models-lme – Catarina Toscano Jul 07 '20 at 13:54
  • @CatarinaToscano OK, that's fine. In that case please consider marking my answer here as accepted and I can take a look at the new question a little later when I have time. – Robert Long Jul 07 '20 at 14:06
  • ok! thank you Robert, I have accepted your answer – Catarina Toscano Jul 07 '20 at 14:24