I would like to build a time series model for univaraite data in order to predict or forcast. I am a bit new to R but know some of the syntax. More over, I would like to get the best arima model with aicc criteria. I have used arima, auto.arima or sarima. But I could not extract the optimum values f p, d and q. I have tried sarima with mapply

aicc = mapply(function(i, j) sarima(X1, i, 0, j, no=T)[[3]], rep(0:4, 5), rep(0:4, each=5))
model =arima(xd, order=c(??, 0, ??)) # I would like to know what will be the order of this model.

So that I can use this model for forecast.

Also I have tried sarima with supply like

aicc=sapply(0:5, function(i) sarima(X1, i, 0, 0)[[3]])
m=arima(xd, order=c(best, 0, 0))

But here i can not get q compomnent. Is there any way to get optimum value of p and q. Thank you in advance


closed as off-topic by Andy, Tim, Stephan Kolassa, gung, Sycorax Jul 7 '15 at 18:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Andy, Tim, Stephan Kolassa, gung, Sycorax
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try auto.arima from forecast package - it will automatically find the "best" model using more efficient method than proposed by you. $\endgroup$ – Tim Jul 7 '15 at 18:29

here is the solution:

fit <- auto.arima(WWWusage,max.p = 5,max.q = 5,max.P = 5,max.Q = 5,max.d = 3,seasonal = TRUE,ic = 'aicc')

In this case optimal model is $ARIMA(1,1,1)$ and $aicc=510.8778$. This is the result: enter image description here

  • $\begingroup$ +1. You can get the AR and MA orders through summary(fit) or coefficients(fit). $\endgroup$ – Stephan Kolassa Jul 7 '15 at 18:38
  • $\begingroup$ or simply use str(fit) to see all parameters. $\endgroup$ – TPArrow Jul 7 '15 at 18:40
  • $\begingroup$ But I do not want seasonal. It is just non seasonal time series. So how I can get without seasonal then $\endgroup$ – Mahesh Maskey Jul 7 '15 at 18:54
  • $\begingroup$ if you use seasonal=FALSE then you get the right answer! $\endgroup$ – TPArrow Jul 7 '15 at 19:00
  • $\begingroup$ In my case, it gives ARIMA(0,1,2) with drift. But I do not know much about drift. I am sure I do not want this and I wan more towards p component rather than q. Is it possible? my data is like this [1] 0.316090 0.307530 0.290590 0.274100 0.251260 0.246170 0.253220 0.259450 [9] 0.255040 0.222030 0.208960 0.226830 0.217210 0.188840 0.160510 0.170030 [17] 0.179540 0.159960 0.162150 0.159250 0.139600 0.129890 0.114720 0.108620 [25] 0.104060 0.110100 0.093821 0.079752 0.077417 0.081177 0.074980 0.076597 [33] 0.085255 0.072477 0.072308 0.061657 0.052408 0.044569 0.042093 0.041494 [41] 0.047673 $\endgroup$ – Mahesh Maskey Jul 7 '15 at 19:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.