ESAC_test {HDCD}R Documentation

ESAC single change-point test

Description

R wrapper for C function testing for a single change-point using ESAC (see Moen et al. 2023).

Usage

ESAC_test(
  X,
  threshold_d = 1.5,
  threshold_s = 1,
  debug = FALSE,
  empirical = FALSE,
  thresholds = NULL,
  fast = FALSE,
  tol = 0.001,
  N = 1000,
  rescale_variance = TRUE
)

Arguments

X

Matrix of observations, where each row contains a time series

threshold_d

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

threshold_s

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

debug

If TRUE, diagnostic prints are provided during execution

empirical

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

thresholds

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

fast

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

tol

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

N

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

rescale_variance

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

Value

1 if a change-point is detected, 0 otherwise

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

# Generating data
X = matrix(rnorm(n*p), ncol = n, nrow=p)
Y = matrix(rnorm(n*p), ncol = n, nrow=p)

# Adding a single sparse change-point to X (and not Y):
X[1:5, 26:n] = X[1:5, 26:n] +1

# Vanilla ESAC:
resX = ESAC_test(X)
resX
resY = ESAC_test(Y)
resY

# Manually setting leading constants for \lambda(t) and \gamma(t)
resX = ESAC_test(X, 
                 threshold_d = 2, threshold_s = 2, #leading constants for \gamma(t)
)
resX 
resY = ESAC_test(Y, 
                 threshold_d = 2, threshold_s = 2, #leading constants for \gamma(t)
)
resY

# Empirical choice of thresholds:
resX = ESAC_test(X, empirical = TRUE, N = 100, tol = 1/100)
resX
resY = ESAC_test(Y, empirical = TRUE, N = 100, tol = 1/100)
resY

# Manual empirical choice of thresholds (equivalent to the above)
thresholds_test_emp = ESAC_test_calibrate(n,p, N=100, tol=1/100,bonferroni=TRUE)
resX = ESAC_test(X, thresholds = thresholds_test_emp[[1]])
resX
resY = ESAC_test(Y, thresholds = thresholds_test_emp[[1]])
resY

[Package HDCD version 1.1 Index]