> Hi all,
> I´m using the arima() function to study a time series but it gives me
> the following error:
> Error en optim(init[mask], armafn, method = "BFGS", hessian = TRUE,
> control = optim.control, :
> non-finite finite-difference value 
> I know that I can change the method of the arima() to "CSS" instead of
> "ML" but I'm specially interested in using maximum likelihood.
> I have read that using the Nelder-Mead method in the optim() function
> could avoid this error but I think that it is not possible to change
> the method of "optim" from arima().
The arguments for 'arima' includes 'optim.control', which the
'arima' help page describes as a "List of control parameters for
'optim'." Unfortunately, the following attempt to use this failed:
arima(lh, order = c(1,0,0), optim.control=list(method="Nelder-Mead"))
Warning messages: In optim(init[mask], armafn, method = "BFGS", hessian
= TRUE, control = optim.control, :
unknown names in control: method
If it were my problem, I might start by downloading the source for
the R "stats" package from CRAN or listing 'arima' and copying it into a
script file. A 'search' for "optim" in
the code for 'arima' revealed that it is called in 4 different places.
I then added the following lines to the start of 'optim' and changed all
4 calls to 'optim' so they said 'method = optimMtd' instead of 'method =
When I tried this, I found that I had to search for "R_" and
replace it by "stats:::R_" because of object names hidden in the
"namespace" for the "stats" package. When I did this, 'optim' ran
successfully and gave almost identical answers to the default "BFGS"
'optim' method, differing by one digit on the last decimal place in one
of the summary numbers from "arima(lh, order = c(1,0,0))".
If you try this, please let us know if it solves your problem.