[R] arima() in for loop

John Fox jfox at mcmaster.ca
Mon Oct 28 15:41:08 CET 2002

Dear VIto,

At 12:50 PM 10/28/2002 +0100, vito muggeo wrote:
>hi all,
>In a simulation context I'm running in a for loop the arima() function
>for( i in 1:1000){
>         y<-arima.sim(....)
>         out<-arima(y,....)
>         ........
>          }
>Everything works, but after some cycle (10, say) I get error due to the
>particular y-values simulated. (E.g., a *frequent* error is "Error in
>svd(na.omit(xreg)) : 0 extent dimensions") As a consequence the overall loop
>does not continue!
>Is it possible to skip the "errors" ? i.e I'd like that, when arima() is not
>able to estimate the model, it returns 0, say (or some other object), in
>order to allow the loop to go on.
>I tried to look inside the code of arima(), but I'm not so expert to find
>the solution

Take a look at the try function, which is designed to trap errors.

John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list