The documentation of the changepoint package says that a changepoint is denoted as the first observation of the new segment / regime. However, when I try to detect the changepoints in this very simple example, it gives me the last observation of the segment:
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)
As Roland highlighted this is a documentation bug. This has been reported here: https://github.com/rkillick/changepoint/issues/13 and is fixed in the github version. It will be pushed to CRAN with the next release.
This has been an open issue on StackOverflow for a long time, if alberto had reported this to the maintainer as Roland suggested i'm sure it would have been fixed sooner. A lesson to us all.