Skip to contents

Container class for tidycpt objects

Value

A tidycpt object.

Details

Every tidycpt object contains:

  • segmenter: The object returned by the underlying changepoint detection algorithm. These can be of arbitrary class. Use as.segmenter() to retrieve them.

  • model: A model object inheriting from mod_cpt, as created by as.model() when called on the segmenter.

  • elapsed_time: The clock time that passed while the algorithm was running.

  • time_index: If available, the labels for the time indices of the time series.

Examples

# Segment a time series using PELT
x <- segment(CET, method = "pelt")
class(x)
#> [1] "tidycpt"
str(x)
#> List of 4
#>  $ segmenter   :Formal class 'cpt' [package "changepoint"] with 12 slots
#>   .. ..@ data.set : Time-Series [1:362] from 1 to 362: 8.87 9.1 9.78 9.52 8.63 9.34 8.29 9.86 8.52 9.51 ...
#>   .. ..@ cpttype  : chr "mean and variance"
#>   .. ..@ method   : chr "PELT"
#>   .. ..@ test.stat: chr "Normal"
#>   .. ..@ pen.type : chr "MBIC"
#>   .. ..@ pen.value: num 23.6
#>   .. ..@ minseglen: num 2
#>   .. ..@ cpts     : int [1:6] 55 57 309 311 330 362
#>   .. ..@ ncpts.max: num Inf
#>   .. ..@ param.est:List of 2
#>   .. .. ..$ mean    : num [1:6] 8.79 9.44 9.24 9.32 9.51 ...
#>   .. .. ..$ variance: num [1:6] 0.368 0 0.358 0 0.155 ...
#>   .. ..@ date     : chr "Wed Apr 24 21:56:29 2024"
#>   .. ..@ version  : chr "2.2.4"
#>  $ model       :List of 6
#>   ..$ data         : Time-Series [1:362] from 1 to 362: 8.87 9.1 9.78 9.52 8.63 9.34 8.29 9.86 8.52 9.51 ...
#>   ..$ tau          : int [1:5] 55 57 309 311 330
#>   ..$ region_params: tibble [6 × 3] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ region           : chr [1:6] "[0,55)" "[55,57)" "[57,309)" "[309,311)" ...
#>   .. ..$ param_mu         : num [1:6] 8.8 9.04 9.23 9.48 9.49 ...
#>   .. ..$ param_sigma_hatsq: Named num [1:6] 0.3744 0.16 0.3575 0.0256 0.1518 ...
#>   .. .. ..- attr(*, "names")= chr [1:6] "[0,55)" "[55,57)" "[57,309)" "[309,311)" ...
#>   ..$ model_params : NULL
#>   ..$ fitted_values: num [1:362] 8.8 8.8 8.8 8.8 8.8 ...
#>   ..$ model_name   : chr "meanvar"
#>   ..- attr(*, "class")= chr "mod_cpt"
#>  $ elapsed_time: 'difftime' num 0.00920915603637695
#>   ..- attr(*, "units")= chr "secs"
#>  $ time_index  : Date[1:362], format: "1659-01-01" "1660-01-01" ...
#>  - attr(*, "class")= chr "tidycpt"