all_max_rcpp {exdex} | R Documentation |
Sliding and disjoint block maxima
Description
Calculates the (sliding) maxima of all blocks of b
contiguous values
and all sets of the maxima of disjoint blocks of b
contiguous values
in the vector x
. This provides the first step of computations in
spm
.
Usage
all_max_rcpp(x, b = 1, which_dj = c("all", "first", "last"), ...)
Arguments
x |
A numeric vector of raw observations. |
b |
A numeric scalar. The block size. |
which_dj |
A character scalar. Determines Which sets of disjoint
maxima are calculated: |
... |
Further arguments to be passed to
|
Details
Sliding maxima. The function
roll_max
in the RcppRoll
package is used.
Disjoint maxima. If n = length(x)
is an integer
multiple of b
, or if which_dj = "first"
or
which_dj = "last"
then only one set of n / b
disjoint
block maxima are returned.
Otherwise, n - floor(n / b) * b + 1
sets of floor(n / b)
disjoint block maxima are returned. Set i
are the disjoint maxima
of x[i:(i + floor(n / b) * b - 1)]
. That is, all possible sets
of contiguous disjoint maxima achieving the maxima length of
floor(n / b)
are calculated.
In both instances na.rm = TRUE
is passed to max
so
that blocks containing missing values produce a non-missing result.
Also returned are the values in x
that contribute to each set
of block maxima.
Value
A list containing
ys |
a numeric vector containing one set of sliding block maxima. |
xs |
a numeric vector containing the values that
contribute to |
yd |
if |
xd |
if |
See Also
spm
for semiparametric estimation of the
extremal index based on block maxima.
Examples
x <- 1:11
all_max_rcpp(x, 3)
all_max_rcpp(x, 3, which_dj = "first")
all_max_rcpp(x, 3, which_dj = "last")