require(Segmentor3IsBack);
N=2000
x=c(rnbinom(N,size=1.3,prob=0.7),rnbinom(N,size=1.3,prob=0.2),
rnbinom(N,size=1.3,prob=0.01), rnbinom(N,size=1.3,prob=0.2),
rnbinom(N,size=1.3,prob=0.8));
res=Segmentor(data=x,model=3,Kmax=20);
# Finds the optimal segmentation in up to 20 segments with respect to
#the negative binomial model.
Cr<-SelectModel(res,penalty='oracle',keep=FALSE)
Cr
#chooses the number of segments in the segmentation of x
Run the code above in your browser using DataLab