View source: R/Finalised_coding.R
| cusum_function | R Documentation |
This function returns the CUMSUM statistic for a given data sequence. See Details for more information.
cusum_function(x)
x |
A numeric vector containing the data. |
The CUSUM statistic for x at a location b is defined as
\tilde{X}_{s,e}^b = \sqrt{\frac{e-b}{n(b-s+1)}}\sum_{t=s}^{b}X_t -
\sqrt{\frac{b-s+1}{n(e-b)}}\sum_{t=b+1}^{e}X_t,
where 1\le s \le b < e\le T and n=e-s+1. In cusum_function,
we have s=1, e=T.
A numeric vector with the CUSUM statistic values at b = 1,2,...,T-1,
where T is the length of x.
Andreas Anastasiou, anastasiou.andreas@ucy.ac.cy
cumsum_lin for the calculation of the contrast function that
is used in the case of piecewise-linear mean signals.
no.cpt.noise <- rnorm(2000)
csm.no.cpt <- IDetect:::cusum_function(no.cpt.noise)
single.cpt <- c(rep(4,1000),rep(0,1000))
single.cpt.noise <- single.cpt + rnorm(2000)
csm.single.cpt <- IDetect:::cusum_function(single.cpt.noise)
#*** Notice that the maximum in absolute value of \code{csm.single.cpt}
#*** occurs in a neighbourhood of the true change-point, which is 1000.
which.max(abs(csm.single.cpt))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.