View source: R/HD_regression.R
CV.search.DP.LR.regression | R Documentation |
Perform grid search based on Cross-Validation of all tuning parameters (gamma, lambda and zeta)
CV.search.DP.LR.regression( y, X, gamma_set, lambda_set, zeta_set, delta, eps = 0.001 )
y |
A |
X |
A |
gamma_set |
A |
lambda_set |
A |
zeta_set |
A |
delta |
A strictly positive |
eps |
A |
A list
with the following structure:
cpt_hat |
A list of vector of estimated changepoints (sorted in strictly increasing order) |
K_hat |
A list of scalar of number of estimated changepoints |
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
Rinaldo, Wang, Wen, Willett and Yu (2020) <arxiv:2010.10410>
set.seed(123) d0 = 8 p = 15 n = 100 cpt_true = c(30, 70) data = simu.change.regression(d0, cpt_true, p, n, sigma = 1, kappa = 9) gamma_set = c(0.01, 0.1) lambda_set = c(0.01, 0.1) temp = CV.search.DP.regression(y = data$y, X = data$X, gamma_set, lambda_set, delta = 2) 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))) gamma_set[min_idx[1]] lambda_set[min_idx[2]] cpt_init = unlist(temp$cpt_hat[min_idx[1], min_idx[2]]) zeta_set = c(0.1, 1) temp_zeta = CV.search.DP.LR.regression(data$y, data$X, gamma_set[min_idx[1]], lambda_set[min_idx[2]], zeta_set, delta = 2, eps = 0.001) min_zeta_idx = which.min(unlist(temp_zeta$test_error)) cpt_LR = local.refine.regression(cpt_init, data$y, X = data$X, zeta = zeta_set[min_zeta_idx]) Hausdorff.dist(cpt_init, cpt_true) Hausdorff.dist(cpt_LR, cpt_true)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.