This function computes a running/rolling percentage rank.
runPercentRank(x, n = 260, cumulative = FALSE, exact.multiplier = 0.5)
A object of percent ranks over a n-period moving window of the same
class as x
and y
or a vector (if try.xts
fails).
Object coercible to xts or matrix.
Number of periods to use in the window or, if
cumulative=TRUE
, the number of observations to use before the first
result is returned. Must be between 1 and nrow(x)
, inclusive.
Logical, use from-inception calculation?
The weight applied to identical values in the window. Must be between 0 and 1, inclusive. See details.
Charlie Friedemann
The computation for a percentage rank can vary depending on the weight given
to values in the window that are equal to the value being ranked. This weight
can be set using the exact.multiplier
argument which defaults to 0.5.
exact.multiplier = 0
scores equal values in the lookback window as
always being greater than the value being ranked. exact.multiplier = 1
scores equal values as being below the value being ranked. Any multiplier
between 0 and 1 counts that proportion of the equal values as being below
the value being ranked.
The value of exact.multiplier
has the most impact when the window is
relatively small or when the number of discrete values in the window is
small. For non-repeating values, changing exact.multiplier = 0
to
exact.multiplier = 1
for a window of size N
will shift the
resulting percentile rankings by 1/N
. It is equivalent to changing
the question from, "how many values are < the value" to "how many values
are <= the value".
The following site(s) were used to code/document this
indicator:
https://en.wikipedia.org/wiki/Percentile_rank