5
$\begingroup$

I'm in the process of becoming familiar with some on the version 10 new functionality. I have two data sets, datasetA and datasetC, of time series data that I would like to make forecasts on. Here is datasetA.

datasetA = {{0., 16.2}, {0.5, 20.}, {1., 19.}, {1.5, 28.5}, {2., 
17.8}, {2.5, 23.3}, {3., 19.9}, {3.5, 13.5}, {4., 20.1}, {4.5, 
11.8}, {5., 29.8}, {5.5, 26.9}, {6., 32.3}, {6.5, 16.5}, {7., 
31.7}, {7.5, 24.2}, {8., 37.1}, {8.5, 25.9}, {9., 28.1}, {9.5, 
35.6}, {10., 27.4}, {10.5, 30.4}, {11., 29.4}, {11.5, 29.3}, {12.,
 29.4}, {12.5, 29.1}, {13., 31.4}, {13.5, 24.}, {14., 
30.9}, {14.5, 43.1}, {15., 28.7}, {15.5, 38.8}, {16., 
37.9}, {16.5, 34.8}, {17., 26.5}, {17.5, 44.4}, {18., 
39.2}, {18.5, 44.6}, {19., 26.9}, {19.5, 51.1}, {20., 34.}, {20.5,
 42.6}, {21., 38.7}, {21.5, 45.1}, {22., 56.}, {22.5, 54.3}, {23.,
 47.7}, {23.5, 48.6}, {24., 48.4}, {24.5, 47.1}, {25., 
45.4}, {25.5, 44.7}, {26., 35.7}, {26.5, 36.6}, {27., 
52.8}, {27.5, 56.6}, {28., 60.8}, {28.5, 58.4}, {29., 
52.7}, {29.5, 49.1}, {30., 44.8}};

And here is my attempt at modeling it with a SARIMA time series model, with the corresponding plot of the above data and a 30 day forecast.

tsmA = TimeSeriesModelFit[datasetA, {"SARIMA", Automatic}]
plot2 = ListLinePlot[{tsmA["TemporalData"], 
TimeSeriesForecast[tsmA, {70}]}, Frame -> True, 
FrameLabel -> {"Time (days)", "Output"}, 
PlotLabel -> "Plot 2 \nModel: tsmA with Forecast", 
PlotLegends -> {"data", "forecast"}]

enter image description here

So far so good as this forecast looks reasonable.

Here is datasetC, my attempt at modeling it and its forecast.

datasetC = {{0., 25.2}, {0.5, 18.4}, {1., 22.1}, {1.5, 21.5}, {2., 
20.7}, {2.5, 33.}, {3., 15.3}, {3.5, 24.4}, {4., 33.7}, {4.5, 
37.4}, {5., 31.8}, {5.5, 23.5}, {6., 30.2}, {6.5, 24.6}, {7., 
21.1}, {7.5, 27.7}, {8., 35.5}, {8.5, 29.3}, {9., 34.1}, {9.5, 
30.1}, {10., 27.6}, {10.5, 34.4}, {11., 34.9}, {11.5, 37.9}, {12.,
 40.5}, {12.5, 31.9}, {13., 37.5}, {13.5, 36.5}, {14., 
25.4}, {14.5, 28.}, {15., 41.2}, {15.5, 36.6}, {16., 33.5}, {16.5,
 37.1}, {17., 22.7}, {17.5, 37.5}, {18., 48.8}, {18.5, 
39.7}, {19., 47.5}, {19.5, 38.1}, {20., 30.9}, {20.5, 50.9}, {21.,
 43.9}, {21.5, 39.4}, {22., 44.1}, {22.5, 45.7}, {23., 
38.6}, {23.5, 57.}, {24., 46.}, {24.5, 49.5}, {25., 38.}, {25.5, 
49.}, {26., 46.1}, {26.5, 55.5}, {27., 47.7}, {27.5, 49.2}, {28., 
51.4}, {28.5, 50.2}, {29., 57.3}, {29.5, 53.}, {30., 46.2}};

tsmC = TimeSeriesModelFit[datasetC, {"SARIMA", Automatic}]
plot6 = ListLinePlot[{tsmC["TemporalData"], 
TimeSeriesForecast[tsmC, {70}]}, Frame -> True, 
FrameLabel -> {"Time (days)", "Output"}, 
PlotLabel -> "Plot 6 \nModel: tsmC with Forecast", 
PlotLegends -> {"data", "forecast"}]

enter image description here

This forecast does not look reasonable. Can someone explain why this is and how I might produce a better forecast ? Eventually, I would like to produce a 90% prediction interval on the forecasts. Thanks.

$\endgroup$
  • 1
    $\begingroup$ Why does the first looks "reasonable" to you and the second "unreasonable" ? $\endgroup$ – eldo Aug 9 '14 at 20:42
  • $\begingroup$ The forecast of Plot 2 seems to capture the positive and negative amplitudes around the dominant trend much better than that of Plot 6 where the amplitudes are much smaller than its associated data. $\endgroup$ – Steve Aug 9 '14 at 21:45
  • $\begingroup$ @Verbeia, thank you very much for your answer, you've given me a few things to think about. It very well could be that the model structure I'm assuming is not optimal for datasetC as I am learning time series methods at the same time with the implementation of those methods by Mathematica. If you can suggest a better approach to model datasetC that would be much appreciated. I take it that you are happy with the model of datasetA ? $\endgroup$ – Steve Aug 10 '14 at 13:20
4
$\begingroup$

I am not so sure that this is an unreasonable forecast given the model structure you have assumed. Mathematica does not make it easy to extract fitted values from the model using the model["SomeProperty'] construct, which is a pity. (Or maybe I missed that bit in the documentation.) When you check the best fit model, it is clear that the seasonal MA component is negative, so a lot of the fit in the sample washes out in the forecast period.

tsmC["BestFit"]
(* SARIMAProcess[2.61954, {}, 0, {}, {6, {0.134168}, 1, {-0.822867}}, 36.8536] *)

And the regular seasonal component just isn't that strong. It seems that there is simply a fair bit of irregular noise in the data that by definition doesn't persist into the forecasts.

 ListLinePlot@tsmC["FitResiduals"]

enter image description here

plot7 = ListLinePlot[{tsmC["TemporalData"], 
   Table[{x, tsmC[x]}, {x, 0, 30}], TimeSeriesForecast[tsmC, {70}]}, 
  Frame -> True, FrameLabel -> {"Time (days)", "Output"}, 
  PlotLabel -> "Plot 6 \nModel: tsmC with Forecast", 
  PlotLegends -> {"data", "fitted", "forecast"}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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