Cross Validated
2026-09-03 14:57 UTC
By Nate
AI-113-20260903-social-media-69372178
How to check for temporal auto-correlation for each time series separately?
I have 2 time series in abundance that I'm modeling by a 2-level factor in mgcv , by "fSeason" (wet/dry), and following advice here , I should be splitting a test for auto-correlation by each factor level. I'm just not sure how to do that. Apologies for posting ChatGPT code, but I've been unsuccessful in my search everywhere else. DHARMa does have a test, but I was told it's only for a single time series. I don't think I can use the traditional AR(1) as the data are irregularly-spaced and I've never taken Bayesian statistics. Anyway, for now I'm just asking if the code AI generated is correctly identifying that I do have some, albeit weak, but significant temporal auto-correlation in the wet season. Any general advice is also welcome! Data here . library(mgcv) library(gratia) library(DHARMa) system.time( by $scaledResiduals scaledResiduals[Season_idx] res_Season $simulatedResponse simulatedResponse[Season_idx, , drop = FALSE] res_Season $observedResponse observedResponse[Season_idx] res_Season $fittedPredictedResponse fittedPredictedResponse[Season_idx] res_Season$nObs Site locations were haphazardly chosen (before my time) to monitor changes in fish abundance due to the construction of new canals (data posted here not collected with this statistical model/set of hypotheses in mind - its just available). Timing of surveys is based on tide level (need at least 60 cm/2 ft of water to survey near shore during the day (during reg. working hours). It takes about 4-7 days to surve…
I have 2 time series in abundance that I'm modeling by a 2-level factor in mgcv , by "fSeason" (wet/dry), and following advice here , I should be splitting a test for auto-correlation by each factor level. I'm just not sure how to do that. Apologies for posting ChatGPT code, but I've been unsuccessful in my search everywhere else. DHARMa does have a test, but I was told it's only for a single time series. I don't think I can use the traditional AR(1) as the data are irregularly-spaced and I've never taken Bayesian statistics. Anyway, for now I'm just asking if the code AI generated is correctly identifying that I do have some, albeit weak, but significant temporal auto-correlation in the wet season. Any general advice is also welcome! Data here . library(mgcv) library(gratia) library(DHARMa) system.time( by $scaledResiduals scaledResiduals[Season_idx] res_Season $simulatedResponse simulatedResponse[Season_idx, , drop = FALSE] res_Season $observedResponse observedResponse[Season_idx] res_Season $fittedPredictedResponse fittedPredictedResponse[Season_idx] res_Season$nObs Site locations were haphazardly chosen (before my time) to monitor changes in fish abundance due to the construction of new canals (data posted here not collected with this statistical model/set of hypotheses in mind - its just available). Timing of surveys is based on tide level (need at least 60 cm/2 ft of water to survey near shore during the day (during reg. working hours). It takes about 4-7 days to surve…
Full article content could not be extracted automatically. Read the original below.
Source:
Cross Validated
· stats.stackexchange.com