tmcorrTopN

Syntax

tmcorrTopN(T, X, Y, S, window, top, [ascending=true], [tiesMethod=’latest’])

Please see Time-Based Moving TopN Functions (tmTopN functions) for the parameters and windowing logic.

Details

After stably sorting S in the specified ascending order, the function calculates the correlation of X and Y in a sliding window.

Return value: a vector of DOUBLE type

Examples

$ T=2023.01.03+1..7
$ X = [2, 1, 4, 3, 4, 3, 1]
$ Y=[1, 7, 8, 9, 0, 5, 8]
$ S = [5, 8, 1, , 1, 1, 3]
// The NULL values in S are ignored in data sorting, and the corresponding elements in X and Y do not participate in calculation
$ tmcorrTopN(T,X,Y,S,6,4)
[,-1,0.317,0.317,-0.16329,0.3296,-0.4995]

$ T=2023.01.03 2023.01.07 2023.01.08 2023.01.10 2023.01.11 2023.01.12
$ X=8 3 1 2 5 2
$ Y=1 7 8 9 0 5
$ S=1 5 2 3 1 1
$ t=table(T as time, X as val1, Y as val2, S as id)
$ select tmcorrTopN(time,val1,val2,id,4,3) as topN from t

topN

-1

-0.5

-0.9413

-0.8962

Related function: tmcorr