Message Boards Message Boards

0
|
9619 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Issue with TimeSeries in Mathematica 12.0

Posted 5 years ago

Using the example code "Building a Model for Forecasting Stock Prizes" (see https://www.wolfram.com/mathematica/new-in-10/time-series/build-a-model-for-forecasting-stock-prices.html) which was working before gives errors in Mathematica V12.0. The code is

data = FinancialData["SBUX", 
   "Close", {{2013, 1, 1}, {2013, 8, 1}, "Week"}, "Value"];
start = DayRound["Jan 1 2013", "BusinessDay", "Next"];
stocks = TimeSeries[data, {start, Automatic, "Week"}]
DateListPlot[stocks, Filling -> Axis]
eproc = TimeSeriesModelFit[stocks]
forecast = TimeSeriesForecast[eproc, {4}];
DateListPlot[{stocks, forecast}, Filling -> Axis]

The TimeSeries function stocks = TimeSeries[data, {start, Automatic, "Week"}] results in multiple error messages. First one and route cause is

DateListPlot::ldata: TimeSeries[TimeSeries[Time: 04 Jan 2013 to 01 Aug 2013 \[SpanFromLeft]
Data points: 31 \[SpanFromLeft]

],{DateObject[{2013,1,2},Day,Gregorian,2.],Automatic,Week}] is not a valid dataset or list of datasets.

If I remove the bracket {start, Automatic, "Week"} in TimeSeries everything seems to work with the exeption that I now get a message

TemporalData::rsmplng: The data is not uniformly spaced and will be automatically resampled to the resolution of the minimum time increment.

The resulting diagrams seem to be O.K.

Could not find any hint in the documentation. Therefore I appreciate any help from the experts.

Thanks, Walter

POSTED BY: Walter Haeffner
4 Replies

Hi Sean, Got it. Many thanks, Walter

POSTED BY: Walter Haeffner

In version 12, FinancialData has been updated to return a TimeSeries. So as other people noted, you don't need to manually construct a TimeSeries as you're currently doing.

stocks = FinancialData["SBUX", "Close", {{2013, 1, 1}, {2013, 8, 1}, "Week"}];
DateListPlot[stocks, Filling -> Axis]
eproc = TimeSeriesModelFit[stocks]
forecast = TimeSeriesForecast[eproc, {4}];
DateListPlot[{stocks, forecast}, Filling -> Axis]

Alternatively, you can ask FinancialData to behave as it did in 11.3:

FinancialData["SBUX", "Close", {{2013, 1, 1}, {2013, 8, 1}, 
  "Week"}, "Value", Method -> "Legacy"]

Or use

SetOptions[FinancialData, Method -> "Legacy"]

To make this option the default in your code.

POSTED BY: Sean Clarke

Financial data already returns a TimeSeries? I'm not sure why you construct a new TimeSeries?

FinancialData["SBUX", "Close", {{2013, 1, 1}, {2013, 8, 1}, "Week"}, "Value"]
POSTED BY: Sander Huisman

Yes, the same problem with me!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract