TimeSeriesAnalysis - Maple Programming Help

Home : Support : Online Help : Statistics and Data Analysis : Time Series Analysis Package : TimeSeriesAnalysis/LongestDefinedSubsequence

TimeSeriesAnalysis

 LongestDefinedSubsequence
 obtain a longest non-missing subsequence

 Calling Sequence LongestDefinedSubsequence(TS)

Parameters

 TS - TimeSeries object

Description

 • The LongestDefinedSubsequence command takes a time series and returns a longest contiguous subsequence of data where none of the data sets have missing values. For example, if TS is a TimeSeries object containing the following data:

$\mathrm{Matrix}\left(\left[\left[5.,3.,2.\right],\left[2.,\mathrm{Float}\left(\mathrm{undefined}\right),4.\right],\left[\mathrm{Float}\left(\mathrm{undefined}\right),5.,1.\right],\left[6.,2.,6.\right],\left[4.,4.,4.\right],\left[1.,3.,2.\right]\right]\right)$

then the 4th through 6th row of data will be returned. The value $\mathrm{Float}\left(\mathrm{undefined}\right)$ is used to represent missing data. (Data for time series is converted to floating point data, so any input of type undefined is converted to $\mathrm{Float}\left(\mathrm{undefined}\right)$ and subsequently considered missing.)

 • If there are multiple longest subsequences (of equal length), then LongestDefinedSubsequence returns an arbitrary one.

Examples

 > $\mathrm{with}\left(\mathrm{TimeSeriesAnalysis}\right):$

Consider the time series described above.

 > $\mathrm{ts}≔\mathrm{TimeSeries}\left(\mathrm{Matrix}\left(\left[\left[5.,3.,2.\right],\left[2.,\mathrm{Float}\left(\mathrm{undefined}\right),4.\right],\left[\mathrm{Float}\left(\mathrm{undefined}\right),5.,1.\right],\left[6.,2.,6.\right],\left[4.,4.,4.\right],\left[1.,3.,2.\right]\right]\right),\mathrm{headers}=\left["A","B","C"\right],\mathrm{frequency}=\mathrm{annual}\right)$
 ${\mathrm{ts}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{A, B, C}}\\ {\mathrm{6 rows of data:}}\\ {\mathrm{2010 - 2015}}\end{array}\right]$ (1)
 > $\mathrm{GetData}\left(\mathrm{ts}\right)$
 $\left[\begin{array}{ccc}{5.}& {3.}& {2.}\\ {2.}& {\mathrm{HFloat}}{}\left({\mathrm{undefined}}\right)& {4.}\\ {\mathrm{HFloat}}{}\left({\mathrm{undefined}}\right)& {5.}& {1.}\\ {6.}& {2.}& {6.}\\ {4.}& {4.}& {4.}\\ {1.}& {3.}& {2.}\end{array}\right]$ (2)
 > $\mathrm{ldts}≔\mathrm{LongestDefinedSubsequence}\left(\mathrm{ts}\right)$
 ${\mathrm{ldts}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{A, B, C}}\\ {\mathrm{3 rows of data:}}\\ {\mathrm{2013 - 2015}}\end{array}\right]$ (3)
 > $\mathrm{GetData}\left(\mathrm{ldts}\right)$
 $\left[\begin{array}{ccc}{6.}& {2.}& {6.}\\ {4.}& {4.}& {4.}\\ {1.}& {3.}& {2.}\end{array}\right]$ (4)

A second example.

 > $\mathrm{ts2}≔\mathrm{TimeSeries}\left(\left[2.1,\mathrm{undefined},2.5,2.4,\mathrm{undefined},\mathrm{undefined},3.2,2.4\right]\right)$
 ${\mathrm{ts2}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{data set}}\\ {\mathrm{8 rows of data:}}\\ {\mathrm{2008 - 2015}}\end{array}\right]$ (5)
 > $\mathrm{ldts2}≔\mathrm{LongestDefinedSubsequence}\left(\mathrm{ts2}\right)$
 ${\mathrm{ldts2}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{data set}}\\ {\mathrm{2 rows of data:}}\\ {\mathrm{2010 - 2011}}\end{array}\right]$ (6)
 > $\mathrm{GetData}\left(\mathrm{ldts2}\right)$
 $\left[\begin{array}{c}{2.50000000000000}\\ {2.40000000000000}\end{array}\right]$ (7)

Compatibility

 • The TimeSeriesAnalysis[LongestDefinedSubsequence] command was introduced in Maple 18.
 • For more information on Maple 18 changes, see Updates in Maple 18.