Skip to contents

Default class for candidate changepoint sets

Usage

new_seg_basket(
  x = numeric(),
  algorithm = NA,
  cpt_list = list(),
  seg_params = list(),
  model_name = "meanshift_norm",
  penalty = "BIC",
  ...
)

seg_basket(x, ...)

Arguments

x

a numeric vector coercible into a stats::ts() object

algorithm

Algorithm used to find the changepoints

cpt_list

a possibly empty list() of candidate changepoints

seg_params

a possibly empty list() of segmenter parameters

model_name

character indicating the model used to find the changepoints.

penalty

character indicating the name of the penalty function used to find the changepoints.

...

currently ignored

Value

A seg_basket() object.

Examples

seg <- seg_basket(DataCPSim, cpt_list = list(c(365), c(330, 839)))
str(seg)
#> List of 6
#>  $ data      : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#>  $ algorithm : logi NA
#>  $ basket    : tibble [2 × 7] (S3: tbl_df/tbl/data.frame)
#>   ..$ changepoints:List of 2
#>   .. ..$ : num 365
#>   .. ..$ : num [1:2] 330 839
#>   ..$ model       :List of 2
#>   .. ..$ :List of 6
#>   .. .. ..$ data         : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#>   .. .. ..$ tau          : num 365
#>   .. .. ..$ region_params: tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. .. ..$ region  : chr [1:2] "[0,365)" "[365,1.1e+03]"
#>   .. .. .. ..$ param_mu: num [1:2] 35.8 76.8
#>   .. .. ..$ model_params : Named num 1716
#>   .. .. .. ..- attr(*, "names")= chr "sigma_hatsq"
#>   .. .. ..$ fitted_values: num [1:1096] 35.8 35.8 35.8 35.8 35.8 ...
#>   .. .. ..$ model_name   : chr "meanshift_norm"
#>   .. .. ..- attr(*, "class")= chr "mod_cpt"
#>   .. ..$ :List of 6
#>   .. .. ..$ data         : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#>   .. .. ..$ tau          : num [1:2] 330 839
#>   .. .. ..$ region_params: tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. .. ..$ region  : chr [1:3] "[0,330)" "[330,839)" "[839,1.1e+03]"
#>   .. .. .. ..$ param_mu: num [1:3] 35.9 49.2 125.6
#>   .. .. ..$ model_params : Named num 858
#>   .. .. .. ..- attr(*, "names")= chr "sigma_hatsq"
#>   .. .. ..$ fitted_values: num [1:1096] 35.9 35.9 35.9 35.9 35.9 ...
#>   .. .. ..$ model_name   : chr "meanshift_norm"
#>   .. .. ..- attr(*, "class")= chr "mod_cpt"
#>   ..$ logLik      : num [1:2] -5636 -5256
#>   ..$ AIC         : num [1:2] 11281 10525
#>   ..$ BIC         : num [1:2] 11301 10555
#>   ..$ MBIC        : num [1:2] 11292 10551
#>   ..$ MDL         : num [1:2] 11306 10566
#>  $ seg_params: list()
#>  $ model_name: chr "meanshift_norm"
#>  $ penalty   : chr "BIC"
#>  - attr(*, "class")= chr "seg_basket"
as.ts(seg)
#> Time Series:
#> Start = 1 
#> End = 1096 
#> Frequency = 1 
#>    [1]  35.50961  29.00292  35.63508  32.98452  29.53557  25.40781  28.82497
#>    [8]  50.31157  24.93185  58.88063  30.35777  33.66315  32.58653  42.78788
#>   [15]  45.23963  23.66417  20.00954  31.64746  34.65507  68.49028  43.53948
#>   [22]  25.29938  57.19244  39.51995  23.79025  27.81451  42.00712  36.09812
#>   [29]  32.74664  34.73679  60.20919  55.52211  33.92043  32.48948  22.66494
#>   [36]  24.16119  27.05582  16.09789  31.69439  27.22202  20.64027  33.97673
#>   [43]  46.71000  25.28389  24.88207  41.75347  36.50448  35.98297  31.39612
#>   [50]  44.14153  67.82557  26.81619  27.55292  30.77449  51.17371  51.34317
#>   [57]  23.10056  22.92962  29.39409  73.67531  23.46017  35.36286  29.45083
#>   [64]  54.18062  25.04895  27.47914  51.41767  32.30387  43.17916  30.11288
#>   [71]  22.45535  33.70278  34.16720  44.64931  22.60994  50.26498  50.28394
#>   [78]  33.24944  38.73890  36.75336  52.38881  36.62906  16.68155  35.12389
#>   [85]  35.89239  61.81050  47.85419  30.26446  36.93150  54.81053  30.32479
#>   [92]  37.46579  49.93442  46.01734  24.86685  35.88435  42.25720  37.78741
#>   [99]  46.26335  38.52976  47.99867  44.28395  51.05976  50.99393  36.01026
#>  [106]  37.44409  16.77029  31.05583  22.40344  27.22149  28.31583  58.06805
#>  [113]  38.30690  47.26490  31.55811  47.63268  23.38334  33.30157  46.75618
#>  [120]  30.46511  23.17060  31.52724  38.55479  35.54940  49.63486  38.85458
#>  [127]  35.80205  24.50227  20.49025  31.59546  33.84992  30.02572  23.84156
#>  [134]  27.92167  28.04857  55.54324  23.82133  46.27102  35.95369  47.65766
#>  [141]  31.37265  37.43892  26.73598  39.78209  37.23990  38.69749  25.74961
#>  [148]  15.00954  41.03282  35.55822  28.20253  34.25572  36.72560  25.87219
#>  [155]  34.25647  41.05718  45.99951  35.09617  30.10936  56.29692  21.62607
#>  [162]  32.16878  48.08144  27.56512  24.86829  23.20973  23.35380  24.87480
#>  [169]  41.98302  43.00026  42.37708  57.59545  28.58172  35.77870  28.82814
#>  [176]  35.31054  45.07452  19.92057  49.94871  42.05699  45.69919  40.55247
#>  [183]  28.77050  34.25098  39.57524  27.14581  44.69057  36.14965  49.50564
#>  [190]  49.79043  17.99559  39.65697  44.97010  18.31935  31.24522  31.07475
#>  [197]  21.61906  40.06484  34.99030  21.94425  37.44403  40.21178  38.23743
#>  [204]  31.80890  34.61897  47.81524  34.58307  30.49509  45.29616  49.07757
#>  [211]  24.17640  35.64875  17.63070  21.61867  32.29813  26.41488  28.31542
#>  [218]  25.02318  20.23520  28.13247  63.69313  42.52417  29.03129  54.03181
#>  [225]  25.60167  66.22389  26.02854  43.94607  39.26708  21.90635  33.10292
#>  [232]  31.36953  68.74632  49.57971  36.77692  62.23430  33.17239  34.70213
#>  [239]  29.33086  40.40664  20.51693  56.48982  47.57652  18.78920  39.83695
#>  [246]  23.57444  32.90584  23.97282  29.16350  33.94278  33.32760  40.39087
#>  [253]  37.08789  34.55488  28.07540  34.55889  32.50873  30.26050  31.61021
#>  [260]  29.22609  21.66017  39.99861  31.54268  54.66244  28.83481  50.43102
#>  [267]  41.57023  36.52691  41.74322  29.88869  65.63664  28.92781  31.62743
#>  [274]  60.02248  23.41874  30.41566  49.28914  30.75073  41.08489  35.95343
#>  [281]  26.30653  30.42233  35.58619  27.11696  41.07739  32.16801  54.22658
#>  [288]  30.58481  32.75808  40.14170  38.59850  34.62828  26.92407  32.65613
#>  [295]  21.12857  21.76199  31.72514  32.81883  39.57492  29.56246  26.52171
#>  [302]  33.16808  30.46846  26.71148  20.12177  28.85316  25.85809  73.07025
#>  [309]  50.11722  55.60337  42.62562  53.62811  40.37492  36.09093  54.15097
#>  [316]  52.48111  28.21508  44.33563  15.14660  31.77283  28.02836  42.85488
#>  [323]  30.07936  32.42728  33.91356  17.04858  29.01530  31.04799  24.28621
#>  [330]  35.50456  45.96182  21.99371  38.45540  25.78633  45.07985  27.04933
#>  [337]  50.03548  29.92024  26.27057  24.47919  59.13347  35.87683  42.14550
#>  [344]  29.36456  44.58931  30.97851  21.83860  46.47922  39.71751  20.74531
#>  [351]  21.96494  27.95186  40.64999  65.79466  34.95445  33.87721  27.41981
#>  [358]  19.67562  39.39982  45.69528  22.18879  37.54553  23.15847  28.45508
#>  [365]  25.23477  33.00227  27.16574  34.19212  38.82416  17.26278  38.40626
#>  [372]  57.01508  40.28032  27.15082  32.21021  41.59108  44.75365  31.57659
#>  [379]  44.49800  41.11233  35.23455  24.47634  45.13415  37.24519  42.85021
#>  [386]  32.84645  37.01077  38.96790  40.08106  43.99265  32.24746  27.24075
#>  [393]  31.66613  34.98403  27.29397  34.99001  31.25752  30.07230  27.18477
#>  [400]  37.36462  34.40921  27.16085  37.36703  47.98335  43.48091  23.31231
#>  [407]  20.68531  40.72063  13.66989  27.99689  25.61063  27.89089  17.93238
#>  [414]  23.25505  69.87353  20.53952  38.76444  45.53784  43.99368  25.86236
#>  [421]  23.02465  26.68788  51.99475  31.49945  39.98303  25.96329  18.68290
#>  [428]  45.39740  41.85522  40.88774  33.13019  36.51401  43.93668  28.72223
#>  [435]  17.36850  29.80030  29.36764  33.21636  30.98314  44.00905  49.96474
#>  [442]  32.63317  34.95938  42.09920  25.98961  26.13540  40.91752  27.13926
#>  [449]  23.93415  44.34438  24.80069  39.56627  34.17161  29.33848  51.51685
#>  [456]  38.10154  17.89906  29.84155  20.73680  17.94649  20.14526  30.60828
#>  [463]  37.05229  26.99159  48.47064  29.63704  30.29811  29.44919  50.20743
#>  [470]  25.22852  19.31610  49.49408  31.13921  45.04409  26.36500  21.37141
#>  [477]  33.60464  39.82629  23.44417  50.85233  35.55273  31.42400  52.78349
#>  [484]  46.42078  32.84158  41.58214  37.57874  92.79539  21.87917  35.86701
#>  [491]  44.63170  23.67373  49.57926  37.82632  28.51937  54.19448  25.42921
#>  [498]  31.42047  45.75800  26.14005  32.43037  30.31998  60.34780  35.38384
#>  [505]  17.65934  49.95322  48.97623  24.37608  62.05997  17.90258  35.04199
#>  [512]  25.02686  37.13100  27.42116  46.56513  14.44667  18.13457  30.41839
#>  [519]  40.06058  33.26711  58.99535  23.18483  36.67044  24.95331  27.19064
#>  [526]  26.76947  37.48431  37.13503  22.80870  32.98376  16.45626  25.22453
#>  [533]  35.59700  24.01433  58.24541  34.09432  31.09085  29.28524  20.65437
#>  [540]  24.52000  61.00638  33.59970  19.62836  30.89483  27.49646  47.74031
#>  [547]  38.48854  79.28284  49.83587  41.20827  60.84168  58.74430  73.74234
#>  [554]  62.99021  44.73661  66.14946  78.63431  58.85001  56.29965  49.76806
#>  [561]  66.31184  77.24626  30.20323  34.36305  40.14230 115.76308  53.35118
#>  [568]  56.61291  54.02821  30.86656  64.91494  51.47610  58.02405  46.19877
#>  [575]  75.46288  62.38693  62.12430  29.65914  48.83256  48.45711  87.84555
#>  [582]  48.89591  79.45862  45.43495  61.17216  44.15376  40.81283  28.66775
#>  [589] 100.81542  80.80345  59.82787  60.46746  61.44131  33.23726  52.19624
#>  [596]  83.51128  53.55938  63.91426  43.91224  55.36213  54.68760  56.36276
#>  [603]  50.26803  63.36135  71.84053  44.01963  54.90876  48.05082  73.33604
#>  [610]  40.86609  53.14413  59.74683  74.13609  72.72819  73.80368  46.35780
#>  [617]  39.46049  69.37131  69.23278  39.48316  65.63175  50.51306  79.59284
#>  [624]  43.27989  29.25963  53.94132  47.30325  89.88726  64.49022  53.12747
#>  [631]  51.61317  47.72412 102.46424  79.80996  51.62739  45.94677  44.20380
#>  [638]  62.47154  56.71323  45.20940  33.56516  93.76083  56.27748  43.03061
#>  [645]  86.12136  66.81985 103.73717  45.81972  66.39085  43.21773  56.16747
#>  [652]  59.28413  50.73493  65.26301 107.46498  68.39817  77.53655  63.00234
#>  [659] 100.37694  50.08347  51.31859  47.84582  73.28803  56.60291  49.47953
#>  [666]  74.14721  51.88331  72.97605  37.36928  50.55296  94.49818  85.63369
#>  [673]  47.21940  51.29463  30.87699  40.99069  65.22233  84.18339  36.97547
#>  [680]  67.67693 130.27515  56.50564  52.08214  36.62894  50.17403  43.98132
#>  [687]  63.78818  69.71901  58.66280  34.25625  40.01212  38.51369  31.93027
#>  [694]  70.08009  60.78508  51.19670  65.45439  70.13630  38.38639  46.42615
#>  [701]  59.55314  49.09690  60.75484  66.66783  70.41840  77.79466  57.57120
#>  [708]  66.27876  40.41878  51.19402  90.55426  28.21335  67.71025  52.72485
#>  [715]  37.34428  72.43783  92.29608  55.59297  69.66448  58.30077  50.26778
#>  [722]  74.61613  50.92561  51.97960  99.50324  47.12665  87.80435 119.15289
#>  [729]  96.67512  27.20912  42.35955  51.36019  66.15466  50.99965  31.33727
#>  [736]  29.62981  55.37496  72.04834  44.82771  46.57539  64.62869  38.82131
#>  [743]  53.86127  30.62108  27.37893  85.39840  55.85290  64.89730  94.68730
#>  [750]  35.15146  37.51919  45.72001  89.69830  46.13428  66.35095  37.41977
#>  [757]  43.10677  40.13555  43.13188  24.73451  76.52571  36.36566  71.17790
#>  [764]  56.44084  63.19831  38.86127  56.54947  83.05808  41.66112  60.14119
#>  [771]  73.36839  36.83335  46.99687  68.72470  48.02621  37.04922  67.67630
#>  [778]  46.78206  43.38829  79.76107  43.42811  34.89142  46.70848  85.92108
#>  [785]  65.54841  39.49996  41.09837  47.97916  62.31907  75.42977  83.27070
#>  [792]  73.13176  58.56810  75.03824  37.08341  57.11212  62.88590  80.01578
#>  [799]  31.43220  50.27634  20.52318  57.18749  65.93147  42.64495  60.78448
#>  [806]  42.12619  44.69412  58.64844  68.76875 163.36185  59.30573  44.16434
#>  [813]  74.02857  42.16594  47.80402  46.06946  68.13544  58.27459  44.44837
#>  [820]  49.71347  41.92370  65.10552 190.42879 100.55114  84.73240  95.19440
#>  [827]  62.62765  81.34105  62.84927 119.41128  97.69586 103.24047 132.04779
#>  [834]  63.94897  61.11686  68.83021  80.70128 118.36174  69.88491  75.67939
#>  [841]  97.87433  84.47204 167.57416 119.33953 112.87803  94.60966  54.52644
#>  [848] 134.89541  80.76840 100.86500 125.36064  80.85360  81.27602 102.14881
#>  [855]  62.87013  89.81105  90.54166  77.87923 154.26053 104.44530  89.99370
#>  [862] 137.11783 108.63313  81.65888  91.76187 153.53548  93.17887 131.28943
#>  [869]  58.95745  63.59264  86.73104 159.01308  56.48464  53.76414  79.36095
#>  [876] 104.17268  82.69108  75.47191  80.10494 123.34176 117.11018  82.67987
#>  [883]  87.24288  77.92377 105.19438  75.47461  73.26672 103.96131  88.69445
#>  [890]  67.40834 115.24510 107.64339  93.11673 129.87959 126.03289 118.21727
#>  [897] 101.24318  85.84310  83.24171  94.37437  95.52714  58.18705  70.93290
#>  [904] 135.64519 122.17646  47.94730  81.90610  71.29312  59.56557  90.96883
#>  [911] 105.27981  68.10784  62.24482 118.12494  89.29744 104.93346  54.31292
#>  [918] 118.22755  85.99992  68.28882 116.87775  59.89081  88.51994 124.96078
#>  [925]  48.99528  83.42296  39.21350 104.91602  96.76956 112.59752  71.12703
#>  [932]  88.73937  68.98548  70.70640  93.68761 131.72255  82.59086  81.56980
#>  [939]  80.12171 160.72231 130.68852  61.65840 175.64769 103.14938 133.32521
#>  [946] 160.15746  97.61800 119.62046 125.04584 120.67301 110.96952  62.16252
#>  [953] 215.10540  81.98616 110.52191  53.11782  83.00635  59.01162 167.43096
#>  [960] 146.43115 136.73301  93.53995  92.63548  98.56852  59.88143 101.45146
#>  [967] 102.84065 115.38549 110.87331  96.65850  70.26512  73.19904 204.44288
#>  [974] 120.52524 148.47584 176.52242  72.50633  98.01507  85.07589 122.09749
#>  [981] 173.47087 272.06243 114.84247 194.43547 182.95500  99.70758 155.32184
#>  [988] 234.90205 149.08372 129.43951  92.17400 150.30666 127.34289  95.56536
#>  [995] 183.85856 173.20963 119.36203 298.97556 239.90785 149.72990 145.83624
#> [1002] 199.97769 221.71715 124.50443 127.57657 126.63670 224.84161 193.52027
#> [1009]  67.17684 193.24399 163.77183 115.04808 139.80491 194.08049 142.56183
#> [1016] 150.05278 112.32713 229.27074 123.95988 146.80726 185.69923 111.44768
#> [1023] 148.97687 122.53709 127.37003  92.55487 106.25934 151.61132 166.55049
#> [1030] 166.27216  89.84812 285.64838 210.83361 119.86280 120.26534 166.67314
#> [1037] 128.77576 128.26908 203.90985 124.66021 285.09853 111.19870 185.07644
#> [1044]  88.79945  97.17543 121.60783 183.18550 113.42228 234.66441 148.81920
#> [1051] 127.67544 144.30028 183.15017 180.80073 212.84778  81.80066 156.28369
#> [1058] 217.85070 136.70053 196.65904 155.49179 120.33784 123.21350 293.16047
#> [1065] 141.29326 286.30265 137.11341 191.99534 155.88733 232.83108 141.37831
#> [1072] 114.62536 154.08698 129.56200 197.71852 143.31929 155.63173 166.92790
#> [1079] 151.48311 133.67364 183.79864 134.72402 108.41123 113.01052 145.28928
#> [1086]  85.79995 220.96699 127.18015 215.14311 190.93505 156.44133 164.06449
#> [1093] 164.81190  85.39927 179.14410 135.09159
changepoints(seg)
#> [1] 330 839
fitness(seg)
#>      BIC 
#> 10554.84