I am fairly new to statistics and R. I would like to know the process to determine the ARIMA parameters for my dataset. Can you help me figure out the same using R and theoretically (if possible)?

The data range from Jan-12 to Mar-14 and portrays the monthly sales. Here's the data set:

99 58 52 83 94 73 97 83 86 63 77 70 87 84 60 105 87 93 110 71 158 52 33 68 82 88 84

And here's the trend:

enter image description here

The data don't exhibit a trend, seasonal behavior or cyclicity.


4 Answers 4


In general, dig into an advanced time series analysis textbook (introductory books will usually direct you to just trust your software), like Time Series Analysis by Box, Jenkins & Reinsel. You may also find details on the Box-Jenkins procedure by googling. Note that there are other approaches than Box-Jenkins, e.g., AIC-based ones.

In R, you first convert your data into a ts (time series) object and tell R that the frequency is 12 (monthly data):

sales <- ts(c(99, 58, 52, 83, 94, 73, 97, 83, 86, 63, 77, 70, 87, 84, 60, 105, 87, 93, 110, 71, 158, 52, 33, 68, 82, 88, 84),frequency=12)

You can plot the (partial) autocorrelation functions:


These don't suggest any AR or MA behavior.

Then you fit a model and inspect it:

model <- auto.arima(sales)

See ?auto.arima for help. As we see, auto.arima chooses a simple (0,0,0) model, since it sees neither trend nor seasonality nor AR or MA in your data. Finally, you can forecast and plot the time series and forecast:



Look at ?forecast.Arima (note the capital A!).

This free online textbook is a great introduction to time series analysis and forecasting using R. Very much recommended.

  • $\begingroup$ Hi Stephan, I have added the data and the plot for my dataset. As you can see that I have only 27 data points, so I am running on fumes here. Could you suggest something here. $\endgroup$
    – Raunak87
    Jun 26, 2014 at 6:43
  • $\begingroup$ I edited the answer. Your series does not exhibit a lot of structure, so there is really little you can do. Since you essentially have noise and little else, you get large prediction intervals. $\endgroup$ Jun 26, 2014 at 6:53

Two things.Your time series is monthly,you need at least 4 years of data for a sensible ARIMA estimation, as reflected 27 points do not give the autocorrelation structure. This can also mean that your sales is affected by some external factors , rather than being correlated with its own value. Try to find out what factor affects your sales and is that factor being measured. Then you can run a regression or VAR (Vector Autoregression) to get forecasts.

If you absolutely don't have anything else other than these values , your best way is to use a exponential smoothing method to get a naive forecast. Exponential smoothing is available in R .

Secondly don't see the sales of a product in isolation, the sales of two products might be correlated for example increase in coffee sales can reflect decrease in tea sales. use the other product information to improve your forecast.

This typically happens with sales data in retail or supply chain. They dont show much of autocorrelation structure in the series. While on the other hand methods like ARIMA or GARCH typically work with stock market data or economic indices where you generally have autocorrelation.


This is really a comment but exceeds the allowable so I post it as a quasi-answer as it suggests the correct way to analyze time series data. .

The well-known fact but often ignored here and elsewhere is that the theoretical ACF/PACF which is used to formulate a tentative ARIMA model premises no Pulses/Level Shifts/Seasonal Pulses/Local Time Trends. Additionally it premises constant parameters and constant error variance over time. In this case the 21st observation (value=158) is easily flagged as an outlier/Pulse and a suggested adjustment of -80 yields a modified value of 78 . The resultant ACF/PACF of the modified series shows little or no evidence of stochastic (ARIMA) structure. In this case the operation was a success but the patient died. The sample ACF is based upon the covariance/variance and an unduly inflated/bloated variance yields a downwards bias to the ACF. Prof. Keith Ord once referred to this as the "Alice in Wonderland effect"


As it has been pointed out by Stephan Kolassa there is no much structure in your data. The autocorrelation functions do not suggest an ARMA structure (see acf(sales), pacf(sales)) and forecast::auto.arima does not choose any AR or MA order.

fit1 <- auto.arima(sales, d=0, D=0, ic="bic")
#ARIMA(0,0,0) with non-zero mean 
#      intercept
#        81.3704
#s.e.     4.4070

Nevertheless, notice that the null of normality in the residuals is rejected at the 5% significance level.

#X-squared = 12.9466, df = 2, p-value = 0.001544

Aside note: JarqueBera.test is based on function jarque.bera.test available in package tseries.

Including the additive outlier at observation 21 that is detected with tsoutliers renders normality in the residuals. Thus, the estimate of the intercept and the forecast are not affected by the outlying observation.

res <- tsoutliers::tso(sales, types=c("AO", "TC", "LS"), 
  args.tsmethod=list(ic="bic", d=0, D=0))
#ARIMA(0,0,0) with non-zero mean 
#      intercept     AO21
#        78.4231  79.5769
#s.e.     3.3885  17.6072
#sigma^2 estimated as 298.5:  log likelihood=-115.25
#AIC=236.49   AICc=237.54   BIC=240.38
#  type ind time coefhat tstat
#1   AO  21 2:09   79.58  4.52
#X-squared = 1.3555, df = 2, p-value = 0.5077
  • 1
    $\begingroup$ It doesn't make sense to use a Jarque Bera test with $n=12$, since (i) it relies on an asymptotic approximation that doesn't kick in until $n$ is well into the hundreds, and (ii) a formal hypothesis test really answers the wrong question (we know the data won't be exactly normal; the question is really how badly we might be affected by potential non-normality, which the test doesn't speak to. $\endgroup$
    – Glen_b
    Jun 26, 2014 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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