返回段的最后一个点的Changepoint方法

时间:2016-03-31 07:25:08

标签: r

documentation of the changepoint package表示变更点被表示为新段/制度的第一次观察。但是,当我尝试在这个非常简单的示例中检测变更点时,它为我提供了最后段的观察结果:

library(changepoint)
x <- c(1,1,1,1,1,10,10,10,10,10)
res <- cpt.meanvar(x, class=TRUE, method="PELT")

bp <- cpts(res)
# bp contains the point 5
colors <- rep("black", length(x))
colors[bp] <- 'red'
plot(x, col=colors, pch=19, cex=1)

enter image description here

它不应该返回第6个而不是第5个吗?

1 个答案:

答案 0 :(得分:1)

正如Roland强调的那样,这是一个文档错误。这已在此报道: https://github.com/rkillick/changepoint/issues/13 并在github版本中修复。它将在下一个版本推送到CRAN。

这已成为StackOverflow上的一个悬而未决的问题,如果alberto向维护者报告了这一点,因为Roland建议我确定它会更早修复。给我们所有人的教训。