Segment a time series using a genetic algorithm
segment_cga.Rd
Segmenting functions for various genetic algorithms
Arguments
- x
A time series
- ...
arguments passed to
changepointGA::GA()
Value
A cga
object. This is just a changepointGA::GA()
object with an additional
slot for data
(the original time series).
Details
segment_cga()
uses the genetic algorithm in GA::ga()
to "evolve" a random
set of candidate changepoint sets, using the penalized objective function
specified by penalty_fn
.
By default, the normal meanshift
model is fit (see fit_meanshift_norm()
)
and the BIC penalty is applied.
Examples
# \donttest{
# Segment a time series using a genetic algorithm
res <- segment_cga(CET)
summary(res)
#> Length Class Mode
#> overbestfit 1 -none- numeric
#> overbestchrom 5 -none- numeric
#> bestfit 11185 -none- numeric
#> bestchrom 5603685 -none- numeric
#> count 1 -none- numeric
#> convg 1 -none- numeric
#> data 366 ts numeric
# Segment a time series using changepointGA
x <- segment(CET, method = "cga")
summary(x)
#>
#> ── Summary of tidycpt object ───────────────────────────────────────────────────
#> → y: Contains 366 observations, ranging from 6.86 to 11.18 .
#> ℹ Segmenter (class cga )
#> → A: Used the Genetic algorithm from the changepointGA package.
#> → τ: Found 4 changepoint(s).
#> → f: Reported a fitness value of 641.45 using the BIC penalty.
#> ℹ Model
#> → M: Fit the arima model.
#> → θ: Estimated 2 parameter(s), for each of 5 region(s).
changepoints(x)
#> [1] 32 40 265 329
# }