cpt.cc: Changepoints in cross-correlated data-CAPA-CC

Description Usage Arguments Value Examples

View source: R/method_cptcc.R

Description

A method for detecting a single changepoint in cross-correlated data based on CPT-CC by Tveten, Eckley, Fearnhead (2020). To detect multiple changepoints, combine this function with a version of Binary Segmentation (BS), like Wild BS or Seeded BS.

Usage

1
cpt.cc(x, Q, b = 1, min_seg_len = 2)

Arguments

x

An n x p data matrix where each row is an observation vector.

Q

An estimate of the precision matrix. See robust_sparse_precision. Must be a sparse matrix from the Matrix package.

b

The scaling factor for the collective anomaly penalty. Defaults to 1.

min_seg_len

The minimum segment length. Defaults to 2.

Value

An S3 class of type cptcc with the following components:

x

The input data matrix.

cpts

A data frame with two columns: variate (which variable is affected) and cpt (the location of the estimated changepoint).

Examples

1
2
3
4
5
library(capacc)
x <- simulate_cor(n = 100, locations = 50, durations = 50, proportions = 0.2)$x
diff_x <- x[2:nrow(x), ] - x[1:(nrow(x) - 1), ]
Q <- 2 * robust_sparse_precision(diff_x, adjacency_mat(banded_neighbours(2, ncol(x)), sparse = FALSE))
res <- cpt.cc(x, Q, b = 1, min_seg_len = 5)

Tveten/capacc documentation built on Sept. 29, 2021, 5:31 a.m.