View source: R/HD_regression.R
| CV.search.DP.regression | R Documentation | 
Perform grid search to select tuning parameters gamma (for l_0 penalty of DP) and lambda (for lasso penalty) based on cross-validation.
CV.search.DP.regression(y, X, gamma_set, lambda_set, delta, eps = 0.001)
| y | A  | 
| X | A  | 
| gamma_set | A  | 
| lambda_set | A  | 
| delta | A strictly positive  | 
| 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
Rinaldo, Wang, Wen, Willett and Yu (2020) <arxiv:2010.10410>
d0 = 10 p = 20 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, 1) lambda_set = c(0.01, 0.1, 1, 3) 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]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.