config-i1 / smooth

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

ARIMA bug in auto.adam (but not in adam) #188

Closed T-Flet closed 2 years ago

T-Flet commented 2 years ago

An optimiser error is thrown by auto.adam ARIMA-only calls but not for equivalent adam calls i.e.:

> auto.adam(AirPassengers, model = 'NNN', orders = list(ar = 2, i = 0, ma = 2, select = T))
Error in is.nloptr(ret) : at least one element in x0 > ub

while

> adam(AirPassengers, model = 'NNN', orders = list(ar = 2, i = 0, ma = 2, select = T))
Time elapsed: 0.34 seconds
Model estimated using auto.adam() function: ARIMA(1,0,2) with constant
Distribution assumed in the model: Normal
Loss function type: likelihood; Loss function value: 779.2461
ARMA parameters of the model:
AR:
phi1[1] 
  0.209 
MA:
theta1[1] theta2[1] 
   0.7113    0.3556 

Sample size: 144
Number of estimated parameters: 7
Number of degrees of freedom: 137
Information criteria:
     AIC     AICc      BIC     BICc 
1572.492 1573.316 1593.281 1595.327 

Since (from the vignette) "if you do orders=list(..., select=TRUE) in adam(), it will call auto.adam() and do the selection", something seems to be going wrong in the auto.adam-only portion of ARIMA-only modelling, i.e. the distribution portion. As further evidence of this, note that explicitly providing the distribution argument can trigger the error even in adam (not all distributions do, e.g. dnorm does not):

> adam(AirPassengers, model = 'NNN', orders = list(ar = 2, i = 0, ma = 2, select = T), distribution = 'dgamma')
Error in is.nloptr(ret) : at least one element in x0 > ub
config-i1 commented 2 years ago

Thanks! I'll check this out.

config-i1 commented 2 years ago

Fixed in 6ca53bce9f9483aa32fdd5a4cb9009ba9ecf6c4a Please, install the development version using remotes::install_github("config-i1/smooth") until the package makes its way to CRAN.