pad_tau(): an integer vector that starts with 0 and ends in n.
unpad_tau(): an integer vector stripped of its first and last entries.
is_valid_tau(): a logical if all of the entries are between 2 and n−1.
regions_tau(): A base::factor()
validate_tau(): an integer vector with only the base::unique()
entries between 2 and n−1, inclusive.
Details
If a time series contains n observations, we label them from 1 to n. Neither the 1st point nor the nth point can be a changepoint, since the regions they create on one side would be empty. However, for dividing the time series into non-empty segments, we start with 1, add n+1, and then divide the half-open interval [1,n+1) into half-open subintervals that define the regions.
pad_tau() ensures that 1 and n+1 are included.
unpad_tau() removes 1 and n+1, should they exist.
is_valid_tau() checks to see if the supplied set of changepoints is valid
validate_tau() removes duplicates and boundary values.
Examples
# Anything less than 2 is not allowedis_valid_tau(0, length(DataCPSim))is_valid_tau(1, length(DataCPSim))# Duplicates are allowedis_valid_tau(c(42,42), length(DataCPSim))is_valid_tau(826, length(DataCPSim))# Anything greater than \eqn{n} (in this case 1096) is not allowedis_valid_tau(1096, length(DataCPSim))is_valid_tau(1097, length(DataCPSim))# Always return a factor with half-open intervals on the rightregions_tau(c(42,330),1096)# Anything less than 2 is not allowedvalidate_tau(0, length(DataCPSim))validate_tau(1, length(DataCPSim))validate_tau(826, length(DataCPSim))# Duplicates are removedvalidate_tau(c(826,826), length(DataCPSim))# Anything greater than \eqn{n} (in this case 1096) is not allowedvalidate_tau(1096, length(DataCPSim))validate_tau(1097, length(DataCPSim))# Fix many problemsvalidate_tau(c(-4,0,1,4,5,5,824,1096,1097,182384), length(DataCPSim))