TimeSeriesForecast for a range

5

1

Now I have a tsm, say tsm=TimeSeriesModelFit[data]. Now, while using TimeSeriesForecast to forecast it, is there a way to let Mathematica only print the result in my desired range, say larger than 10 but smaller than 20.

Yincheng Liu

Posted 2015-11-26T16:25:35.397

Reputation: 309

Answers

6

Using some data from the documentation of TimeSeriesModelFit

data = {5., 9., 8., 10., 6.1, 10.4, 9.1, 11.6, 7.5, 12.1, 10.4, 13.5, 9., 14.1, 11.9, 15.7, 
  10.8, 16.4, 13.7, 18.3, 12.9, 19., 15.8, 21.2, 15.3, 22.1, 18.3, 24.6};

tsm = TimeSeriesModelFit[data];

tsf = TimeSeriesForecast[tsm, {10, 20}];

ListLinePlot[{TimeSeries[data], tsf}]

Plot1

tsf["Path"]
{{37, 36.7126}, {38, 31.2892}, {39, 41.3135}, {40, 33.7416}, {41, 44.8659}, 
 {42, 39.0431}, {43, 50.7289}, {44, 42.9233}, {45, 55.6801}, {46, 49.5727}, {47, 63.1753}}

Or

forecast = {#, tsm[#]} & /@ Range[37, 47]
{{37, 36.7126}, {38, 31.2892}, {39, 41.3135}, {40, 33.7416}, {41, 44.8659}, 
 {42, 39.0431}, {43, 50.7289}, {44, 42.9233}, {45, 55.6801}, {46, 49.5727}, {47, 63.1753}}
ListLinePlot[{TimeSeries[data], forecast}]

Plot2

Karsten 7.

Posted 2015-11-26T16:25:35.397

Reputation: 26 728

sorry my question is that, the mathematica will only output the result in my desired range... not the number of steps forward... – Yincheng Liu – 2015-12-01T08:07:14.497

@YinchengLiu Edited. – Karsten 7. – 2015-12-01T18:19:19.660