mcovarTopN#

swordfish.function.mcovarTopN()#

Within a sliding window of given length (measured by the number of elements), the function stably sorts X and Y by S in the order specified by ascending, then calculates the moving covariance of the first top pairs of elements in X and Y.

Parameters:
  • X (Constant) – A numeric vector or matrix.

  • Y (Constant) – A numeric vector or matrix.

  • S (Constant) – A numeric/temporal vector or matrix, based on which X are sorted.

  • window (Constant) – An integer greater than 1, indicating the sliding window size.

  • top (Constant) – An integer in (1, window], indicating the first top elements of X after sorted based on S.

  • ascending (Constant, optional) – A Boolean value indicating whether to sort S in ascending order. The default value is true.

  • tiesMethod (Constant, optional) –

    A string that specifies how to select elements if there are more elements with the same value than spots available in the top N after sorting X within a sliding window. It can be:

    • ’oldest’: select elements starting from the earliest entry into the window;

    • ’latest’: select elements starting from the latest entry into the window;

    • ’all’: select all elements.

    Note

    For backward compatibility, the default value of tiesMethod is ‘oldest’ for the following functions: mstdTopN, mstdpTopN, mvarTopN, mvarpTopN, msumTopN, mavgTopN, mwsumTopN, mbetaTopN, mcorrTopN, mcovarTopN; For the remaining mTopN functions, the default value of tiesMethod is ‘latest’.