cpt.range-class: Class "cpt.range"

Description Objects from the Class Slots Methods Author(s) See Also Examples

Description

A class for changepoint objects that return more than 1 segmentation. Inherits from cpt class.

Objects from the Class

Objects can be created by calls of the form new("cpt.range", ...).

new("cpt.range", ...):

creates a new object with class cpt.range

Slots

cpts.full:

Object of class "matrix", each row of the matrix is a different segmentation of the data (different set of changepoints).

pen.value.full:

Object of class "vector", each element is the penalty used to create the set of changepoints in the corresponding row of cpts.full.

The remaining slots are inherited from the cpt class.

data.set:

Object of class "ts", a coerced time series of the original data. Inherited from cpt class.

cpttype:

Object of class "character", the type of changepoint that was identified. Inherited from cpt class.

method:

Object of class "character", the method that was used to search for changepoints. Inherited from cpt class.

test.stat:

Object of class "character", the test statistic for the analysis of the data. Inherited from cpt class.

pen.type:

Object of class "character", the penalty type specified in the analysis. Inherited from cpt class.

pen.value:

Object of class "numeric", the value of the penalty used in the analysis. Inherited from cpt class.

minseglen:

Object of class "numeric", the minimum segment length (no. of observations between changepoints) used in the analysis. Inherited from cpt class.

cpts:

Object of class "numeric", vector of optimal changepoints identified. Inherited from cpt class.

ncpts.max:

Object of class "numeric", maximum number of changepoint that can be identified. Inherited from cpt class.

param.est:

Object of class "list", list where each element is a vector of parameter estimates, if requested. Inherited from cpt class.

date:

Object of class "character", date and time the changepoint analysis was run. Inherited from cpt class.

version:

Object of class "character", version number of the package used when the analysis was run. Inherited from cpt class.

Methods

cpts.full

signature(object = "cpt.range"): retrieves cpts.full slot

pen.value.full

signature(object = "cpt.range"): retrieves pen.value.full slot

cpts.full<-

signature(object = "cpt.range"): replaces cpts.full slot

param

signature(object="cpt.range",ncpts=NA): creates parameter estimates for the segmentation with ncpts number of changepoints. If ncpts=NA then the optimal set of changepoints according to the set penalty is used.

pen.value.full<-

signature(object = "cpt.range"): replaces pen.value.full slot

plot

signature(object="cpt.range",ncpts=NA,diagnostic=FALSE): by default plots the optimal segmentation as for class="cpt". If ncpts is specified then plots the segmentation for ncpts number of changepoints. If diagnostic=TRUE then produces a diagnostic plot to aide selection of the number of changes.

print

signature(object = "cpt.range"): prints details of the cpt.range object including summary

summary

signature(object = "cpt.range"): prints a summary of the cpt.range object

Author(s)

Rebecca Killick

See Also

cpts.full-methods,cpt,cpt.mean,cpt.var,cpt.meanvar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
showClass("cpt.range") # shows the structure of the cpt.range class

x=new("cpt.range") # creates a new object with the cpt.range class defaults
cpts(x) # retrieves the cpts slot from x
cpts(x)<-c(10,50,100) # replaces the cpts slot from x with c(10,50,100)

# Example of multiple changes in variance at 50,100,150 in simulated normal data
set.seed(1)
x=c(rnorm(50,0,1),rnorm(50,0,10),rnorm(50,0,5),rnorm(50,0,1))
out=cpt.var(x,pen.value=c(log(length(x)),10*log(length(x))),penalty="CROPS",method="PELT")
print(out) # prints details of the analysis including a summary
summary(out)
plot(out,diagnostic=TRUE) # a diagnostic plot to identify number of changepoints
# looks like the segmentation with 3 changepoints, 50,99,150 is the most appropriate
plot(out,ncpts=3) # plots the segmentation for 3 changes
logLik(out,ncpts=3) 
# raw likelihood of the data with changepoints, second value is likelihood + penalty

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Successfully loaded changepoint package version 2.2.2
 NOTE: Predefined penalty values changed in version 2.2.  Previous penalty values with a postfix 1 i.e. SIC1 are now without i.e. SIC and previous penalties without a postfix i.e. SIC are now with a postfix 0 i.e. SIC0. See NEWS and help files for further details.
Class "cpt.range" [package "changepoint"]

Slots:
                                                                  
Name:       cpts.full pen.value.full       data.set        cpttype
Class:         matrix        numeric             ts      character
                                                                  
Name:          method      test.stat       pen.type      pen.value
Class:      character      character      character        numeric
                                                                  
Name:       minseglen           cpts      ncpts.max      param.est
Class:        numeric        numeric        numeric           list
                                    
Name:            date        version
Class:      character      character

Extends: "cpt"
numeric(0)
[1] "Maximum number of runs of algorithm = 7"
[1] "Completed runs = 2"
[1] "Completed runs = 3"
[1] "Completed runs = 4"
[1] "Completed runs = 6"
Class 'cpt' : Changepoint Object
       ~~   : S4 class containing 14 slots with names
              cpts.full pen.value.full data.set cpttype method test.stat pen.type pen.value minseglen cpts ncpts.max param.est date version 

Created on  : Thu May  4 11:08:19 2017 

summary(.)  :
----------
Created Using changepoint version 2.2.2 
Changepoint type      : Change in variance 
Method of analysis    : PELT 
Test Statistic  : Normal 
Type of penalty       : CROPS with value, 5.298317 52.98317 
Minimum Segment Length : 2 
Maximum no. of cpts   : Inf 
Changepoint Locations :  
Range of segmentations:
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]   50   77   79   99  114  133  150
[2,]   50   99  114  133  150   NA   NA
[3,]   50   99  140  150   NA   NA   NA
[4,]   50   99  150   NA   NA   NA   NA
[5,]   50  150   NA   NA   NA   NA   NA

 For penalty values: 5.298317 5.548538 6.149305 7.083099 26.59226 
Created Using changepoint version 2.2.2 
Changepoint type      : Change in variance 
Method of analysis    : PELT 
Test Statistic  : Normal 
Type of penalty       : CROPS with value, 5.298317 52.98317 
Minimum Segment Length : 2 
Maximum no. of cpts   : Inf 
Changepoint Locations :  
Range of segmentations:
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]   50   77   79   99  114  133  150
[2,]   50   99  114  133  150   NA   NA
[3,]   50   99  140  150   NA   NA   NA
[4,]   50   99  150   NA   NA   NA   NA
[5,]   50  150   NA   NA   NA   NA   NA

 For penalty values: 5.298317 5.548538 6.149305 7.083099 26.59226 
   -like -likepen 
925.8085 947.0578 
Warning message:
In .local(object, ...) : Not changed to be -2*logLik

changepoint documentation built on May 2, 2019, 2:05 a.m.