config-i1 / smooth

The set of functions used for time series analysis and in forecasting.
89 stars 19 forks source link

Minor but strange lags bug #199

Closed T-Flet closed 1 year ago

T-Flet commented 1 year ago

There is not much more to explain than to show what works and what does not in the following reproducible example:

# WORK
auto.adam(data = zoo(AirPassengers), lags = c(12), distribution = 'dgamma') # The "true" period
auto.adam(data = zoo(AirPassengers), lags = c(23), distribution = 'dgamma') # Double period -1
auto.adam(data = zoo(AirPassengers), lags = c(25), distribution = 'dgamma') # Double period +1
auto.adam(data = zoo(AirPassengers), lags = c(36), distribution = 'dgamma') # Triple period

# FAIL
auto.adam(data = zoo(AirPassengers), lags = c(24), distribution = 'dgamma') # Double period
auto.adam(data = zoo(AirPassengers), lags = c(48), distribution = 'dgamma') # Quadruple period

The failure is with this error and warning (and the warning does not appear in the working cases):

Error in if (doShifts) { : argument is of length zero
In addition: Warning message:
This function only works with classes zoo and POSIXt. Cannot extract DST observations. 

The failing cases work if AirPassengers is not converted to zoo, but that is, I think, beside the point. (The distribution argument is not necessary to trigger the issue; it is only there to speed up execution).

Finding this might seem very random: the context in which it came up was automatically determining periodicity prior to fitting; then checking double the dominant frequency after the first fit is worth a try.

config-i1 commented 1 year ago

Thanks for reporting this and providing the example. This is now fixed in ade9b25e291a8ef47f7c98da300c4b29298473bf