query: Query A Time Series Using a Sliding Window Approach

Description Usage Arguments Details Value References

Description

Queries a given time series using a sliding window and Spearman Ranking Correlation Coefficient for similarity assessment between each window and a given pattern.

Usage

1
2
3
Query(timeseries, pattern.template, distinctive.feature, ruleset,
  window.length = 1.2 * GetLengthInSeconds(pattern.template),
  spearmans.rho.threshold = 0.7, return.matched.patterns = FALSE)

Arguments

timeseries

The xts time series to be queried for the pattern

pattern.template

The xts time series that represents a template of the pattern being searched for. The first and last points in pattern.template (the endpoints) must be estimations of the time series BEFORE and AFTER the pattern has occured, otherwise it will not match.

distinctive.feature

Optional argument. A function of the form function(xts), which returns TRUE if the xts object matches the distinctive feature and FALSE otherwise. If the xts object is found not to contain the distincitive feature, the sliding window will move to the next offset without executing the PIPs algorithm. This is functionally identical to the ruleset parameter, except that it is executed BEFORE the PIPs and matching algorithms. Providing a low-complexity function to check for a distinctive feature of the desired pattern prior to identifying PIPs can significantly decrease run time. A quick and easy example of this might be to ensure the window exceeds some variance threshold. CAUTION: Providing a higher complexity function can result in increased run time.

Note: that errors in the distinctive feature function will be caught since there is no gaurantee for irregular time series that enough points will be found within each window to satisfy this user-defined function.

ruleset

Optional argument. A function of the form function(xts), which returns TRUE if the xts object matches the ruleset and FALSE otherwise.The xts parameter should be assumed to be the same length as the pattern.template (so if the pattern.template is length 10, do not make a reference to xts[11] in the distinctive.feature function) This is functionally identical to the distinctive.feature parameter, except that it is executed AFTER the PIPs and matching algorithms. Higher complexity rules should go here.

window.length

A numeric length (in seconds) for the sliding window, which the pattern.template will be matched against. Defaults to 1.2 times the length of the template pattern.

spearmans.rho.threshold

The numeric threshold used for the Spearman's rho similarity coefficient. This values should above 0 and less than 1. Setting this values closer to 1 ensures that only very similar time series segments will match. Arbitrarily defaults to 0.7.

return.matched.patterns

A logical value. TRUE makes the algorithm return each window that matched as a list of xts objects. FALSE returns a 1 x 2 data frame with columns "Patterns" = Number of patterns found, and "Errors" = number of exceptions thrown by the GetPIPs function (e.g., incidences of there being too few data points found in the window to identify enough PIPs). Defaults to FALSE.

Details

This package has a comprehensive vignette. Use vignette("TSPatternQuery") to view the "long-form" documentation.

Value

Either a list of matched windows or a data frame containing the number of matches and errors, depending on the return.matched.patterns parameter.

References

Zhe Zhang, Jian Jiang, Xiaoyan Liu, Ricky Lau, Huaiqing Wang, and Rui Zhang. A real time hybrid pattern matching scheme for stock time series. In Proceedings of the Twenty-First Australasian Conference on Database Technologies - Volume 104, ADC ’10, pages 161–170, Darlinghurst, Australia, Australia, 2010. Australian Computer Society, Inc.


joshmarsh/TSPatternQuery documentation built on May 19, 2019, 8:53 p.m.