Extract changepoints
changepoints.Rd
Retrieve the indices of the changepoints identified by an algorithm or model.
Usage
changepoints(x, ...)
# Default S3 method
changepoints(x, ...)
# S3 method for class 'mod_cpt'
changepoints(x, ...)
# S3 method for class 'seg_basket'
changepoints(x, ...)
# S3 method for class 'seg_cpt'
changepoints(x, ...)
# S3 method for class 'tidycpt'
changepoints(x, use_labels = FALSE, ...)
# S3 method for class 'ga'
changepoints(x, ...)
# S3 method for class 'cpt'
changepoints(x, ...)
# S3 method for class 'wbs'
changepoints(x, ...)
Value
a numeric vector of changepoint indices, or, if use_labels
is
TRUE
, a character
of time labels.
Details
tidycpt objects, as well as their segmenter
and model
components,
implement changepoints()
methods.
Note that this function is not to be confused with wbs::changepoints()
,
which returns different information.
For the default
method, changepoints()
will attempt to return the
cpt_true
attribute, which is set by test_set()
.
See also
Other tidycpt-generics:
as.model()
,
as.segmenter()
,
diagnose()
,
fitness()
,
model_name()
Examples
cpts <- segment(DataCPSim, method = "ga", maxiter = 5)
changepoints(cpts$segmenter)
#> x4 x7 x10 x13 x15 x17 x23 x26 x27 x29 x30 x31 x34
#> 4 7 10 13 15 17 23 26 27 29 30 31 34
#> x37 x38 x39 x46 x47 x49 x52 x53 x54 x55 x58 x60 x61
#> 37 38 39 46 47 49 52 53 54 55 58 60 61
#> x62 x63 x64 x65 x66 x67 x70 x71 x77 x78 x79 x80 x82
#> 62 63 64 65 66 67 70 71 77 78 79 80 82
#> x83 x94 x95 x97 x100 x105 x106 x108 x109 x110 x113 x115 x117
#> 83 94 95 97 100 105 106 108 109 110 113 115 117
#> x119 x124 x126 x127 x128 x129 x130 x131 x133 x135 x137 x142 x148
#> 119 124 126 127 128 129 130 131 133 135 137 142 148
#> x155 x158 x163 x165 x166 x167 x169 x172 x173 x174 x175 x176 x178
#> 155 158 163 165 166 167 169 172 173 174 175 176 178
#> x180 x181 x183 x185 x188 x190 x192 x193 x194 x198 x199 x201 x202
#> 180 181 183 185 188 190 192 193 194 198 199 201 202
#> x205 x207 x209 x210 x212 x215 x218 x222 x224 x225 x229 x230 x232
#> 205 207 209 210 212 215 218 222 224 225 229 230 232
#> x236 x238 x240 x241 x243 x245 x249 x253 x257 x259 x260 x262 x265
#> 236 238 240 241 243 245 249 253 257 259 260 262 265
#> x266 x267 x271 x274 x275 x277 x279 x280 x284 x286 x287 x288 x289
#> 266 267 271 274 275 277 279 280 284 286 287 288 289
#> x290 x291 x294 x296 x299 x301 x303 x310 x311 x313 x314 x316 x317
#> 290 291 294 296 299 301 303 310 311 313 314 316 317
#> x320 x325 x329 x334 x337 x338 x344 x345 x348 x349 x350 x352 x354
#> 320 325 329 334 337 338 344 345 348 349 350 352 354
#> x355 x359 x362 x363 x364 x365 x367 x371 x372 x377 x379 x381 x383
#> 355 359 362 363 364 365 367 371 372 377 379 381 383
#> x384 x385 x389 x391 x392 x394 x395 x398 x400 x402 x404 x405 x407
#> 384 385 389 391 392 394 395 398 400 402 404 405 407
#> x408 x412 x414 x416 x417 x419 x421 x422 x424 x425 x426 x427 x429
#> 408 412 414 416 417 419 421 422 424 425 426 427 429
#> x435 x438 x440 x441 x442 x443 x445 x446 x447 x448 x452 x456 x458
#> 435 438 440 441 442 443 445 446 447 448 452 456 458
#> x460 x466 x468 x469 x471 x472 x473 x474 x477 x478 x479 x481 x484
#> 460 466 468 469 471 472 473 474 477 478 479 481 484
#> x485 x487 x488 x490 x493 x496 x498 x499 x500 x505 x508 x510 x511
#> 485 487 488 490 493 496 498 499 500 505 508 510 511
#> x514 x515 x517 x520 x521 x523 x526 x530 x533 x535 x537 x538 x540
#> 514 515 517 520 521 523 526 530 533 535 537 538 540
#> x542 x543 x544 x545 x546 x548 x549 x550 x551 x553 x556 x561 x567
#> 542 543 544 545 546 548 549 550 551 553 556 561 567
#> x571 x572 x573 x574 x577 x578 x583 x585 x588 x593 x596 x597 x598
#> 571 572 573 574 577 578 583 585 588 593 596 597 598
#> x599 x601 x602 x605 x606 x609 x611 x615 x618 x621 x622 x623 x626
#> 599 601 602 605 606 609 611 615 618 621 622 623 626
#> x628 x629 x630 x633 x634 x635 x637 x638 x641 x645 x647 x649 x650
#> 628 629 630 633 634 635 637 638 641 645 647 649 650
#> x653 x655 x656 x657 x661 x662 x668 x673 x675 x676 x677 x678 x679
#> 653 655 656 657 661 662 668 673 675 676 677 678 679
#> x680 x687 x688 x689 x691 x695 x697 x701 x703 x705 x706 x709 x713
#> 680 687 688 689 691 695 697 701 703 705 706 709 713
#> x715 x716 x717 x718 x721 x722 x730 x731 x732 x734 x736 x740 x743
#> 715 716 717 718 721 722 730 731 732 734 736 740 743
#> x744 x745 x746 x747 x749 x750 x751 x752 x756 x757 x761 x763 x764
#> 744 745 746 747 749 750 751 752 756 757 761 763 764
#> x765 x769 x771 x777 x778 x780 x783 x784 x785 x786 x788 x789 x794
#> 765 769 771 777 778 780 783 784 785 786 788 789 794
#> x797 x799 x800 x801 x805 x808 x811 x813 x818 x819 x820 x821 x822
#> 797 799 800 801 805 808 811 813 818 819 820 821 822
#> x825 x826 x828 x829 x832 x833 x834 x837 x838 x840 x844 x845 x847
#> 825 826 828 829 832 833 834 837 838 840 844 845 847
#> x851 x852 x853 x854 x855 x856 x861 x862 x863 x866 x869 x871 x873
#> 851 852 853 854 855 856 861 862 863 866 869 871 873
#> x875 x876 x877 x879 x882 x884 x889 x893 x895 x896 x897 x898 x900
#> 875 876 877 879 882 884 889 893 895 896 897 898 900
#> x906 x907 x908 x910 x912 x917 x918 x920 x922 x923 x930 x931 x934
#> 906 907 908 910 912 917 918 920 922 923 930 931 934
#> x936 x937 x938 x939 x940 x941 x944 x945 x946 x950 x952 x953 x954
#> 936 937 938 939 940 941 944 945 946 950 952 953 954
#> x955 x958 x962 x963 x965 x967 x969 x970 x972 x973 x974 x975 x977
#> 955 958 962 963 965 967 969 970 972 973 974 975 977
#> x978 x979 x980 x982 x983 x988 x990 x991 x993 x995 x996 x1000 x1001
#> 978 979 980 982 983 988 990 991 993 995 996 1000 1001
#> x1002 x1003 x1005 x1006 x1007 x1009 x1011 x1013 x1015 x1016 x1019 x1022 x1023
#> 1002 1003 1005 1006 1007 1009 1011 1013 1015 1016 1019 1022 1023
#> x1024 x1025 x1026 x1030 x1031 x1033 x1034 x1035 x1036 x1037 x1038 x1039 x1040
#> 1024 1025 1026 1030 1031 1033 1034 1035 1036 1037 1038 1039 1040
#> x1041 x1043 x1044 x1047 x1048 x1049 x1050 x1052 x1055 x1056 x1058 x1059 x1061
#> 1041 1043 1044 1047 1048 1049 1050 1052 1055 1056 1058 1059 1061
#> x1062 x1064 x1065 x1071 x1072 x1073 x1076 x1079 x1082 x1083 x1085 x1089 x1092
#> 1062 1064 1065 1071 1072 1073 1076 1079 1082 1083 1085 1089 1092
#> x1094 x1095
#> 1094 1095
cpts <- segment(DataCPSim, method = "wbs")
changepoints(cpts$segmenter)
#> [1] 547 822 939 972 980 982 997 999 1031 1033 1040 1041 1063 1066