I have constructed a GAM using the package mgcv to test whether the lengths of an emerging insect (Length) varies with day of the year (DOY) and between two sites (SiteCode). The data are collected at irregular time steps ranging from 2 days to 20 days between samples. The GAM takes the form

M3 <- gam(Length ~s(DOY, by = SiteCode) + SiteCode)

As the data are a time series I would like to test for temporal autocorrelation. I have read that it is not possible to use the autocorrelation function (ACF) due to the irregular spacing and that producing a variogram in relation to DOY would be an option.

Is this a correct method to test for temporal autocorrelation?

And could someone suggest the code to produce the variogram as I'm getting an error related to the 'distance' argument

Best wishes
Tom



	[[alternative HTML version deleted]]

