object representing time series data
list, Vector, or Matrix of numbers, or another TimeSeries object
(optional) equations of the form optionname = value, described later
TimeSeries object, constructed using, for example, the first calling sequence
range of the form start .. end, where start and end are either integers or strings
integer, string, or range of integers or strings, or list of these
non-empty sequence of integers
algebraic expression or list of algebraic expressions
boolean expression or list of boolean expressions
headers = string or list of strings or a positive integer
Names for the data sets. If a single string is given and there is more than one data set, then the names for the data sets are obtained by appending the numbers 1, 2, and so on, to that string. A name or list of names can be given instead of a string or list of strings. If a positive integer is given, the data argument must be a list of lists or a Matrix; the integer is taken to be a row number. In this case, the contents of that row form the names of the data sets, and that row and all rows above it are discarded. If no headers are given and data is a TimeSeries object, the headers are copied from data. If no headers are given and data is not a TimeSeries object, the string "data set" is used.
This option can be specified as header (singular), rather than headers (plural) - there is no difference between the two.
dates = list or Vector of strings or numbers, or a single positive integer
This option specifies the time points corresponding to the data. If you specify strings, they will be parsed as described below, at the format option. If you specify a list or Vector of numbers, they will be interpreted as "seconds since the epoch" - that is, number of seconds elapsed since midnight, January 1st, 1970. If you specify a single positive integer m (not as a list or Vector), it will be taken to mean that the mth column of the data argument contains the date information. In this case, data must be a Matrix or a list of lists.
Maple cannot deal with dates before December 14, 1901, or dates after January 17, 2038.
The dates option cannot be combined with any of the frequency, startdate, and enddate options.
frequency = a positive integer or one of the keywords annual, yearly, quarterly, monthly, weekly, daily, and hourly (as name or string)
startdate = string
enddate = string
These three options give a few alternative methods of specifying the time points corresponding to the data. If using these options, you can use at most two of the three options. The options cannot be combined with the dates option.
If the frequency option is given as a positive integer, it represents a time interval of that number of seconds. The keywords represent the time intervals that they take their name from; annual and yearly mean exactly the same.
The startdate and enddate options are parsed as explained below, at the format option.
If the startdate and enddate options are given, then the interval between the two time points is divided into n−1 intervals (where n is the number of rows in data) that are as close as possible to evenly sized, and every boundary between intervals as well as the start and end dates are taken as time points. If startdate and frequency options are given, then the time points start at the given start date and continue with the given frequency. If the enddate and frequency options are given, the time points end at the given end date and are counted backwards in time according to the frequency options.
If only the startdate or only the enddate option is given, then frequency is by default set to annual, except if a higher frequency is needed to make all dates fall within the range between December 14, 1901 and January 14, 2038. If only the frequency is given, then enddate is set to one year before the current date.
If frequency is specified as annual or yearly or quarterly or monthly, then the increments are not fixed numbers of seconds; they take leap years and the varying lengths of months into account.
format = string or the names deduce or default, or a list of any of these values
All dates specified are parsed by the command StringTools[ParseTime]. The format option determines the format string used for that command. This applies to dates specified with the dates, startdate, and enddate options.
If a single string is specified, then it is the format string used for parsing.
If the name default is given, Maple uses the value stored by the Finance package with FinanceSettings⁡dateformat, which is "%B %e, %Y" by default, matching strings such as "January 1, 2000".
If the name deduce is given, Maple tries the same sequence of formats as the command Finance[ParseDate].
If a list is given, then first any occurrence of default and deduce are replaced by the format or sequence of formats that they represent, and then each format in the resulting list is tried in turn.
If dates are not specified through any options and data is a TimeSeries object, then the dates are copied from data. Otherwise, it is as if frequency was specified as annual and enddate was specified as one year before the current date, with the format "%Y" - that is, only the year is printed.
period = positive integer
If there is potentially a seasonal aspect to the time series, you can specify the length of the season with this parameter. It is expressed as the number of data points that constitute one period. For example, monthly data will often have annual seasonality; that would correspond to the option period = 12. For non-seasonal data, period = 1 is used.
If the period option is not specified, then its default value depends on the frequency option. It is given by the following table:
default for period
The TimeSeries command creates a time series object, for use with the TimeSeriesAnalysis package. A TimeSeries object contains one or more sets of data, measured at one set of time points.
The data argument is required. It contains the actual numbers making up the data sets. If the object is to represent a single set of data, then data can be given as a list or Vector of numbers. If the object is to represent k sets of data, it can be given as a list of k equally long lists of numbers, or a Matrix of numbers with k columns. Alternatively, you can use a pre-existing TimeSeries data set object to give the data.
In the computations of the TimeSeriesAnalysis package, time intervals are all treated as equal - that is, if you specify time points that are irregularly spaced, this information is used only for purposes such as supplying appropriate tickmarks on the axes for graphs.
The TimeSeries methods help page describes the commands that can be used to interrogate TimeSeries objects.
If you construct a time series object TS, you can index it as TS[rows] or TS[rows, columns] to get a new time series object representing a subset of the data.
Selecting rows is done using a range of the form start .. end, where start indicates the first row to be selected and end indicates the last.
If start or end is a positive integer, it indicates the number of the row, counting the earliest row of data as 1 and counting up for later rows (2,3,...).
If start or end is a negative integer, it indicates the number of the row, counting the last row of data as −1 and counting down for earlier rows (−2,−3,...).
If start or end is missing, for example in the ranges TS..5,TS−5..,TS.., then they are taken as 1 and −1, respectively. That is, if start is missing, the range starts at the beginning, and if end is missing, the range ends at the end.
If start or end is a string, Maple interprets it as a date in the format selected for this time series. The range then includes all data points later than or equal to the given time (for start), or before or equal to the given time (for end).
Selecting columns can be done with a string, an integer, a range of strings or integers, or a list of strings, integers, or ranges.
A positive integer selects the given column number, counting from left to right.
A negative integer selects the given column number, counting −1 as the rightmost column and counting down as you move left.
A string selects the column with the given header ("name"). The string has to be an exact match. If there are multiple columns with the same header (which is inadvisable), the first column with this header is selected.
A range selects all columns from the left hand side to the right hand side of the range, inclusive.
A list selects all columns included in the list.
To select some columns but not restrict the rows, you can use TS..,columns. Specifying .. for the rows selects all rows.
Columns can also be selected by indexing with a sequence of integers, as in TS[columnseq]. Positive and negative integers work as described above. The resulting TimeSeries will have columns in the same order as the sequence.
A TimeSeries with new data can be created with TS[rows, algexps], where algexps is an algebraic expression or a list of algebraic expressions, where the indeterminates are the headers of the columns, as names.
The rows of the new TimeSeries are computed from algexps by substituting the column names with the value from that column from the same row. For example, if one column of a TimeSeries object TS has header "revenue" and another column has header "costs", you can create a new TimeSeries with a column that is the difference between these values with TS[.., 'revenue' - 'costs'].
Since the headers are used as names, they need to be enclosed in backticks (`) if they include characters that are not normally part of Maple names, such as spaces. In the previous example, if the columns headers are "gross revenue" and "costs (parts)" instead, you can use TS[.., `gross revenue` - `costs (parts)`].
The columns of the new TimeSeries are in the same order as the expressions in algexps.
The column headers of the new TimeSeries are the default headers, as described in the discussion of the headers option.
The rows of a TimeSeries can be filtered with TS[boolexps] or TS[boolexps, columns], where boolexps is a Boolean expression or a list of Boolean expressions, where the indeterminates are the headers of the columns, as names.
For each row, the column names in boolexps are substituted with the value from that column in the same row. The values of that row are retained if and only if all expressions in boolexps is satisfied. For example, if a column of a TimeSeries object TS has header "profit", you can select the rows of TS with profits less than 1000 with TS['profit' < 1000].
Since the headers are used as names, they need to be enclosed in backticks (`) if they include characters that are not normally part of Maple names, such as spaces. In the previous examples, if the column is called "gross profit", you can select rows with TS[`gross profit` < 1000].
If one expression in boolexps is not satisfied, then the values in that row becomes undefined.
A simple time series object.
t1≔Time seriesdata set3 rows of data:2017 - 2019
The same data, but now specifying the header and the times.
t2≔Time seriesMonthly sales3 rows of data:2013-01-31 - 2013-03-31
A time series with three data sets.
t3≔Time seriesRegion 1, Region 2, Region 34 rows of data:March:2006:08 - May:2006:10
Region 1,Region 2,Region 3
Time series as a plot.
You can select the data for regions 1 and 3 only.
t3a≔t3..,Region 1,Region 3
t3a≔Time seriesRegion 1, Region 34 rows of data:March:2006:08 - May:2006:10
Next, select the rows corresponding to March and April of region two.
t3b≔Time seriesRegion 23 rows of data:March:2006:08 - April:2006:19
Taking a quality measurement every minute, for one day.
t4≔TimeSeries⁡s,startdate=2013-11-06 00:00,frequency=60,format=%Y-%m-%d %H:%M,header=Quality
t4≔Time seriesQuality1440 rows of data:2013-11-06 00:00 - 2013-11-06 23:59
2013-11-06 00:002013-11-06 00:012013-11-06 00:022013-11-06 00:032013-11-06 00:042013-11-06 00:052013-11-06 00:062013-11-06 00:072013-11-06 00:082013-11-06 00:09
You can select the quality measurements starting at 6pm and exclude the last ten measurements.
t4a≔Time seriesQuality350 rows of data:2013-11-06 18:00 - 2013-11-06 23:49
Hourly data is by default considered potentially seasonal with a period of one day.
t5≔TimeSeries⁡s,startdate=2010-01-01 00:00,format=%Y-%m-%d %H:%M,frequency=hourly
t5≔Time seriesdata set1440 rows of data:2010-01-01 00:00 - 2010-03-01 23:00
You can override this parameter if you expect that assuming seasonality with a period of 12 hours can give a better model, such as in the case of tidal information.
t6≔TimeSeries⁡s,startdate=2010-01-01 00:00,format=%Y-%m-%d %H:%M,frequency=hourly,period=12
t6≔Time seriesdata set1440 rows of data:2010-01-01 00:00 - 2010-03-01 23:00
Selecting columns with a sequence of integers.
t7≔Time seriesa, b, c3 rows of data:2017 - 2019
Creating a TimeSeries with new data from existing TimeSeries.
Filtering the rows of a TimeSeries.
t8≔Time seriesa, b4 rows of data:2016 - 2019
The TimeSeriesAnalysis[TimeSeries] command was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
The TimeSeriesAnalysis[TimeSeries] command was updated in Maple 2015.
Download Help Document
What kind of issue would you like to report? (Optional)