CV.search.DP.VAR1 | R Documentation |
Perform grid search based on cross-validation of dynamic programming for VAR change points detection.
CV.search.DP.VAR1(DATA, gamma_set, lambda_set, delta, eps = 0.001)
DATA |
A |
gamma_set |
A |
lambda_set |
A |
delta |
A strictly |
eps |
A |
A list
with the following structure:
cpt_hat |
A list of vector of estimated change points |
K_hat |
A list of scalar of number of estimated change points |
test_error |
A list of vector of testing errors (each row corresponding to each gamma, and each column corresponding to each lambda) |
train_error |
A list of vector of training errors |
Daren Wang & Haotian Xu
Wang, Yu, Rinaldo and Willett (2019) <arxiv:1909.06359>
set.seed(123) p = 10 sigma = 1 n = 20 v1 = 2*(seq(1,p,1)%%2) - 1 v2 = -v1 AA = matrix(0, nrow = p, ncol = p-2) A1 = cbind(v1,v2,AA)*0.1 A2 = cbind(v2,v1,AA)*0.1 A3 = A1 cpt_true = c(40, 80) data = simu.VAR1(sigma, p, 2*n+1, A1) data = cbind(data, simu.VAR1(sigma, p, 2*n, A2, vzero=c(data[,ncol(data)]))) data = cbind(data, simu.VAR1(sigma, p, 2*n, A3, vzero=c(data[,ncol(data)]))) gamma_set = c(0.1, 0.5, 1) lambda_set = c(0.1, 1, 3.2) temp = CV.search.DP.VAR1(data, gamma_set, lambda_set, delta = 5) temp$test_error # test error result # find the indices of gamma.set and lambda.set which minimizes the test error min_idx = as.vector(arrayInd(which.min(temp$test_error), dim(temp$test_error))) cpt_init = unlist(temp$cpt_hat[min_idx[1], min_idx[2]]) Hausdorff.dist(cpt_init, cpt_true)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.