AKS
AKS

Reputation: 11

ARIMA Modelling

I am trying to fit an ARIMA model to my time series.

I am trying to get the best model for my time series as follows,

best.aic<-Inf
for(p in 0:6){
  for(d in 0:6){
    for(q in 0:6){
      fit<-arima(nasdaq_ts,order=c(p,d,q))
      fit.aic<- fit$aic
      if (fit.aic < best.aic) {
        best.aic<-fit.aic
        best.fit<-fit
        best.order<-c(p,d,q)
        }
      }
    }
  }

But I am getting an error which says as follows

Error in optim(init[mask], armafn, method = optim.method, hessian = TRUE,  : 
  initial value in 'vmmin' is not finite

I cannot understand the above error or what is causing it? Can someone please help me here

My time series looks as follows,

enter image description here

Upvotes: 0

Views: 283

Answers (2)

Abhishek Kulkarni
Abhishek Kulkarni

Reputation: 511

Try this code:-

nasdaqfinal.aic <- Inf
nasdaqfinal.order <- c(0,0,0)
for (p in 0:6) for (d in 0:6) for (q in 0:6) {
nasdaqcurrent.aic <- AIC(arima(data, order=c(p, d, q)))
if (nasdaqcurrent.aic < nasdaqfinal.aic) {
nasdaqfinal.aic <- nasdaqcurrent.aic
nasdaqfinal.order <- c(p, d, q)
nasdaqfinal.arima <- arima(data, order=nasdaqfinal.order)
}
}

Upvotes: 0

Matt Sandgren
Matt Sandgren

Reputation: 476

Are you familiar with the auto.arima function? It contains parameters that allow you to specify the model space to search, as well as the type of search to perform.

Upvotes: 2

Related Questions