TimeSeriesAnalysis
LongestDefinedSubsequence
obtain a longest non-missing subsequence
Calling Sequence
Parameters
Description
Examples
Compatibility
LongestDefinedSubsequence(TS)
TS
-
TimeSeries object
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:
Matrix⁡5.,3.,2.,2.,Float⁡undefined,4.,Float⁡undefined,5.,1.,6.,2.,6.,4.,4.,4.,1.,3.,2.
then the 4th through 6th row of data will be returned. The value Float⁡undefined 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 Float⁡undefined and subsequently considered missing.)
If there are multiple longest subsequences (of equal length), then LongestDefinedSubsequence returns an arbitrary one.
with⁡TimeSeriesAnalysis:
Consider the time series described above.
ts ≔ TimeSeries⁡Matrix⁡5.,3.,2.,2.,Float⁡undefined,4.,Float⁡undefined,5.,1.,6.,2.,6.,4.,4.,4.,1.,3.,2.,headers=A,B,C,frequency=annual
ts≔Time seriesA, B, C6 rows of data:2017 - 2022
GetData⁡ts
5.3.2.2.Float⁡undefined4.Float⁡undefined5.1.6.2.6.4.4.4.1.3.2.
ldts ≔ LongestDefinedSubsequence⁡ts
ldts≔Time seriesA, B, C3 rows of data:2020 - 2022
GetData⁡ldts
6.2.6.4.4.4.1.3.2.
A second example.
ts2 ≔ TimeSeries⁡2.1,undefined,2.5,2.4,undefined,undefined,3.2,2.4
ts2≔Time seriesdata set8 rows of data:2015 - 2022
ldts2 ≔ LongestDefinedSubsequence⁡ts2
ldts2≔Time seriesdata set2 rows of data:2017 - 2018
GetData⁡ldts2
2.500000000000002.40000000000000
The TimeSeriesAnalysis[LongestDefinedSubsequence] command was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
TimeSeries
Download Help Document
What kind of issue would you like to report? (Optional)