'ARIMA model won't work: error in optim function

hopefully someone can help me out.

I want to do an autoregressive regression on some monthly logreturns (60 observations). I found that only lag 1,3,11,18 are significant, so I only want to include those in the regression (see object model).

I keep on getting the error of non-finite finite-difference value, which I can't bypass. I tried two things that I found on the web:

  1. I tried setting optim.method = "Nelder-Mead", which gives me the output below.

  2. I tried setting optim.method = "Nelder-Mead" and hessian = FALSE, but then it gives the error that hessian is not a valid argument.

> model
 [1] NA  0 NA  0  0  0  0  0  0  0 NA  0  0  0  0  0  0 NA NA
> arima(log_returns, order = c(18,0,0), fixed = model, include.mean = TRUE)
Error in optim(init[mask], armafn, method = optim.method, hessian = TRUE,  : 
  non-finite finite-difference value [3]
In addition: Warning message:
In arima(log_returns, order = c(18, 0, 0), fixed = model, include.mean = TRUE) :
  some AR parameters were fixed: setting transform.pars = FALSE
> arima(log_returns, order = c(18,0,0), fixed = model, include.mean = TRUE, optim.method = "Nelder-Mead")
Error in optim(init[mask], armafn, method = optim.method, hessian = TRUE,  : 
  non-finite finite-difference value [2]
In addition: Warning messages:
1: In arima(log_returns, order = c(18, 0, 0), fixed = model, include.mean = TRUE,  :
  some AR parameters were fixed: setting transform.pars = FALSE
2: In log(s2) : NaNs produced
3: In log(s2) : NaNs produced
4: In log(s2) : NaNs produced
5: In log(s2) : NaNs produced
6: In log(s2) : NaNs produced
7: In log(s2) : NaNs produced
8: In log(s2) : NaNs produced
9: In log(s2) : NaNs produced


Solution 1:[1]

I had this same problem and setting an xreg value of 1:length(data) worked for me.

arima(data, order=c(p, d, q), xreg=1:length(data), method="ML")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 patL