Hello, Put the fitted models in a list and then use lapply with AIC(). Like this
set.seed(1) x <- 1:100 + sqrt(1:100 + runif(100)) + rnorm(100) models <- list() models[[1]] <- arima(diff(x), order = c(1, 0, 0)) # Just to show models[[2]] <- arima(diff(x), order = c(1, 0, 1)) # several models[[3]] <- arima(diff(x), order = c(2, 0, 2)) # models models[[4]] <- arima(diff(x), order = c(2, 0, 3)) lapply(models, AIC) Or run each model at a time through AIC(), whichever suits better. Hope this helps Rui Barradas Em 04-07-2012 10:22, Sajeeka Nanayakkara escreveu:
Hi, I need to predict exchange rates using time series. So according to ACF and PACF knowledge, mixed model (ARIMA) be the appropriate and now, I need to find order of the model (p,d,q). So, several models were fitted to select the suitable model using arima(). Could you please tell me the procedure of selecting the correct order as I don't have enough time to search? Thank you. Sajeeka Nanayakkara ------------------------------------------------------------------------ *From:* Rui Barradas <ruipbarra...@sapo.pt> *To:* Sajeeka Nanayakkara <nsaje...@yahoo.com> *Cc:* r-help@r-project.org *Sent:* Wednesday, July 4, 2012 2:58 PM *Subject:* Re: [R] how to check convergence of arima model Hello, Inline. Em 04-07-2012 09:35, Sajeeka Nanayakkara escreveu: > Hi, > > Sorry, since I didn't see the earlier message I resend it. > > I read the help page that you mentioned. But the problem is for all > models, code is zero. According to that, all models were converged. > Considering AIC value the best model is selected. No, arima() does not select models by AIC. That is the default behavior of ar(); arima() does NOT select models, it selects, using optim, values for the parameters of a specified model. You must choose the orders yourself. Hope this helps, Rui Barradas > > Is that correct procedure? > > The R code which was used is; > model1<-arima(rates,c(1,1,1)) > model1 > model1$code > [1] 0 > > Sajeeka Nanayakkara > > > > ------------------------------------------------------------------------ > *From:* Rui Barradas <ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt>> > *To:* Sajeeka Nanayakkara <nsaje...@yahoo.com <mailto:nsaje...@yahoo.com>> > *Cc:* r-help@r-project.org <mailto:r-help@r-project.org> > *Sent:* Wednesday, July 4, 2012 2:01 PM > *Subject:* Re: [R] how to check convergence of arima model > > Hello, > > Sorry, but do you read the answers to your posts? > Inline. > > Em 04-07-2012 08:02, Sajeeka Nanayakkara escreveu: > > I have already fitted several models > > using R code; arima(rates,c(p,d,q)) > > > > And I have already answered to a question starting like this yesterday. > In the mean time, the subject line changed. > > > > > As I heard, best model produce the > > smallest AIC value, but maximum likelihood estimation procedure optimizer > > should converge. > > > > > > How to check whether maximum likelihood estimation procedure > optimizer has converged or not? > > Yes, it was this question, the subject line was 'question'... > > ... And the answer was: read the manual, that I quoted, by the way. > > It now changed to: read the manual, period. > > Rui Barradas > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org <mailto:R-help@r-project.org> <mailto:R-help@r-project.org <mailto:R-help@r-project.org>> mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > >
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.