# Deseasonalize the data of traffic growth for the past data

In another question (Using TimeSeriesForecast for forecasting the traffic growth) I asked to use the TimeSeriesForecast on this set of data the answer provided the plot with and without the seasonalization for the future value.

Is it possible to get the same plot (without seasonalization) for data which are already available (now this is only for the forecasted one)?

EDIT

The SARIMA model has the seasonal peaks. Is it possible to calculate the same model also for the range of dates on which I provided the data?

If that is possible maybe I could use the model of the periodic peaks to modulate the real data getting rid of the data seasonality.

What I would be curious to get is not a regression (which would be a flat line) but the deseasonalized data.

• What is stagionalization? Mar 26, 2015 at 12:05
• @Pickett: sorry, my english is terrible. I meant seasonalization, I will correct. Thanks for telling me. Mar 26, 2015 at 12:28
• I'm not sure what you mean with deseasonalized without making a regression. Do you mean filtering or smoothing? Or something like this, this or this, which are all different kinds of regressions? Mar 26, 2015 at 12:38
• @Karsten7. I am not sure if what I want can be achieved. I will edit the question. ps: how did you managed to get the 3 images? Mar 26, 2015 at 13:44
• The last one was created using something like what I show in my answer. The other two were produced by fitting a function, that is not a straight line, to the data (, but this is still doing a linear regression). Mar 26, 2015 at 15:31

Removing seasonality by using MeanFilter:

data = MapAt[DateString[{#, {"Day", "/", "Month", "/", "Year"}}] &,
Import["D:\\Analytics www.superinformati.com Panoramica del pubblico 20141201-20150303 - Sheet 1.tsv"][[3 ;;, {1, 2}]]
, {All, 1}]

DateListPlot[{data,
Transpose[{data[[All, 1]], MeanFilter[data[[All, 2]], 7]}]}]


• I used a range of 7 for the MeanFilter, as the SARIMA model revealed a seasonal order of 7 and because assuming a weekly seasonality makes sense. Mar 26, 2015 at 16:30
• Thanks a lot. And really great job, if you want there is also a last question mathematica.stackexchange.com/questions/78311/… Mar 26, 2015 at 17:19
• How could you see that the seasonality is 7 days? May 7, 2015 at 20:06

Your description of what you want to do is quite vague and the "not a regression" part is kind of contradictory. Therefore I'll take

"Is it possible to calculate the same model also for the range of dates on which I provided the data?"

Importing your data saved in TSV format

data = MapAt[DateString[{#, {"Day", "/", "Month", "/", "Year"}}] &,
Import["D:\\Analytics www.superinformati.com Panoramica del pubblico 20141201-20150303 - Sheet 1.tsv"][[3 ;;, {1, 2}]]
, {All, 1}]


Finding the SARIMA process

tsm = TimeSeriesModelFit[data]


One can use RandomFunction to create multiple simulations assuming a random process. The following code produces 5 simulations. I use Length@data - 30 because your data looks like the real trend starts somewhere after 30 days.

rf1 = RandomFunction[tsm["BestFit"], {Length@data - 30}, 5]


Creating a plot of these simulations and of their mean

randomP1 =
DateListPlot[Transpose[{data[[30 ;;, 1]], #}] & /@ rf1["States"],
PlotStyle -> Opacity[1/2],
PlotRange -> {{data[[1, 1]], data[[-1, 1]]}, Automatic}]

meanP1 = DateListPlot[
PlotStyle -> Red, PlotRange -> {{data[[1, 1]], data[[-1, 1]]}, Automatic}]


Putting everything into one plot

Show[{randomP1,
DateListPlot[data, PlotStyle -> Directive[Black, Thick]],
meanP1}]


Doing the same using a ARIMA model

tsm2 = TimeSeriesModelFit[data, "ARIMA"]

rf2 = RandomFunction[tsm2["BestFit"], {Length@data - 30}, 5]

randomP2 =
DateListPlot[Transpose[{data[[30 ;;, 1]], #}] & /@ rf2["States"],
PlotStyle -> Opacity[1/2],
PlotRange -> {{data[[1, 1]], data[[-1, 1]]}, Automatic}]

meanP2 = DateListPlot[