Compare various models or algorithms for a given changepoint set
compare_models.Rd
Compare various models or algorithms for a given changepoint set
Arguments
- x
A tidycpt object
- ...
currently ignored
Details
A tidycpt object has a set of changepoints returned by the
algorithm that segmented the time series.
That changepoint set was obtained using a specific model.
Treating this changepoint set as fixed, the compare_models()
function
fits several common changepoint models to the time series and changepoint
set, and returns the results of glance()
.
Comparing the fits of various models could lead to improved understanding.
Alternatively, compare_algorithms()
runs several fast changepoint detection
algorithms on the original time series, and consolidates the results.
Examples
# Segment a times series using PELT
x <- segment(CET, method = "pelt")
# Compare models
compare_models(x)
#> # A tibble: 8 × 12
#> pkg version algorithm params num_cpts rmse logLik AIC BIC MBIC MDL
#> <chr> <pckg_> <chr> <list> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 tidych… 0.0.1 nhpp <dbl> 5 0.579 -297. 630. 700. 664. 692.
#> 2 tidych… 0.0.1 splinesh… <dbl> 5 0.553 -299. 646. 739. 668. 713.
#> 3 tidych… 0.0.1 trendshi… <dbl> 5 0.565 -306. 650. 724. 682. 716.
#> 4 tidych… 0.0.1 meanshif… <dbl> 5 0.569 -309. 644. 694. 688. 704.
#> 5 tidych… 0.0.1 trendshi… <dbl> 5 0.574 -312. 661. 731. 695. 723.
#> 6 tidych… 0.0.1 meanvar <NULL> 5 0.579 -316. 666. 732. 702. 724.
#> 7 tidych… 0.0.1 meanshif… <dbl> 5 0.579 -316. 656. 703. 702. 713.
#> 8 tidych… 0.0.1 meanvar <NULL> 5 0.579 -316. 666. 732. 702. 724.
#> # ℹ 1 more variable: BMDL <dbl>
# Compare algorithms
compare_algorithms(x)
#> Seeding initial population with probability: 0.0162752602536624
#> # A tibble: 6 × 8
#> pkg version algorithm seg_params model_name criteria fitness elapsed_time
#> <chr> <pckg_> <chr> <list> <chr> <chr> <dbl> <drtn>
#> 1 tidycha… 0.0.1 manual <list [0]> meanshift… BIC 759. 0.003 secs
#> 2 changep… 2.2.4 PELT <list [1]> meanvar MBIC -Inf 0.009 secs
#> 3 changep… 2.2.4 PELT <list [1]> meanvar MBIC -Inf 0.010 secs
#> 4 wbs 1.4 Wild Bin… <list [1]> meanshift… MBIC 0 0.023 secs
#> 5 GA 3.2.4 Genetic <list [1]> meanshift… BIC 686. 0.109 secs
#> 6 changep… 2.2.4 BinSeg <list [1]> meanvar MBIC 644. 0.146 secs