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 |
threshold_s |
Leading constant for |
debug |
If |
empirical |
If |
thresholds |
Vector of manually chosen values of |
fast |
If |
tol |
If |
N |
If |
rescale_variance |
If |
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