I.record {RecordTest} | R Documentation |
Record Indicators
Description
Returns the record indicators of the values in a vector. The record indicator for each value in a vector is a binary variable which takes the value 1 if the corresponding value in the vector is a record and 0 otherwise.
If the argument X
is a matrix, then each column is treated as a
different vector.
Usage
I.record(X, record = c("upper", "lower"), weak = FALSE)
## Default S3 method:
I.record(X, record = c("upper", "lower"), weak = FALSE)
## S3 method for class 'numeric'
I.record(X, record = c("upper", "lower"), weak = FALSE)
## S3 method for class 'matrix'
I.record(X, record = c("upper", "lower"), weak = FALSE)
Arguments
X |
A numeric vector, matrix (or data frame). |
record |
A character string indicating the type of record to be calculated, "upper" or "lower". |
weak |
Logical. If |
Details
Let \{X_1,\ldots,X_T\}
be a vector of random variables of
size T
. An observation X_t
will be called an upper record
value if its value exceeds that of all previous observations. An
analogous definition deals with lower record values.
Here, X_1
is referred to as the reference value or the trivial record.
Then, the sequence of record indicator random variables
\{I_1,\ldots,I_T\}
is given by
I_t = \left\{
\begin{array}{ll}
1 & \mbox{if } X_t \mbox{ is a record,} \\
0 & \mbox{if } X_t \mbox{ is not a record.}
\end{array} \right.
The method I.record
calculates the sample sequence above if the
argument X
is a numeric vector. If the argument X
is a
matrix (or data frame) with M
columns, the method I.record
calculates the sample sequence above for each column of the object as if
all columns were different sequences.
In summary:
\code{I.record}: \code{X} = \left(
\begin{array}{cccc}
X_{1,1} & X_{1,2} & \cdots & X_{1,M} \\
X_{2,1} & X_{2,2} & \cdots & X_{2,M} \\
\vdots & \vdots & & \vdots \\
X_{T,1} & X_{T,2} & \cdots & X_{T,M} \\
\end{array} \right)
\longrightarrow
\left(
\begin{array}{cccc}
I_{1,1} & I_{1,2} & \cdots & I_{1,M} \\
I_{2,1} & I_{2,2} & \cdots & I_{2,M} \\
\vdots & \vdots & & \vdots \\
I_{T,1} & I_{T,2} & \cdots & I_{T,M} \\
\end{array} \right).
Indicators of record occurrence can be calculated for both upper and lower records.
All the procedure above can be extended to weak records, which also count
the ties as a new (weak) record. Ties are possible in discrete variables
or if a continuous variable has been rounded. Weak records can be computed
if weak = TRUE
.
NA
values in X
are assigned -Inf
for upper records
and Inf
for lower records, so they are records only if they are
placed at t = 1
.
Value
A binary matrix of the same length or dimension as X
,
indicating the record occurrence.
Author(s)
Jorge Castillo-Mateo
References
Arnold BC, Balakrishnan N, Nagaraja HN (1998). Records. Wiley Series in Probability and Statistics. Wiley, New York. doi:10.1002/9781118150412.
See Also
L.record
,
N.record
, Nmean.record
,
p.record
, R.record
,
records
, S.record
Examples
X <- c(1, 5, 3, 6, 6, 9, 2, 11, 17, 8)
I.record(X)
I.record(X, weak = TRUE)
I.record(ZaragozaSeries)
# record argument can be shortened
I.record(ZaragozaSeries, record = "l")