object representing time series data - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics : Time Series Analysis Package : TimeSeriesAnalysis/TimeSeries

TimeSeriesAnalysis[TimeSeries] - object representing time series data

Calling Sequence

TimeSeries(data, opts)

TS[rows]

TS[rows, columns]

TS[columnseq]

TS[rows, algexps]

TS[boolexps]

TS[boolexps, columns]

Parameters

data

-

list, Vector, or Matrix of numbers, or another TimeSeries object

opts

-

(optional) equations of the form optionname = value, described later

TS

-

TimeSeries object, constructed using, for example, the first calling sequence

rows

-

range of the form start .. end, where start and end are either integers or strings

columns

-

integer, string, or range of integers or strings, or list of these

columnseq

-

non-empty sequence of integers

algexps

-

algebraic expression or list of algebraic expressions

boolexps

-

boolean expression or list of boolean expressions

Description

• 

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.

Indexing

• 

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,TS5..,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.

Examples

withTimeSeriesAnalysis&colon;

A simple time series object.

t1:=TimeSeries4&comma;5&comma;6

t1:=Time seriesdata set3 rows of data:2012 - 2014

(1)

GetDatat1

4.5.6.

(2)

GetDatest1

201220132014

(3)

GetHeaderst1

data set

(4)

The same data, but now specifying the header and the times.

t2:=TimeSeries4&comma;5&comma;6&comma;&apos;header&apos;&equals;Monthly sales&comma;&apos;startdate&apos;&equals;2013-01-31&comma;&apos;frequency&apos;&equals;monthly

t2:=Time seriesMonthly sales3 rows of data:2013-01-31 - 2013-03-31

(5)

GetDatat2

4.5.6.

(6)

GetDatest2

2013-01-312013-02-282013-03-31

(7)

GetHeaderst2

Monthly sales

(8)

A time series with three data sets.

t3:=TimeSeries5&comma;6&comma;7&comma;8&comma;3&comma;4&comma;5&comma;6&comma;2&comma;3&comma;4&comma;5&comma;&apos;headers&apos;&equals;Region&comma;&apos;dates&apos;&equals;March:2006:08&comma;March:2006:29&comma;April:2006:19&comma;May:2006:10&comma;&apos;format&apos;&equals;%B:%Y:%d

t3:=Time seriesRegion 1, Region 2, Region 34 rows of data:March:2006:08 - May:2006:10

(9)

GetDatat3

5.3.2.6.4.3.7.5.4.8.6.5.

(10)

GetDatest3

March:2006:08March:2006:29April:2006:19May:2006:10

(11)

GetHeaderst3

Region 1&comma;Region 2&comma;Region 3

(12)

Time series as a plot.

TimeSeriesPlott3

You can select the data for regions 1 and 3 only.

t3a:=t3..&comma;Region 1&comma;Region 3

t3a:=Time seriesRegion 1, Region 34 rows of data:March:2006:08 - May:2006:10

(13)

TimeSeriesPlott3a

Next, select the rows corresponding to March and April of region two.

t3b:=t3March:2006:01..April:2006:30&comma;2

t3b:=Time seriesRegion 23 rows of data:March:2006:08 - April:2006:19

(14)

Taking a quality measurement every minute, for one day.

s:=Statistics:-SampleChiSquare2&comma;6024

s:= 1 .. 1440 VectorrowData Type: float8Storage: rectangularOrder: Fortran_order

(15)

t4:=TimeSeriess&comma;&apos;startdate&apos;&equals;2013-11-06 00:00&comma;&apos;frequency&apos;&equals;60&comma;&apos;format&apos;&equals;%Y-%m-%d %H:%M&comma;&apos;header&apos;&equals;Quality

t4:=Time seriesQuality1440 rows of data:2013-11-06 00:00 - 2013-11-06 23:59

(16)

GetDatat41..10

8.235697157001372.869894918727520.9063874852033426.666174153330700.9128865746755880.1275448006320280.2906881141505920.4228684541177757.2373555725882410.9349083968833

(17)

GetDatest41..10

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

(18)

GetHeaderst4

Quality

(19)

You can select the quality measurements starting at 6pm and exclude the last ten measurements.

t4a:=t42013-11-06 18:00..11

t4a:=Time seriesQuality350 rows of data:2013-11-06 18:00 - 2013-11-06 23:49

(20)

Hourly data is by default considered potentially seasonal with a period of one day.

t5:=TimeSeriess&comma;&apos;startdate&apos;&equals;2010-01-01 00:00&comma;&apos;format&apos;&equals;%Y-%m-%d %H:%M&comma;&apos;frequency&apos;&equals;hourly

t5:=Time seriesdata set1440 rows of data:2010-01-01 00:00 - 2010-03-01 23:00

(21)

GetPeriodt5

24

(22)

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:=TimeSeriess&comma;&apos;startdate&apos;&equals;2010-01-01 00:00&comma;&apos;format&apos;&equals;%Y-%m-%d %H:%M&comma;&apos;frequency&apos;&equals;hourly&comma;&apos;period&apos;&equals;12

t6:=Time seriesdata set1440 rows of data:2010-01-01 00:00 - 2010-03-01 23:00

(23)

GetPeriodt6

12

(24)

Selecting columns with a sequence of integers.

t7:=TimeSeries1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;7&comma;8&comma;9&comma;headers&equals;a&comma;b&comma;c

t7:=Time seriesa, b, c3 rows of data:2012 - 2014

(25)

GetDatat72

4.5.6.

(26)

GetDatat72&comma;3

4.1.5.2.6.3.

(27)

Creating a TimeSeries with new data from existing TimeSeries.

GetDatat7..&comma;&apos;a&apos;&plus;&apos;b&apos;

5.7.9.

(28)

GetDatat7..&comma;&apos;b&apos;&apos;a&apos;&comma;&apos;a&apos;&plus;&apos;b&apos;

3.5.3.7.3.9.

(29)

Filtering the rows of a TimeSeries.

t8:=TimeSeries1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;7&comma;8&comma;headers&equals;a&comma;b

t8:=Time seriesa, b4 rows of data:2011 - 2014

(30)

GetDatat8&apos;b&apos;6

1.5.HFloatundefinedHFloatundefined3.7.4.8.

(31)

GetDatat8&apos;b&apos;6&comma;4&apos;a&apos;

1.5.HFloatundefinedHFloatundefined3.7.HFloatundefinedHFloatundefined

(32)

See Also

Statistics[AutoCorrelation], Statistics[CrossCorrelation], TimeSeries methods


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam