Inspect: Informative sparse projection for estimating change-points...

View source: R/Inspect.R

InspectR Documentation

Informative sparse projection for estimating change-points (Inspect)

Description

R wrapper for C function implementing a Narrowest-Over-Threshold variant of Inspect \insertCitewang_high_2018;textualHDCD as specified in Appendix C in \insertCitemoen2023efficient;textualHDCD. Note that the algorithm is only implemented for \mathcal{S} = \mathcal{S}_2, in the notation of \insertCitemoen2023efficient;textualHDCD.

Usage

Inspect(
  X,
  lambda = NULL,
  xi = NULL,
  alpha = 1.5,
  K = 5,
  eps = 1e-10,
  empirical = FALSE,
  maxiter = 10000,
  N = 100,
  tol = 1/100,
  rescale_variance = TRUE,
  debug = FALSE
)

Arguments

X

Matrix of observations, where each row contains a time series

lambda

Manually specified value of \lambda (can be NULL, in which case \lambda \gets \sqrt{\log(p\log n)/2})

xi

Manually specified value of \xi (can be NULL, in which case \xi \gets 4\sqrt{\log(np)})

alpha

Parameter for generating seeded intervals

K

Parameter for generating seeded intervals

eps

Threshold for declaring numerical convergence of the power method

empirical

If TRUE, the detection threshold xi is based on Monte Carlo simulation using Inspect_calibrate

maxiter

Maximum number of iterations for the power method

N

If empirical=TRUE, N is the number of Monte Carlo samples used

tol

If empirical=TRUE, tol is the false error probability tolerance

rescale_variance

If TRUE, each row of the data is re-scaled by a MAD estimate using rescale_variance

debug

If TRUE, diagnostic prints are provided during execution

Value

A list containing

changepoints

vector of estimated change-points

changepointnumber

number of changepoints

CUSUMval

vector with the sparse projected CUSUMs corresponding to changepoints

coordinates

a matrix of zeros and ones indicating which time series are affected by a change in mean, with each row corresponding to the change-point in changepoints

scales

vector of estimated noise level for each series

References

\insertAllCited

Examples

library(HDCD)
n = 50
p = 50
set.seed(100)
# Generating data
X = matrix(rnorm(n*p), ncol = n, nrow=p)
# Adding a single sparse change-point:
X[1:5, 26:n] = X[1:5, 26:n] +1

# Vanilla Inspect:
res = Inspect(X)
res$changepoints

# Manually setting leading constants for \lambda(t) and \gamma(t)
res = Inspect(X, 
              lambda = sqrt(log(p*log(n))/2),
              xi = 4*sqrt(log(n*p))
)
res$changepoints #estimated change-point locations

# Empirical choice of thresholds:
res = Inspect(X, empirical=TRUE, N = 100, tol = 1/100)
res$changepoints

# Manual empirical choice of thresholds (equivalent to the above)
thresholds_emp = Inspect_calibrate(n,p, N=100, tol=1/100)
res = Inspect(X, xi = thresholds_emp$max_value)
res$changepoints

HDCD documentation built on June 22, 2024, 10:53 a.m.