# Sales forecast using SARIMAProcess and time-series data

I would like to ask for help in how to use the new Mathematica 9 time series functions to make some sales forecast.

For example, for one of our stores, I have this data set with 35 points, from January 2010 to November 2012 with sales in

salesData = {5.14, 5.32, 6.04, 5.84, 6.09, 6.03, 5.79, 6.26, 5.91, 6.44, 6.54, 7.76, 6.24, 6.19, 6.37, 6.72, 6.72, 6.52, 6.64, 6.96, 6.51, 7.03, 6.79, 8.11, 6.82, 6.96, 7.85, 7.68, 7.80, 7.80, 7.80, 8.22, 8.19, 8.67, 8.29}


If I plot it with DateListPlot as below:

DateListPlot[salesData
,{2010,1}
,Joined-> True
,AspectRatio->0.2
,DateTicksFormat->{"MonthShort","/","YearShort"}
,PlotLabel->Style["Sales Chart",18,Bold,Blue]
,ImageSize->800
]


I get:

My question is:

How do I use SARIMAProcess, TemporalData and TimeSeriesForecast to get the forecast and the prediction band with some confidence interval as in this picture?

In this case, the series shows seasonality by year and this is the reason I know that the S in (S)ARIMA is necessary.

I'm new to time series, so if possible, I would like to have didactical answer. I am vague on the meaning of the SARIMA coefficients and how to determine them.

• Are you missing comma between between -3 and -4 elements in salesData ? Dec 16, 2012 at 3:05
• This is not my area of expertise but I do have some interest in this for something I plan to work on next year. I don't have 9 installed though. Have you tried mimicking the Lake Mead example in the docs? Dec 16, 2012 at 3:12
• BTW does anyone know how the seasonal function(s) in Mma compare to the US Census Bureau X-12-ARIMA seasonal adjustment software -- which seems to be very commonly used, if not the standard for seasonal adjusting. Dec 16, 2012 at 3:13
• @VitaliyKaurov tks, list corrected. Dec 16, 2012 at 3:28
• @MikeHoneychurch Yes! But I don't know from where come the model part SARIMAProcess[{.8}, 0, {-.4}, {12, {.2}, 1, {.3}}, 4.12]. Dec 16, 2012 at 3:29

After some study, I think that I found out how to answer it using:

data = TemporalData[salesData,{{2010,1},{2012,11},"Month"}];
proc=EstimatedProcess[salesData,SARIMAProcess[{},1,{},{12,{a},1,{b}},v]];
forecast=TimeSeriesForecast[proc, data,{14}];

DateListPlot[N@{data["Path"],forecast["Path"]}
,AspectRatio->0.2
,Joined-> True
,PlotStyle -> Thick
]


For the error band I used:

errors=forecast["MeanSquaredErrors"];
bound=Sqrt[Last[proc]] Sqrt[errors["PathStates",1]] Quantile[NormalDistribution[],1-1/2 (1-.95)];
bounds=TemporalData[{forecast["PathStates",1]-bound,forecast["PathStates",1]+bound},{{forecast["Times"]},{forecast["Times"]}}];

DateListPlot[N@{data["Path"],forecast["Path"],Sequence@@bounds["Paths"]}
,Joined-> True
,AspectRatio->0.2
,Filling->{3->{{4},LightRed}}
,PlotStyle->{Thick,Blue,Sequence@@ConstantArray[Darker[Red],3]}
]


Now I have just to understand better the meaning of the SARIMAProcess terms. Why I use SARIMAProcess[{},1,{},{12,{a},1,{b}},v] instead of SARIMAProcess[{p},1,{q},{12,{a},1,{b}},v] or something else, I still don't know. But it's a Math problem, not a Mathematica one.

• Someone know how to easily put date ticks with month and year as the original? I have some difficult. Dec 18, 2012 at 2:02
• it looks like your temporal data has no times! Consider news = {DateList[{2010, #, 0, 0, 0, 0}], salesData[[#]]} & /@ Range[Length@salesData]; newt = TemporalData[news] DateListPlot[newt["Paths"]]
– dwa
Dec 18, 2012 at 2:25
• @dwa Tks! Corrected. Dec 18, 2012 at 14:52
• SPSS 'Expert Modeler' gives Holt model as the best model with your data. The stationary R ^2 Value was 0.837 However I have no idea about using Holt model in Mathematica Dec 21, 2012 at 8:26
• @rselva tks. I'm still studying how to perform it on Mathematica. :) Dec 21, 2012 at 8:32