I have fit a glmm using the glmer function from the lme4 package. I have found the DHARMa package very helpful for evaluating the fit of my model but am stuck as to what to do to evaluate temporal autocorrelation. I collected data at 14 sites. A data point was collected every 5 hours at each site, so I have multiple observations for each site. Because of this, I do not have a unique time value for each observation in my data-I have 14 observations (one for each site) per time value. The testTemporalAutocorrelation function in the DHARMa package does not like this—when I plug my time variable into the function
testTemporalAutocorrelation(simulationOutput = simulationOutput,
time = data$ObservationNumber)
I get the following error:
Error in testTemporalAutocorrelation(simulationOutput = simulationOutput, : testing for temporal autocorrelation requires unique time values - if you have several observations per location, use the recalculateResiduals function to aggregate residuals per location
I have used the recalculateResiduals function, plugging in site as the grouping factor
simulationOutput1 <- recalculateResiduals(simulationOutput, group=data$site)
However, I am not sure what the next step is. I initially tried:
testTemporalAutocorrelation(simulationOutput1)
but when I run that, I get the following error:
Error in X[order(z), ] : subscript out of bounds
I am not sure what the next steps are with regards to evaluating temporal autocorrelation. Any thoughts/advice are greatly appreciated, and please let me know if there is any additional information I can provide to clarify my question. Thank you!