So I am looking at unit sales data. I am doing a univariate time series analysis. My data is weekly sales numbers figures, spanning 2012- 2014 (obviously no till end 2014). I first ploted my response var against time.
I suspected trend and seasonality which would make sense. So I did a seasonal trend decompose with loess (STL). Here is the result.
However when I did a stationarity test on my original dataset, it gives me stationarity. And I tried Box-Ljung Philips-Perron unit root test augmented dicky fuller test with stationary and explosive as alternative both and kpss. Stationary. So why is it that my trend and sesonality not significant?
I assigned to every observation a month index and did boxplot(sales~month, data=???)
Here is the result:
Then asked myself if differences in mean were significant, they were not. I tried aov pairwise.t.test and TuckeyHD. even if difference in mean for some means was important, overall not. Could I say then that no significant trend and seasonality appears in the dataset and model with an ARIMA? Also I have only 156 observations in my dataset.
Here is the acf and pacf what ARMA would you specify? if ARMA at all.
I am really at loss it is the first time I see a staionary raw sales figure.
Solved – raw data stationary but still can see trend and seaonality is stl
armaseasonalitystationarity
Best Answer
This is what I get using the R package forecast for ARIMA model selection and tsoutliers for detection of possible additive outliers, level shifts or temporary changes.
These are the data:
Fit an ARIMA model:
The data are fitted by a stationary AR(2) model with some outliers summarized in the output. According to this model, a cyclic behaviour rather than seasonality is observed in the data.
These are the residuals from the fitted model.
$\quad$
Autocorrelations of the residuals:
The autocorrelations of the residuals reveal the significance of the lag of order 52 (one year lag). One way to incorporate this lag is to define it as follows:
and pass
xlag52
through argumentxreg
in functiontso
orarima
. However, probably because the sample is small for such lag, the algorithm run into difficulties when fitting an ARIMA model.Edit
The idea of seasonal dummies mentioned by @IrishStat is much more appropriate than trying to add a lag of order 52. You can use these functions of the
forecast
package:seasonaldummies
to generate seasonal dummies orfourier
to generate the trigonometric representation of seasonal dummies. For illustration and as a complement to the results already shown by @IrishStat, below I show what I get using the first 10 components of the seasonal cycles.This yields the following residuals
Now, we can see that the autocorrelations of order 52 are less prominent in the residuals.
The following estimate of the seasonal pattern is obtained:
Finally, as you used R for the results shown in you question, if you want to work with the model proposed by @IrishStat, you can do the following: