florianhartig/DHARMa

Uneven Spatial Time Series with testTemporalAutocorrelation

Opened this issue · 1 comments

Hello,

I am trying to test temporal autocorrelation in my dataset after fitting a GAM model. I have a dataset that includes one observation per hour per day. However, some hours are missing due to technical errors and no observations were recorded between the hours of 24:00-4:00, so the dataset is not evenly spaced.

Is it possible to still test temporal autocorrelation with the DHARMa package? This is my current code:

testTemporalAutocorrelation(simulationOutput = model_residuals, time = seals$Hour)

#This test does not work due to requiring unique time values; must aggregate residuals
aggregated_residuals <- recalculateResiduals(simulationOutput = model_residuals, group = seals$Hour)

#Test with aggregated residuals
testTemporalAutocorrelation(simulationOutput = aggregated_residuals, time = unique(seals$Hour))

Thank you for your help

Hi @mrconnor29,
You have repeated observations per hour and want to test the temporal autocorrelation per hour, correct?
The temporal autocorrelation test should work by recalculating the residuals aggregated per hour (if you have at least one observation per hour from 5:00 to 23:00h). Didn't it work?
If not, please send it here (or by email) a reproducible example of your code when it is not running.

By the way, if you are using the whole dataset, including the rows without hour (NA) in the model (and residuals), the aggregation may not be working because of the NAs (size difference between the model_residuals and seals$Hour).

Best,
Melina