max_SNsweep | R Documentation |
The function max_SNsweep
allows users to compute and plot the SN-based
test statistics along with the identified change-points from functions
SNSeg_Uni, SNSeg_Multi, or SNSeg_HD.
max_SNsweep(SN_result, plot_SN = TRUE, est_cp_loc = TRUE, critical_loc = TRUE)
SN_result |
The output of functions SNSeg_Uni, SNSeg_Multi or SNSeg_HD. |
plot_SN |
A boolean value to return an SN-based segmentation plot if plot_SN = TRUE. |
est_cp_loc |
A boolean value to plot a red solid vertical line for estimated change-point locations if est_cp_loc = TRUE. |
critical_loc |
A boolean value to plot a blue dashed horizontal line for the critical value if critical_loc = TRUE |
Returns a vector of numeric values of calculated SN-based statistics for each time point. It also generates a SN-based test statistics segmentation plot with the estimated change-points.
For more examples of max_SNsweep
please see the SNSeg vignette:
vignette("SNSeg", package = "SNSeg")
set.seed(7)
n <- 2000
reptime <- 2
cp_sets <- round(n*c(0,cumsum(c(0.5,0.25)),1))
mean_shift <- c(0.4,0,0.4)
rho <- -0.7
ts <- MAR(n, reptime, rho)
no_seg <- length(cp_sets)-1
for(index in 1:no_seg){
tau1 <- cp_sets[index]+1
tau2 <- cp_sets[index+1]
ts[tau1:tau2,] <- ts[tau1:tau2,] + mean_shift[index]
}
ts <- ts[,2]
result <- SNSeg_Uni(ts, paras_to_test = "mean", confidence = 0.9,
grid_size_scale = 0.05, grid_size = 116,
plot_SN = FALSE, est_cp_loc = FALSE)
# Generate SN-based test statistic segmentation plot
# To get the computed SN-based statistics, please run the command "test_stat"
test_stat <- max_SNsweep(result, plot_SN = TRUE, est_cp_loc = TRUE,
critical_loc = TRUE)
# For more examples of \code{max_SNsweep} see the help vignette:
# \code{vignette("SNSeg", package = "SNSeg")}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.