ESAC {HDCD}R Documentation

Efficient Sparsity Adaptive Change-point estimator

Description

R wrapper for C function implementing the full ESAC algorithm (see Moen et al. 2023).

Usage

ESAC(
  X,
  threshold_d = 1.5,
  threshold_s = 1,
  alpha = 1.5,
  K = 5,
  debug = FALSE,
  empirical = FALSE,
  tol = 0.001,
  N = 1000,
  thresholds = NULL,
  thresholds_test = NULL,
  threshold_d_test = threshold_d,
  threshold_s_test = threshold_s,
  fast = FALSE,
  rescale_variance = TRUE,
  trim = FALSE,
  NOT = TRUE,
  midpoint = FALSE
)

Arguments

X

Matrix of observations, where each row contains a time series

threshold_d

Leading constant for \lambda(t) \propto r(t) for t= p. Only relevant when thresholds=NULL

threshold_s

Leading constant for \lambda(t) \propto r(t) for t\leq \sqrt{p\log n}. Only relevant when thresholds=NULL

alpha

Parameter for generating seeded intervals

K

Parameter for generating seeded intervals

debug

If TRUE, diagnostic prints are provided during execution

empirical

If TRUE, detection thresholds are based on Monte Carlo simulation using ESAC_calibrate

tol

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

N

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

thresholds

Vector of manually chosen values of \lambda(t) for t \in \mathcal{T}, decreasing in t

thresholds_test

Vector of manually chosen values of \gamma(t) for t \in \mathcal{T}, decreasing in t

threshold_d_test

Leading constant for \gamma(t) \propto r(t) for t=p. Only relevant when empirical=FALSE and thresholds_test=NULL

threshold_s_test

Leading constant for \gamma(t) \propto r(t) for t\leq \sqrt{p\log n}. Only relevant when empirical=FALSE and thresholds_test=NULL

fast

If TRUE, ESAC only tests for a change-point at the midpoint of each seeded interval

rescale_variance

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

trim

If TRUE, interval trimming is performed

NOT

If TRUE, ESAC uses Narrowest-Over-Threshold selection of change-points

midpoint

If TRUE, change-point positions are estimated by the mid-point of the seeded interval in which the penalized score is the largest

Value

A list containing

changepoints

vector of estimated change-points

changepointnumber

number of changepoints

CUSUMval

the penalized score at the corresponding change-point in 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

startpoints

start point of the seeded interval detecting the corresponding change-point in changepoints

endpoints

end point of the seeded interval detecting the corresponding change-point in changepoints

thresholds

vector of values of \lambda(t) for t \in \mathcal{T} in decreasing order

thresholds_test

vector of values of \gamma(t) for t \in \mathcal{T} in decreasing order

References

Moen PAJ, Glad IK, Tveten M (2023). “Efficient sparsity adaptive changepoint estimation.” Arxiv preprint, 2306.04702, https://doi.org/10.48550/arXiv.2306.04702.

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 ESAC:
res = ESAC(X)
res$changepoints

# Manually setting leading constants for \lambda(t) and \gamma(t)
res = ESAC(X, 
           threshold_d = 2, threshold_s = 2, #leading constants for \lambda(t)
           threshold_d_test = 2, threshold_s_test = 2 #leading constants for \gamma(t)
)
res$changepoints #estimated change-point locations

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

# Manual empirical choice of thresholds (equivalent to the above)
thresholds_emp = ESAC_calibrate(n,p, N=100, tol=1/100)
res = ESAC(X, thresholds_test = thresholds_emp[[1]])
res$changepoints

[Package HDCD version 1.1 Index]