single_CUSUM {HDCD} | R Documentation |
CUSUM transformation of matrix at a specific position
Description
R wrapper for C function computing the CUSUM transformation of matrix over an interval evaluated at a specific position. For compatibility with C indexing, the user should subtract
from
,
and
when supplying the arguments to the function. If start and stop are not supplied, the CUSUM is computed over the full data, so
.
Usage
single_CUSUM(X, start = NULL, stop = NULL, pos)
Arguments
X |
Matrix of observations, where each row contains a time series |
start |
Starting point of interval over which the CUSUM should be computed, subtracted by one |
stop |
Ending point of interval over which the CUSUM should be computed, subtracted by one |
pos |
Position at which the CUSUM should be evaluated, subtracted by one |
Value
A vector of CUSUM values, each corresponding to a row of the input matrix. The -th element corresponds to the CUSUM transformation of the
-th row of
, computed over the interval
and evaluated at position
, i.e.
,
where
,
and
.
Examples
n = 10
p = 10
set.seed(101)
X = matrix(rnorm(n*p), ncol = n, nrow=p)
# CUSUM over the full data (s,e] = (0,n] evaluated at position v=4
position = 4
X_cusum_single = single_CUSUM(X,pos = position-1)
X_cusum_single
# verifying that this corresponds to the 4-th row of output of CUSUM():
X_cusum = CUSUM(X)
X_cusum[,4]