# Example of multiple changes in variance at 50,100,150 in simulated data
set.seed(1)
x=c(rnorm(50,0,1),rnorm(50,0,10),rnorm(50,0,5),rnorm(50,0,1))
multiple.var.css(x,mul.method="BinSeg",penalty="Manual",pen.value="log(2*log(n))",Q=5,class=FALSE)
#returns optimal number of changepoints is 4, locations are 50,53,99,150.
# Example multiple datasets where the first row has multiple changes in variance and the second row
#has no change in variance
set.seed(10)
x=c(rnorm(50,0,1),rnorm(50,0,10),rnorm(50,0,5),rnorm(50,0,1))
y=rnorm(200,0,1)
z=rbind(x,y)
multiple.var.css(z,mul.method="SegNeigh",penalty="Asymptotic",pen.value=0.01,Q=5,class=FALSE)
# returns list that has two elements, the first has 3 changes in variance at 52,100,149 and the
#second has no changes in variance
ans=multiple.var.css(z,mul.method="SegNeigh",penalty="Asymptotic",pen.value=0.01)
cpts(ans[[1]]) # same results as for class=FALSE.
cpts(ans[[2]]) # same results as for class=FALSE.
Run the code above in your browser using DataLab