I'm trying to find change points of multiple data using for loop.
In the for loop, each data needs to be typed their own ncpts value(which is 3 in the codes below).
So, I want to know how to get the vector or list of possible ncpts given in the error message which I can use in the for loop.
The codes below are just for checking.
library(changepoint)
set.seed(1)
x=c(rnorm(50,0,1),rnorm(50,5,3),rnorm(50,10,2))
out=cpt.meanvar(x, pen.value=c(2*log(length(x)),100*log(length(x))),penalty="CROPS",method="PELT")
cpts.full(out) #range of segmentations
pen.value.full(out)
plot(out,diagnostic =TRUE)
plot(out, ylab='Data', ncpts=3)
Error in .local(x, ...) :
Your input object doesn't have a segmentation with the requested number of changepoints.
Possible ncpts are: 15,11,9,7,5,2,1,0
Created on 2020-09-25 by the reprex package (v0.3.0)