cumsum_lin: Calculate the contrast function that is used in continuous...

View source: R/Finalised_coding.R

cumsum_linR Documentation

Calculate the contrast function that is used in continuous piecewise-linear mean signals

Description

This function returns the values of the contrast function, which is used for for change-point detection in continuous piecewise-linear mean signals. See Details for more information.

Usage

cumsum_lin(x)

Arguments

x

A numeric vector containing the data.

Details

The mathematical expression of the result returned by cumsum_lin is rather large. Therefore, for the exact formula please see the relevant subsection for piecewise-linearity in the preprint “Detecting multiple generalized change-points by isolating single ones”, Anastasiou and Fryzlewicz (2017).

Value

A numeric vector with the contrast function values at b = 1,2,...,T-1, where T is the length of x. Note that due to the structure of the signal (piecewise-linear mean), the value of the contrast function statistic at b=1 is equal to zero.

Author(s)

Andreas Anastasiou, anastasiou.andreas@ucy.ac.cy

See Also

cusum_function for the calculation of the CUSUM statistic, which is the contrast function used in the case of piecewise-constant mean signals.

Examples

no.cpt.noise <- rnorm(2000)
cf.no.cpt <- IDetect:::cumsum_lin(no.cpt.noise)

single.cpt <- c(seq(0, 999, 1), seq(998.5, 499, -0.5))
single.cpt.noise <- single.cpt + rnorm(2000)
cf.single.cpt <- IDetect:::cumsum_lin(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(cf.single.cpt))

IDetect documentation built on May 7, 2026, 5:09 p.m.