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
.
all_max_rcpp(x, b = 1, which_dj = c("all", "first", "last"), ...)
A list containing
ys
a numeric vector containing one set of sliding block maxima.
xs
a numeric vector containing the values that
contribute to ys
, that is, the whole input vector x
.
yd
if which_dj = "all"
a floor(n / b)
by n - floor(n / b) * b + 1
numeric matrix. Each column
contains a set of disjoint maxima. Otherwise, a floor(n / b)
by 1 numeric matrix containing one set of block maxima.
xd
if which_dj = "all"
a
floor(n / b) * b
by n - floor(n / b) * b + 1
numeric
matrix. Each column contains the values in x
that contribute
to the corresponding column in yd
. Otherwise, a
floor(n / b)
by 1 numeric matrix containing one the one set of
the values in x
that contribute to yd
.
A numeric vector of raw observations.
A numeric scalar. The block size.
A character scalar. Determines Which sets of disjoint
maxima are calculated: "all"
, all sets; "first"
, only the
set whose first block starts on the first observation in x
;
"last"
, only the set whose last block end on the last observation
in x
.
Further arguments to be passed to
roll_max
.
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.
spm
for semiparametric estimation of the
extremal index based on block maxima.
x <- 1:11
all_max_rcpp(x, 3)
all_max_rcpp(x, 3, which_dj = "first")
all_max_rcpp(x, 3, which_dj = "last")
Run the code above in your browser using DataLab