mimaxLast

Syntax

mimaxLast(X, window, [minPeriods])

Arguments

Please see mFunctions for the parameters and windowing logic.

Details

Return the position of the element with the largest value in X in a sliding window. If there are multiple elements with the identical largest value in a window, return the position of the first element from the right. Same as other aggregate functions, NULL values are ignored.

Examples

x = 1.2 2 NULL -1 6 -1
mimaxLast(x,3);
// output: [,,1,0,2,1]
m=matrix(3 2 4 4 2, 1 4 2 4 3);
mimaxLast(m,3) 
#0 #1

2 1
2 2
1 1
t=table(3 3 2 as c1, 1 4 4 as c2)
mimaxLast(t,3)
#0 #1

1 2
x = [NULL, 2, NULL, NULL, 3.2]
date = [0, 1, 3,  8, 9] + 2020.01.01
X = indexedSeries(date, x) 
mimaxLast(X, 3d)
#0
2020.01.01 -1
2020.01.02 1
2020.01.04 0
2020.01.09 -1
2020.01.10 1

Related function: mimax