CUSUM | R Documentation |
R wrapper for C function computing the CUSUM transformation of a matrix over an interval (s,e]
. For compatibility with C indexing, the user should subtract 1
from both s
and e
when supplying the arguments to the function. If start and stop are not supplied, the CUSUM is computed over the full data, so (s,e] = (0,n]
. In this case, CUSUM
returns the same result as cusum.transform
in the package InspectChangepoint
\insertCiteinspectpackageHDCD.
CUSUM(X, start = NULL, stop = NULL)
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 |
A matrix of CUSUM values. The (i,j)
-th element corresponds to the CUSUM transformation of the i
-th row of X
, computed over the interval (\code{start}+1,\code{end}+1]
and evaluated at position \code{start}+1+j
, i.e.
\sqrt{\frac{e-v}{(e-s)(v-s)}}\sum_{t=s+1}^v X_{i,t} - \sqrt{\frac{v-s}{(e-s)(e-v)}}\sum_{t=v+1}^e X_{i,t}
,
where s = (\code{start}+1)
, e = (\code{stop}+1)
and v = \code{start}+1+j
.
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]
X_cusum = CUSUM(X)
# CUSUM over (s,e] = (3,9]:
s = 3
e = 9
X_cusum = CUSUM(X, start = s-1, stop = e-1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.