TFmetrics {L0TFinv} | R Documentation |
Print four metrics about change point detection results
Description
Prints four metrics to compare the quality of change point detection results.
Usage
TFmetrics(y0, tau = NULL, yhat, cpts = NULL)
Arguments
y0 |
The underlying trend |
tau |
The locations of change points in the underlying trend |
yhat |
The fitted trend |
cpts |
The positions of the fitted change points |
Details
\hat{\boldsymbol{\tau}}
represents the estimated change point positions, while \boldsymbol{\tau}
denotes the locations of change points in the underlying trend.
d_H=\frac{1}{n} \max \{\max_k \min_j |\tau_j-\hat{\tau}_k|,\max_j \min_k |\tau_j-\hat{\tau}_k|\}.
Note that the number of \hat{\boldsymbol{\tau}}
and \boldsymbol{\tau}
does not need to be the same.
Value
MSE |
The mean square error between the fitted trend and the underlying trend |
MAD |
The median absolute deviation between the fitted trend and the underlying trend |
dH |
Hausdorff Distance (dH) measures the accuracy of the estimated change points |
nknot |
The number of detected change points |
Examples
tau = c(0.1, 0.3, 0.4, 0.7, 0.85)
h = c(-1, 5, 3, 0, -1, 2)
n = 500
BlocksData <- SimuBlocksInv(n = n, sigma = 0.2, seed = 50, tau = tau ,h = h)
res <- L0TFinv.opt(y=BlocksData$y, kmax=10, q=0, first=0.01, last=1, penalty="bic")
metrics <- TFmetrics(BlocksData$y0,BlocksData$tau,res$yopt,res$Aopt/n)
print(metrics)
tau1 = c(0.1, 0.3, 0.4, 0.7, 0.85)
h1 = c(-1, 5, 3, 0, -1, 2)
a0 = -10
n1 = 2000
WaveData <- SimuWaveInv(n = n1, sigma = 0.1, seed = 50, tau = tau1, h = h1, a0 = a0)
res1 <- L0TFinv.fix(y=WaveData$y, k=20, q=1, first=0, last=0.99)
metrics1 <- TFmetrics(WaveData$y0,WaveData$tau,res1$y.all[,5],res1$A.all[[5]]/n1)
print(metrics1)