SNSeg_Uni | R Documentation |
The function SNSeg_Uni
is a SN change point estimation procedure for a
univariate time series based on the change in a single or multiple parameters
. It also detect changes in correlation between two univariate time series.
SNSeg_Uni(
ts,
paras_to_test,
confidence = 0.9,
grid_size_scale = 0.05,
grid_size = NULL,
plot_SN = TRUE,
est_cp_loc = TRUE
)
ts |
A univariate time series expressed as a numeric vector. when the argument paras_to_test is specified as "bivcor", the correlation between bivariate time series, the input ts must be an n by 2 matrix |
paras_to_test |
The parameters that SN algorithm aim to examine, which are presented as a string, a number, or a combination of both. Available choices of paras_to_test include "mean", "variance", "acf", "bivcor" and a numeric value of quantile between 0 and 1. In the scenario where the input ts is a univariate time series, users are allowed to enter a combination of parameters for paras_to_test except "bivcor". Users can also set up their own function as the input of "paras_to_test". If so,
the user-fined function should use the univariate time series as the input and
return a numeric value as the output. Please see the help vignette for more details
by running |
confidence |
Confidence level of SN tests as a numeric value. Available choices of confidence levels contain 0.9, 0.95, 0.99, 0.995 and 0.999. The default is set to 0.9. |
grid_size_scale |
A numeric value of the trimming parameter and only in use if grid_size = NULL. Users are allowed to choose any grid_size_scale between 0.05 and 0.5. A warning will be given if it is outside the range. |
grid_size |
Local window size h to compute the critical value for SN test. Since grid_size = n*grid_size_scale, where n is the length of time series, this function will compute the grid_size_scale by dividing n from grid_size when it is not NULL. |
plot_SN |
Boolean value to plot the time series or not. The default setting is FALSE. |
est_cp_loc |
Boolean value to plot a red solid vertical line for estimated change-point locations if est_cp_loc = TRUE |
SNSeg_Uni
returns an S3 object of class "SNSeg_Uni" including
the time series, the type of parameter to be tested, the local window size to
cover a change point, the estimated change-point locations, the confidence level
and the critical value of the SN test. It also generates a time series segmentation
plot when plot_SN = TRUE
.
ts
A numeric vector or two-dimensional matrix of the input time series.
paras_to_test
A character, numeric value, a function or vector of the parameter(s) used for the SN test. If it is a function defined by the user, please refer to the section "test in a general functional" in the help vignette for more details on how to write the function correctly.
grid_size
A numeric value of the window size.
SN_sweep_result
A list of matrices where each matrix consists of four columns: (1) SN-based test statistic for each change-point location (2) Change-point location (3) Lower bound of the local window and (4) Upper bound of the local window.
est_cp
A vector containing the locations of the estimated change-points.
confidence
Confidence level of SN test as a numeric value.
critical_value
Critical value of the SN-based test statistic.
Users can apply the functions summary.SN
to compute the parameter estimate
of each segment separated by the detected change-points. An additional function
plot.SN
can be used to plot the time series with estimated change-points.
Users can set the option plot_SN = TRUE
or use the function plot.SN
to plot the time series.
It deserves to note that some change-points could be missing due to the constraint
on grid_size_scale
or related grid_size
that grid_size_scale
has a minimum value of 0.05. Therefore, SNCP claims no change-points within the
first ngrid_size_scale
or the last ngrid_size_scale
time points.
This is a limitation of the function SNSeg_Uni
.
For more examples of SNSeg_Uni
see the help vignette:
vignette("SNSeg", package = "SNSeg")
# code to simulate a univariate time series
set.seed(7)
ts <- MAR_Variance(2, "V1")
ts <- ts[,2]
# test the change in a single parameter (variance)
# grid_size defined
result <- SNSeg_Uni(ts, paras_to_test = "variance", confidence = 0.9,
grid_size_scale = 0.05, grid_size = 67,
plot_SN = TRUE, est_cp_loc = TRUE)
# estimated change-point locations
result$est_cp
# For more examples of change in a single or multiple parameters, please run
# the command: vignette("SNSeg", package = "SNSeg")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.