CV.search.DP.univar {changepoints} | R Documentation |
Grid search for dynamic programming to select the tuning parameter through Cross-Validation.
Description
Perform grid search for dynamic programming to select the tuning parameter through Cross-Validation.
Usage
CV.search.DP.univar(y, gamma_set, delta)
Arguments
y |
A |
gamma_set |
A |
delta |
A positive |
Value
A list
with the following structure:
cpt_hat |
A list of vector of estimated change points (sorted in strictly increasing order). |
K_hat |
A list of scalar of number of estimated change points. |
test_error |
A list of vector of testing errors. |
train_error |
A list of vector of training errors. |
Author(s)
Daren Wang & Haotian Xu
References
Wang, Yu and Rinaldo (2020) <doi:10.1214/20-EJS1710>
Examples
set.seed(0)
cpt_true = c(20, 50, 170)
y = rnorm(300) + c(rep(0,20),rep(2,30),rep(0,120),rep(2,130))
gamma_set = 1:5
DP_result = CV.search.DP.univar(y, gamma_set, delta = 5)
min_idx = which.min(DP_result$test_error)
cpt_hat = unlist(DP_result$cpt_hat[min_idx])
Hausdorff.dist(cpt_hat, cpt_true)
[Package changepoints version 1.1.0 Index]