| Inspect_test {HDCD} | R Documentation | 
Inspect single change-point test
Description
R wrapper for C function testing for a single change-point using Inspect Wang and Samworth (2018).
Usage
Inspect_test(
  X,
  lambda = NULL,
  xi = NULL,
  eps = 1e-10,
  empirical = FALSE,
  N = 100,
  tol = 1/100,
  maxiter = 10000,
  rescale_variance = TRUE,
  debug = FALSE
)
Arguments
| X | Matrix of observations, where each row contains a time series | 
| lambda | Manually specified value of  | 
| xi | Manually specified value of  | 
| eps | Threshold for declaring numerical convergence of the power method | 
| empirical | If  | 
| N | If  | 
| tol | If  | 
| maxiter | Maximum number of iterations for the power method | 
| rescale_variance | If  | 
| debug | If  | 
Value
1 if a change-point is detected, 0 otherwise
References
Wang T, Samworth RJ (2018). “High dimensional change point estimation via sparse projection.” Journal of the Royal Statistical Society: Series B (Statistical Methodology), 80(1), 57–83. ISSN 1467-9868, doi:10.1111/rssb.12243, https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/rssb.12243.
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 Inspect:
resX = Inspect_test(X)
resX
resY = Inspect_test(Y)
resY
# Manually setting \lambda and \xi:
resX = Inspect_test(X, 
                    lambda = sqrt(log(p*log(n))/2),
                    xi = 4*sqrt(log(n*p))
)
resX 
resY = Inspect_test(Y, 
                    lambda = sqrt(log(p*log(n))/2),
                    xi = 4*sqrt(log(n*p))
)
resY
# Empirical choice of thresholds:
resX = Inspect_test(X, empirical = TRUE, N = 100, tol = 1/100)
resX
resY = Inspect_test(Y, empirical = TRUE, N = 100, tol = 1/100)
resY
# Manual empirical choice of thresholds (equivalent to the above)
thresholds_test_emp = Inspect_test_calibrate(n,p, N=100, tol=1/100)
resX = Inspect_test(X, xi = thresholds_test_emp$max_value)
resX
resY = Inspect_test(Y, xi = thresholds_test_emp$max_value)
resY