max_SNsweep: SN-based test statistic segmentation plot for univariate,...

View source: R/max_SNsweep.R

max_SNsweepR Documentation

SN-based test statistic segmentation plot for univariate, mulitivariate and high-dimensional time series

Description

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.

Usage

max_SNsweep(SN_result, plot_SN = TRUE, est_cp_loc = TRUE, critical_loc = TRUE)

Arguments

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

Value

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")

Examples


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")}



SNSeg documentation built on June 22, 2024, 10:50 a.m.