multiple.reg.norm(data,mul.method="PELT",penalty="SIC",value=0,Q=5,class=TRUE,param.estimates=TRUE)
cpt
is returned.cpts
contains the changepoints that are solely returned if class=FALSE. The structure of cpts
is as follows.
If data is a matrix (single dataset) then a vector/list is returned depending on the value of mul.method. If data is an array (multiple datasets) then a list is returned where each element in the list is either a vector or list depending on the value of mul.method.If mul.method is PELT then a vector is returned:
PELT Algorithm: Killick, R. and Fearnhead, P. and Eckley, I.A. (2011) An exact linear time search algorithm for multiple changepoint detection, Submitted
Binary Segmentation: Scott, A. J. and Knott, M. (1974) A Cluster Analysis Method for Grouping Means in the Analysis of Variance, Biometrics 30(3), 507--512
Segment Neighbourhoods: Auger, I. E. And Lawrence, C. E. (1989) Algorithms for the Optimal Identification of Segment Neighborhoods, Bulletin of Mathematical Biology 51(1), 39--54
multiple.mean.norm
,multiple.var.norm
,multiple.meanvar.norm
,cpt.reg
,PELT.reg.norm
,binseg.reg.norm
,single.reg.norm
,segneigh.reg.norm
,cpt
# Example of multiple changes in regression at 100,250 in simulated data with zero-mean normal errors
set.seed(1)
x=1:400
y=c(0.01*x[1:100],3.5-0.02*x[101:250],-15+0.05*x[251:400])
ynoise=y+rnorm(400,0,0.2)
yx=cbind(ynoise,1,x)
multiple.reg.norm(yx,mul.method="BinSeg",penalty="Manual",value="4*log(n)",Q=5,class=FALSE) # returns optimal number of changepoints is 2, locations are 100,250.
# Example multiple datasets where the first has multiple changes in regression and the second has no change in regression
set.seed(1)
x1=1:400
y1=c(0.01*x1[1:100],3.5-0.02*x1[101:250],-15+0.05*x1[251:400])
ynoise1=y1+rnorm(400,0,0.2)
yx1=cbind(ynoise1,1,x1)
x2=1:400
y2=0.01*x2
ynoise2=y2+rnorm(400,0,0.2)
yx2=cbind(ynoise2,1,x2)
data=array(0,dim=c(2,400,3))
data[1,,]=yx1; data[2,,]=yx2
multiple.reg.norm(data,mul.method="SegNeigh",penalty="Asymptotic",value=0.01,Q=5,class=FALSE) # returns list that has two elements, the first has 2 changes in regression at 100,250 and the second has no changes in regression
ans=multiple.reg.norm(data,mul.method="PELT",penalty="Asymptotic",value=0.01)
cpts(ans[[1]]) # same results as for the SegNeigh method.
cpts(ans[[2]]) # same results as for the SegNeigh method.
Run the code above in your browser using DataLab