Title: | L2 Inference for Change Points in High-Dimensional Time Series |
---|---|
Description: | Provides a method for detecting multiple change points in high-dimensional time series, targeting dense or spatially clustered signals. See Li et al. (2023) "L2 Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM". arXiv preprint <arXiv:2208.13074>. |
Authors: | Jiaqi Li [aut], Likai Chen [aut], Weining Wang [aut], Wei Biao Wu [aut], Rui Lin [cre] |
Maintainer: | Rui Lin <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0 |
Built: | 2025-02-03 04:38:45 UTC |
Source: | https://github.com/cran/L2hdchange |
Check the validity of the neighbourhood specification
check_nbd(nbd_info)
check_nbd(nbd_info)
nbd_info |
A list containing the neighbourhood information. See |
No return value. Show an error message if nbd_info is invalid.
nbd_info <- list(c(1:10),c(8:20)) check_nbd <- check_nbd(nbd_info)
nbd_info <- list(c(1:10),c(8:20)) check_nbd <- check_nbd(nbd_info)
Daily number of COVID-19 cases for 58 areas in the United States (including 50 states, Washington D.C., 5 territories and 2 cruise ships) for 812 days from 22 Jan 2020 to 12 April 2022.
covid_data
covid_data
covid_data
A data matrix with p = 58 rows and n = 812 columns.
U.S. CDC https://covid.cdc.gov/covid-data-tracker/#maps_new-admissions-rate-county
U.S. COVID-19 Data Neighbourhood Information
covid_nbd_info
covid_nbd_info
covid_nbd_info
A list containing five arrays indicating the constituents of five U.S. regions:
Northeast: Connecticut, Maine, Massachusetts, New Hampshire, Rhode Island, Vermont, New Jersey, New York, and Pennsylvania.
Midwest: Illinois, Indiana, Michigan, Ohio, Wisconsin, Iowa, Kansas, Minnesota, Missouri, Nebraska, North Dakota, and South Dakota.
South: Delaware, Florida, Georgia, Maryland, North Carolina, South Carolina, Virginia, District of Columbia, West Virginia, Alabama, Kentucky, Mississippi, Tennessee, Arkansas, Louisiana, Oklahoma, and Texas.
West: Arizona, Colorado, Idaho, Montana, Nevada, New Mexico, Utah, Wyoming, Alaska, California, Hawaii, Oregon, and Washington.
Others: American Samoa, Diamond Princess, Grand Princess, Guam, Northern Mariana Islands, Puerto Rico, and Virgin Islands.
U.S. Census Bureau, W. (2000). List of regions of the United States.
Construct an S3 class 'no_nbd' or 'nbd' for change-point estimation
est_hdchange(hdobj, test_stats, threshold, stat_all, critical_values)
est_hdchange(hdobj, test_stats, threshold, stat_all, critical_values)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated by |
test_stats |
A list containing the test statistics generated by |
threshold |
The threshold in break estimation. |
stat_all |
An array of test statistics generated by |
critical_values |
An array of quantiles for critical values. |
An S3 object of class 'no_nbd' or 'nbd' used as the argument of get_breaks()
.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) teststats <- get_teststats(ts_no_nbd) V_12_MAinf <- get_V_l2_MAinf(ts_no_nbd) estobj <- est_hdchange(hdobj = ts_no_nbd, test_stats = teststats$stat_max, threshold = 1e-5, stat_all = V_12_MAinf, critical_values = c(0.01, 0.05, 0.1))
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) teststats <- get_teststats(ts_no_nbd) V_12_MAinf <- get_V_l2_MAinf(ts_no_nbd) estobj <- est_hdchange(hdobj = ts_no_nbd, test_stats = teststats$stat_max, threshold = 1e-5, stat_all = V_12_MAinf, critical_values = c(0.01, 0.05, 0.1))
Generate a random Gaussian vector
genZ(hdobj)
genZ(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated by |
The Gaussian random vector .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) Z <- genZ(ts_no_nbd)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) Z <- genZ(ts_no_nbd)
Obtain the time-stamps and spatial locations with breaks
get_breaks(estobj)
get_breaks(estobj)
estobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the time-stamps and spatial locations with breaks.
For S3 class 'no_nbd', it returns the total number of breaks
and the time-stamps
. See Algorithm 1 of Li et al. (2023).
For S3 class 'nbd', it returns the total number of breaks
and the
spatial-temporal location of the break
. See Algorithm
2 of Li et al. (2023).
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) teststats <- get_teststats(ts_no_nbd) V_12_MAinf <- get_V_l2_MAinf(ts_no_nbd) estobj <- est_hdchange(hdobj = ts_no_nbd, test_stats = teststats$stat_max, threshold = 1e-5, stat_all = V_12_MAinf, critical_values = c(0.01, 0.05, 0.1)) breaks <- get_breaks(estobj)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) teststats <- get_teststats(ts_no_nbd) V_12_MAinf <- get_V_l2_MAinf(ts_no_nbd) estobj <- est_hdchange(hdobj = ts_no_nbd, test_stats = teststats$stat_max, threshold = 1e-5, stat_all = V_12_MAinf, critical_values = c(0.01, 0.05, 0.1)) breaks <- get_breaks(estobj)
Obtain the time-stamps and spatial locations with breaks
## S3 method for class 'nbd' get_breaks(estobj)
## S3 method for class 'nbd' get_breaks(estobj)
estobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the total number of breaks and the
spatial-temporal location of the break
. See Algorithm
2 of Li et al. (2023).
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain the time-stamps and spatial locations without break
## S3 method for class 'no_nbd' get_breaks(estobj)
## S3 method for class 'no_nbd' get_breaks(estobj)
estobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the total number of breaks
and the time-stamps
. See Algorithm 1 of Li et al. (2023).
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
The covariance matrix for generating random Gaussian vector
get_cov_x_MAinf(n, b)
get_cov_x_MAinf(n, b)
n |
Number of time series observations. |
b |
Bandwith parameter |
The covariance matrix. See section 2.2 of Li et al. (2023).
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) Cov_x_MAinf <- get_cov_x_MAinf(ts_no_nbd$n, ts_no_nbd$b)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) Cov_x_MAinf <- get_cov_x_MAinf(ts_no_nbd$n, ts_no_nbd$b)
Obtain critical values and threshold
get_critical(hdobj)
get_critical(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the critical values and
the threshold parameter .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) crit <- get_critical(ts_no_nbd)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) crit <- get_critical(ts_no_nbd)
Obtain critical values and threshold
## S3 method for class 'nbd' get_critical(hdobj)
## S3 method for class 'nbd' get_critical(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the critical values and
the threshold parameter .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain critical values and threshold
## S3 method for class 'no_nbd' get_critical(hdobj)
## S3 method for class 'no_nbd' get_critical(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the critical values and
the threshold parameter .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain the simulated standardised gap vector
get_GS_MAinf(hdobj)
get_GS_MAinf(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
An array of the simulated counterpart of .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) GS_MAinf <- get_GS_MAinf(ts_no_nbd)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) GS_MAinf <- get_GS_MAinf(ts_no_nbd)
Obtain the simulated standardised gap vector
## S3 method for class 'nbd' get_GS_MAinf(hdobj)
## S3 method for class 'nbd' get_GS_MAinf(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
An array of the simulated counterpart of .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain the simulated standardised gap vector
## S3 method for class 'no_nbd' get_GS_MAinf(hdobj)
## S3 method for class 'no_nbd' get_GS_MAinf(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
An array of the simulated counterpart of .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Compute the long-run variance of the gap vector
get_lr_var(hdobj)
get_lr_var(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
The covariance matrix of the gap vectors .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) lr_var <- get_lr_var(ts_no_nbd)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) lr_var <- get_lr_var(ts_no_nbd)
Obtain the test statistics
get_teststats(hdobj)
get_teststats(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the test statistics
and a sequence of standardised
.
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) teststat <- get_teststats(ts_no_nbd)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) teststat <- get_teststats(ts_no_nbd)
Obtain the test statistics
## S3 method for class 'nbd' get_teststats(hdobj)
## S3 method for class 'nbd' get_teststats(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the test statistics
and a sequence of standardised
.
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain the test statistics
## S3 method for class 'no_nbd' get_teststats(hdobj)
## S3 method for class 'no_nbd' get_teststats(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
A list containing the test statistics
and a sequence of standardised
.
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain the standardised gap vector
get_V_l2_MAinf(hdobj)
get_V_l2_MAinf(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
An array of .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) V_12_MAinf <- get_V_l2_MAinf(ts_no_nbd)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) V_12_MAinf <- get_V_l2_MAinf(ts_no_nbd)
Obtain the standardised gap vector
## S3 method for class 'nbd' get_V_l2_MAinf(hdobj)
## S3 method for class 'nbd' get_V_l2_MAinf(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
An array of .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
Obtain the standardised gap vector
## S3 method for class 'no_nbd' get_V_l2_MAinf(hdobj)
## S3 method for class 'no_nbd' get_V_l2_MAinf(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
An array of .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
The main function of this package. It performs a test for existence of breaks and estimates the time-stamps and locations of the breaks.
hdchange(hdobj)
hdchange(hdobj)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
The return value is an S3 object of class 'no_nbd' or 'nbd' containing a list of the test results and change-point locations.
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
############ No neighbourhood case ############ # generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) # Estimate the time-stamps of the breaks est_result_no_nbd <- hdchange(ts_no_nbd) # Summarize the results summary(est_result_no_nbd) # Plot the results plot_result(est_result_no_nbd) axis(1, at = est_result_no_nbd$time_stamps, labels = c("break 1", "break 2", "break 3") ) title(main = "Change-points estimation") ############ Neighbourhood case ############ # generate data data_nbd <- sim_hdchange_nbd(n = 300, p = 70, nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) ), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "t", dependence = "iid", param = 5), jump_max = 1) # construct nbd object ts_nbd <- ts_hdchange(data_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1), nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) )) # Estimate the time-stamps of the breaks est_result_nbd <- hdchange(ts_nbd) # Summarize the results summary(est_result_nbd) # Plot the results plot_result(est_result_nbd, nbd_index = 2) pairs <- est_result_nbd$nbd_and_stamps_pair time_stamps <- pairs[pairs[, 1] == 2, 2] axis(1, at = time_stamps, labels = c("break 1", "break 2") ) title(main = "Change-points estimation for neibourhood 2")
############ No neighbourhood case ############ # generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) # Estimate the time-stamps of the breaks est_result_no_nbd <- hdchange(ts_no_nbd) # Summarize the results summary(est_result_no_nbd) # Plot the results plot_result(est_result_no_nbd) axis(1, at = est_result_no_nbd$time_stamps, labels = c("break 1", "break 2", "break 3") ) title(main = "Change-points estimation") ############ Neighbourhood case ############ # generate data data_nbd <- sim_hdchange_nbd(n = 300, p = 70, nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) ), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "t", dependence = "iid", param = 5), jump_max = 1) # construct nbd object ts_nbd <- ts_hdchange(data_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1), nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) )) # Estimate the time-stamps of the breaks est_result_nbd <- hdchange(ts_nbd) # Summarize the results summary(est_result_nbd) # Plot the results plot_result(est_result_nbd, nbd_index = 2) pairs <- est_result_nbd$nbd_and_stamps_pair time_stamps <- pairs[pairs[, 1] == 2, 2] axis(1, at = time_stamps, labels = c("break 1", "break 2") ) title(main = "Change-points estimation for neibourhood 2")
Plot the time series and change-points
plot_result(est_result, ...)
plot_result(est_result, ...)
est_result |
An S3 object of class 'result_no_nbd' or 'result_nbd' created by |
... |
Additional arguments. |
See hdchange()
for examples.
No return value. Presents the plot of the data and breaks.
# generate data data_nbd <- sim_hdchange_nbd(n = 300, p = 70, nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) ), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "t", dependence = "iid", param = 5), jump_max = 1) # construct nbd object ts_nbd <- ts_hdchange(data_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1), nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) )) # Estimate the time-stamps of the breaks est_result_nbd <- hdchange(ts_nbd) # Plot the results plot_result(est_result_nbd, nbd_index = 2) pairs <- est_result_nbd$nbd_and_stamps_pair time_stamps <- pairs[pairs[, 1] == 2, 2] axis(1, at = time_stamps, labels = c("break 1", "break 2") ) title(main = "Change-points estimation for neibourhood 2")
# generate data data_nbd <- sim_hdchange_nbd(n = 300, p = 70, nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) ), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "t", dependence = "iid", param = 5), jump_max = 1) # construct nbd object ts_nbd <- ts_hdchange(data_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1), nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) )) # Estimate the time-stamps of the breaks est_result_nbd <- hdchange(ts_nbd) # Plot the results plot_result(est_result_nbd, nbd_index = 2) pairs <- est_result_nbd$nbd_and_stamps_pair time_stamps <- pairs[pairs[, 1] == 2, 2] axis(1, at = time_stamps, labels = c("break 1", "break 2") ) title(main = "Change-points estimation for neibourhood 2")
Plot the time series and change-points
## S3 method for class 'result_nbd' plot_result(est_result, ..., nbd_index)
## S3 method for class 'result_nbd' plot_result(est_result, ..., nbd_index)
est_result |
An S3 object of class 'result_nbd' created by |
... |
Additional arguments. |
nbd_index |
An integer indicating which neighbourhood to be plotted. |
See hdchange()
for examples.
No return value. Presents the plot of the data and breaks.
Plot the time series and change-points
## S3 method for class 'result_no_nbd' plot_result(est_result, ...)
## S3 method for class 'result_no_nbd' plot_result(est_result, ...)
est_result |
An S3 object of class 'result_no_nbd' created by |
... |
Additional arguments. |
See hdchange()
for examples.
No return value. Presents the plot of the data and breaks.
Simulate data with neighbourhood
sim_hdchange_nbd( n = 300, p = 70, nbd_info = list((1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55)), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "normal", dependence = "iid", param = 1), jump_max = 1 )
sim_hdchange_nbd( n = 300, p = 70, nbd_info = list((1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55)), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "normal", dependence = "iid", param = 1), jump_max = 1 )
n |
Number of time series observations. |
p |
Number of individual. |
nbd_info |
A list containing the neighbourhood information. See |
sp_tp_break |
A |
dist_info |
A list specifying the distribution of the innovation. |
jump_max |
Maximum jump size of the breaks. |
'sp_tp_break' should be a matrix with first column
indicating the neighbourhoods and the second column indicating the time stamps.
For example, 'sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250))' means that
the second neighbourhood has two breaks taking place at
and
the fourth neighbourhood has one break taking place at
.
'dist_info' should be a list containing the following items:
dist: distribution of the innovations, either "normal" or "t".
dependence: iid or , either "iid" or "MA_inf".
param = parameter of the distribution, standard deviation for normal distribution and degree of freedom for t distribution
'jump_max' is set equal in nbd case for convenience.
See ts_hdchange()
for example.
A simulated data matrix.
data_nbd <- sim_hdchange_nbd(n = 300, p = 70, nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) ), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "t", dependence = "iid", param = 5), jump_max = 1)
data_nbd <- sim_hdchange_nbd(n = 300, p = 70, nbd_info = list( (1:9), (2:31), (32:41), (42:70), (3:15), (16:35), (31:55) ), sp_tp_break = rbind(c(2, 50), c(4, 150), c(2, 250)), dist_info = list(dist = "t", dependence = "iid", param = 5), jump_max = 1)
Simulate data without neighbourhood
sim_hdchange_no_nbd( n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "iid", param = 1), jump_max = c(2, 2, 1.5) )
sim_hdchange_no_nbd( n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "iid", param = 1), jump_max = c(2, 2, 1.5) )
n |
Number of time series observations. |
p |
Number of individuals. |
S |
Number of individuals with jumps. |
tau |
An array of length |
dist_info |
A list specifying the distribution of the innovation. |
jump_max |
An array of length |
'dist_info' should be a list containing the following items:
dist: distribution of the innovations, either "normal" or "t".
dependence: iid or MA(), either "iid" or "MA_inf".
param = parameter of the distribution, standard deviation for normal distribution and degree of freedom for t distribution
See ts_hdchange()
for example.
A simulated data matrix.
data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5))
data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5))
Summarize the estimation results
## S3 method for class 'result_nbd' summary(object, ...)
## S3 method for class 'result_nbd' summary(object, ...)
object |
An S3 object of class 'result_nbd' created by |
... |
Additional arguments. |
See hdchange()
for examples.
No return value. Presents the summary of the test and estimation results.
Summarize the estimation results
## S3 method for class 'result_no_nbd' summary(object, ...)
## S3 method for class 'result_no_nbd' summary(object, ...)
object |
An S3 object of class 'result_no_nbd' created by |
... |
Additional arguments. |
See hdchange()
for examples.
No return value. Presents the summary of the test and estimation results.
Test the existence of change-points in the data
test_existence(hdobj, display = TRUE)
test_existence(hdobj, display = TRUE)
hdobj |
An S3 object of class 'no_nbd' or 'nbd' generated
by |
display |
A logical. If 'display = TRUE', the test statistics and critical values will be printed. |
See hdchange()
for examples.
A list containing the following elements:
'test_stats' The test statistics
.
'critical_values' The critical values.
'stat_all' An array of .
'critical_value_alpha' The threshold value depending on alpha.
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) test <- test_existence(ts_no_nbd, display = TRUE)
# generate data data_no_nbd <- sim_hdchange_no_nbd(n = 200, p = 30, S = 30, tau = c(40, 100, 160), dist_info = list(dist = "normal", dependence = "MA_inf", param = 1), jump_max = c(2, 2, 1.5)) # construct no_nbd object ts_no_nbd <- ts_hdchange(data_no_nbd, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) test <- test_existence(ts_no_nbd, display = TRUE)
This function creates an S3 object of class 'no_nbd' or 'nbd' containing the
initialising information supplied to the main function hdchange()
.
'no_nbd' or 'nbd' are constructed depending on whether the
neighbourhood information is provided. The resulting object will be used in the
test and estimation functions.
ts_hdchange( data, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-05, quantiles = c(0.01, 0.05, 0.1), nbd_info = NULL )
ts_hdchange( data, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-05, quantiles = c(0.01, 0.05, 0.1), nbd_info = NULL )
data |
p by n data matrix, n = number of time series observations, p = cross-sectional dimension. |
window_size |
|
m |
Number of blocks in long-run variance estimation, 8 by default. |
h |
Parameter in long-run variance estimation, 1 by default. |
N_rep |
Number of repetitions in MC simulation. |
alpha |
A small positive number controlling for the threshold in break estimation. |
quantiles |
An array of quantiles for critical values. |
nbd_info |
A list containing the neighbourhood information, NULL by default indicating no neighbourhoods. |
'nbd_info' indicates the location of individuals in the data matrix.
For example, 'nbd_info = list(c(1:10), c(25:35), c(7:18))' means that
there are three neighbourhoods. The first neighbourhood contains from the 1st
to 10th individuals and the same rule applies to the rest of neighbourhoods.
The neighbourhoods are allowed to be overlapped. See also the illustrating
example in hdchange()
.
The return value is an S3 object of class 'no_nbd' or 'nbd'. It contains a list of the following items:
data, m, h, N_rep, alpha, quantiles, and nbd_info are the same as in the arguments.
n = number of time series observations.
p = cross-sectional dimension.
b = bandwith parameter .
Li, J., Chen, L., Wang, W. and Wu, W.B., 2022. Inference for Change Points in High-Dimensional Time Series via a Two-Way MOSUM.
arXiv preprint arXiv:2208.13074.
data <- covid_data # No neighbourhood case ts_no_nbd <- ts_hdchange(data, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) # Neighbourhood case ts_nbd <- ts_hdchange(data, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1), nbd_info = list(c(1:10), c(25:35), c(7:18)))
data <- covid_data # No neighbourhood case ts_no_nbd <- ts_hdchange(data, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1)) # Neighbourhood case ts_nbd <- ts_hdchange(data, window_size = 30, m = 8, h = 1, N_rep = 999, alpha = 1e-5, quantiles = c(0.01, 0.05, 0.1), nbd_info = list(c(1:10), c(25:35), c(7:18)))