cpt.range-class | R Documentation |
A class for changepoint objects that return more than 1 segmentation. Inherits from cpt class.
Objects can be created by calls of the form new("cpt.range", ...)
.
new("cpt.range", ...)
:creates a new object with class cpt.range
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.
signature(object = "cpt.range")
: retrieves cpts.full slot
signature(object = "cpt.range")
: retrieves pen.value.full slot
signature(object = "cpt.range")
: replaces cpts.full slot
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.
signature(object = "cpt.range")
: replaces pen.value.full slot
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.
signature(object = "cpt.range")
: prints details of the cpt.range object including summary
signature(object = "cpt.range")
: prints a summary of the cpt.range object
Rebecca Killick
cpts.full-methods
,cpt
,cpt.mean
,cpt.var
,cpt.meanvar
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.