3

when I fit the ARMA model by using the function

fit<-arima(data,order = c(1,0,1),method="ML")

I got this message

possible convergence problem: optim gave code = 1

can anyone help me to solve this problem


An example: if I repeat this an number of times I receive convergence warnings

set.seed(2)
n <- 100
for(i in 1:1000) {
     sim <- arima.sim(list(ar=c(0.9,-0.4),ma=c(-1.2,0.3)),n=n) 
     fit <- arima(sim, order = c(1,0,1), method="ML")
}
user20650
  • 23,419
  • 5
  • 52
  • 85
Oday Dassi
  • 51
  • 1
  • 7
  • You should provide some sort of [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can recreate the problem and help you understand what's going on. – MrFlick May 28 '16 at 20:57
  • i generate the data by sim – Oday Dassi May 28 '16 at 21:01
  • when i simulate this fitted model 10,000 times i got this message – Oday Dassi May 28 '16 at 21:03
  • Please take the time to read the link provided by MrFlick and edit your question accordingly. – lmo May 28 '16 at 21:05
  • An example is needed , but looking at `?optim` it would seem that a `1` indicates that the max number of iterations has been met. So looking at `?arima`, the next step would be to increase this by changing the iterations in the `optim.control` argument. – user20650 May 28 '16 at 21:26
  • libraray{forecast} n – Oday Dassi May 28 '16 at 21:31
  • first step simulate data by using this function sim – Oday Dassi May 28 '16 at 21:39
  • second fit model by using fit – Oday Dassi May 28 '16 at 21:40
  • user20650 please can you use this example sim – Oday Dassi May 28 '16 at 21:48
  • @OdayDassi; that runs okay for me. As you are using random generated numbers, you need to use set.seed to make it reproducible. So for example, `set.seed(1) ; sim – user20650 May 28 '16 at 21:51
  • But from my previous comments, did you try and change the number of iterations. For example, `set.seed(1) ; sim – user20650 May 28 '16 at 21:54
  • user20650; please could you tell me if you run this example 10,000 times or just one time, when i run this example in one time i dont have problem with it but with 10,000 time i got problem – Oday Dassi May 28 '16 at 21:55
  • user20650; i am running the example that you gave me sim – Oday Dassi May 28 '16 at 21:59
  • okay, I edited your question with an example that gives a warning. Using the example that i added to your question, if you change the control to `fit – user20650 May 28 '16 at 22:02
  • 2
    dear user20650; i run the example and i did not get any warning message many thanks for your help – Oday Dassi May 28 '16 at 22:18
  • Dear user20650; could you tell me please why i cannot fit another model by using the same method that you gave me it for example sim – Oday Dassi May 29 '16 at 11:42
  • I dont know anything about time-series, so first you need to make sure that your simulations are reasonable. But going back to my previous comment above, convergence is not guaranteed. Anyway, I would try changing the number of iterations, and the optimisation algorithm to see if it helps (although the BFGS is the default for a reason). If not I would wrap `arima` in `try` so that when you are looping through the simulations, it continues if it throws an error. – user20650 May 29 '16 at 12:28
  • ps. if you use @user20650, I will be notified that you have left a comment – user20650 May 29 '16 at 12:37
  • Dear user20650; i have used this method sim – Oday Dassi May 29 '16 at 12:47
  • Well BFGS is the default - did you try other methods? Have a look at `?optim` to see other algorithms. Also `maxit` can also be greater than 200. But as I have commented, there is no guarantee of convergence. So you need to come up with a strategy to deal with this - which is why i suggested using `try`. – user20650 May 29 '16 at 12:51
  • Dear user20650; what do you mean by using try. is it a function in R. i have already increase the iterations but the same problem – Oday Dassi May 29 '16 at 13:05
  • It is. In the following example, an error is thrown in one of the iterations, that will stop the loop. You can use `try` to allow the loop to continue. `fit – user20650 May 29 '16 at 13:11
  • To see the iterations that throw the error, you can use `s – user20650 May 29 '16 at 13:17
  • so this is the function of fitted the number of iterations s – Oday Dassi May 29 '16 at 13:24
  • `s` is a vector of length 1000 of `TRUE` and `FALSE` - `TRUE` if there was an error. (note: this will not catch convergence warnings!). The idea of using `try`, is just to allow the loop to go through all iterations, as otherwise it stops when there is an error. – user20650 May 29 '16 at 13:29
  • Dear user20650 finally i got the correct function and without any wearing error sim – Oday Dassi May 29 '16 at 14:10
  • Great stuff... got there in the end – user20650 May 29 '16 at 15:25

0 Answers0