library("cpss")
set.seed(666)
n <- 2048
tau <- c(205, 267, 308, 472, 512, 820, 902, 1332, 1557, 1598, 1659)
seg_len <- diff(c(0, tau, n))
mu <- rep(c(0, 14.64, -3.66, 7.32, -7.32, 10.98, -4.39, 3.29, 19.03, 7.68, 15.37, 0), seg_len)
ep <- 7 * rnorm(n)
y <- mu + ep
# \donttest{
res <- cpss.mean(y, algorithm = "SN", ncps_max = 20)
summary(res)
# 205 267 307 471 512 820 897 1332 1557 1601 1659
plot(res, type = "scatter")
plot(res, type = "path")
out <- update(res, dim_update = 12)
out@cps
# 205 267 307 471 512 820 897 1332 1557 1601 1659 1769
# coef(out)
# }
Run the code above in your browser using DataLab