How to incorporate the maximum number of change points to search for to the function named cpt.np?

Hello,

Is there a way to incorporate the maximum number of change points to search for to the function named cpt.np in changepoint.np package?

Any help or suggestion would be highly appreciated. Thank you.

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. It can be difficult to reverse engineer a question without one, especially with a function that one hasn't yet used. Making it easy for the community works best both ways.

The example in help(cpt.np) is helpful:

suppressPackageStartupMessages(library(changepoint.np))

set.seed(12)

J <- function(x){
   (1+sign(x))/2
 }

n <- 1000
tau <- c(0.1,0.13,0.15,0.23,0.25,0.4,0.44,0.65,0.76,0.78,0.81)*n
h <- c(2.01, -2.51, 1.51, -2.01, 2.51, -2.11, 1.05, 2.16, -1.56, 2.56, -2.11)
sigma <- 0.5
t <- seq(0,1,length.out = n)
data <- array()
for (i in 1:n){
   data[i] <- sum(h*J(n*t[i] - tau)) + (sigma * rnorm(1))
}

out <- cpt.np(data, penalty = "SIC",method="PELT",test.stat="empirical_distribution",
              class=TRUE,minseglen=2, nquantiles =4*log(length(data)))
cpts(out)
#>  [1] 100 130 150 230 250 400 440 650 760 780 810

Created on 2020-04-04 by the reprex package (v0.3.0)

Along with the documentation, I take it that the purpose of the function is to process the entire argument to find the optimal changepoints. Returning 11 changepoints from a 1,000 element array doesn't seem like something that needs rationing.

But I could be missing something, the motivation for limiting the number of changepoints?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.