cptDist: Comparing multiple changepoint configurations by pairwise...

View source: R/cptDist.R

cptDistR Documentation

Comparing multiple changepoint configurations by pairwise distance

Description

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.

Usage

cptDist(tau1, tau2, N)

Arguments

tau1

A vector contains the changepoint locations for C_{1} for comparison. A value NULL is required if there is no changepoint detected.

tau2

A vector contains the changepoint locations for C_{2} for comparison. A value NULL is required if there is no changepoint detected.

N

The simulated time series sample size. Two changepoint configurations should have the same n values.

Details

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.

Value

dist

The calculated distance.

References

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.

Examples

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)

changepointGA documentation built on April 4, 2025, 4:39 a.m.