cptDist | R Documentation |
This function is to calculate the distance metric (Shi et al., 2022) between
two changepoint configurations, C_{1}=\{\tau_{1}, \ldots, \tau_{m}\}
and C_{2}=\{\eta_{1}, \ldots, \eta_{k}\}
, where \tau
's are the
changepoint locations.
cptDist(tau1, tau2, N)
tau1 |
A vector contains the changepoint locations for |
tau2 |
A vector contains the changepoint locations for |
N |
The simulated time series sample size. Two changepoint configurations
should have the same |
The pairwise distance was proposed by Shi et al. (2022),
d(C_{1}, C_{2})=|m-k|+ \min(A(C_{1}, C_{2})),
where m
is the number of changepoints in configuration C_{1}
and
k
is the number of changepoints in configuration C_{2}
.
The term \min(A(C_{1}, C_{2}))
reflects the cost of matching
changepoint locations between C_{1}
and C_{2}
and can be calculated
using the linear assignment method. Details can be found in Shi et al. (2022).
Note: if one configuration doesn't contain any changepoints (valued NULL
),
the distance is defined as |m-k|
. The function can also be used
to examine changepoint detection performance in simulation studies. Given the
true changepoint configuration, C_{true}
, used in generating the time
series, the calculated distance between the estimated multiple changepoint
configuration, C_{est}=\{\eta_{1}, \ldots, \eta_{k}\}
, and C_{true}
can be used to evaluate the performance of the detection algorithm.
dist |
The calculated distance. |
Shi, X., Gallagher, C., Lund, R., & Killick, R. (2022). A comparison of single and multiple changepoint techniques for time series data. Computational Statistics & Data Analysis, 170, 107433.
N = 100
# both tau1 and tau2 has detected changepoints
tau2 = c(25, 50, 75)
tau1 = c(20, 35, 70, 80, 90)
cptDist(tau1=tau1, tau2=tau2, N=N)
# either tau1 or tau2 has zero detected changepoints
cptDist(tau1=tau1, tau2=NULL, N=N)
cptDist(tau1=NULL, tau2=tau2, N=N)
# both tau1 and tau2 has zero detected changepoints
cptDist(tau1=NULL, tau2=NULL, N=N)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.