pad_tau | R Documentation |
Pad and unpad changepoint sets with boundary points
pad_tau(tau, n)
unpad_tau(padded_tau)
is_valid_tau(tau, n)
regions_tau(tau, n)
validate_tau(tau, n)
tau |
a numeric vector of changepoint indices |
n |
the length of the original time series |
padded_tau |
Output from |
If a time series contains n
observations, we label them from 1
to n
.
Neither the 1st point nor the n
th 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.
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.
# Anything less than 2 is not allowed
is_valid_tau(0, length(DataCPSim))
is_valid_tau(1, length(DataCPSim))
# Duplicates are allowed
is_valid_tau(c(42, 42), length(DataCPSim))
is_valid_tau(826, length(DataCPSim))
# Anything greater than \eqn{n} (in this case 1096) is not allowed
is_valid_tau(1096, length(DataCPSim))
is_valid_tau(1097, length(DataCPSim))
# Always return a factor with half-open intervals on the right
regions_tau(c(42, 330), 1096)
# Anything less than 2 is not allowed
validate_tau(0, length(DataCPSim))
validate_tau(1, length(DataCPSim))
validate_tau(826, length(DataCPSim))
# Duplicates are removed
validate_tau(c(826, 826), length(DataCPSim))
# Anything greater than \eqn{n} (in this case 1096) is not allowed
validate_tau(1096, length(DataCPSim))
validate_tau(1097, length(DataCPSim))
# Fix many problems
validate_tau(c(-4, 0, 1, 4, 5, 5, 824, 1096, 1097, 182384), length(DataCPSim))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.