rkillick/changepoint

-1 result returns

Closed this issue · 1 comments

I tried detect change points in R. I've ran following MWE in R.

``
library(changepoint)
mydata = c(2000, 2100, 2400, 2000, 4500, 4000, 10000, 12000, 11000, 10000 ,10500, 12000, 10000, 5000, 4000, 4500, 5100, 3800, 4100, 4500)
cpoints=cpt.mean(mydata, penalty='Manual', pen.value='100000000*diffparam', method="PELT", class=TRUE)
plot(cpoints,cpt.width=3,cpt.col='red')

cpts(cpoints)
param.est(cpoints)
``

I am expecting 3 changepoints (same in graph). However, cpts(cpoints) returns only two detected change points. On the other hand, param.est(cpoints) returns three results. Am I missing something?

I see from your CrossValidated post:
https://stats.stackexchange.com/questions/353207/r-changepoint-different-number-of-outputs

What isn't said that is that you will always have 1 more in param.est(cpoints) than cpts(cpoints) as there is 1 more segment than changepoint. You can get 3 by using cpoints@cpts which includes n as then end of the third segment.